-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Examples] Fix java webbit websockets selenium
Updated dependencies and added spiffy new webdriver factory that in combination with the driver-binary-downloader-maven-plugin just works. Related issues: - #1033 This fixes #1033
- Loading branch information
1 parent
c70c0ec
commit 63bba6c
Showing
26 changed files
with
290 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
selenium_standalone/ | ||
selenium_standalone_zips/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 9 additions & 14 deletions
23
...bsockets-selenium/src/test/java/cucumber/examples/java/websockets/NavigationStepdefs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
package cucumber.examples.java.websockets; | ||
|
||
import cucumber.api.java.en.Given; | ||
import cucumber.api.java8.En; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
public class NavigationStepdefs { | ||
private final WebDriver webDriver; | ||
public class NavigationStepdefs implements En { | ||
|
||
public NavigationStepdefs(SharedDriver webDriver) { | ||
this.webDriver = webDriver; | ||
} | ||
|
||
@Given("^I am on the front page$") | ||
public void i_am_on_the_front_page() throws InterruptedException { | ||
webDriver.get("http://localhost:" + ServerHooks.PORT); | ||
Given("^I am on the front page$", () -> { | ||
webDriver.get("http://localhost:" + ServerHooks.PORT); | ||
|
||
// The input fields won't be enabled until the WebSocket has established | ||
// a connection. Wait for this to happen. | ||
WebDriverWait wait = new WebDriverWait(webDriver, 1); | ||
wait.until(ExpectedConditions.elementToBeClickable(By.id("celcius"))); | ||
// The input fields won't be enabled until the WebSocket has established | ||
// a connection. Wait for this to happen. | ||
WebDriverWait wait = new WebDriverWait(webDriver, 1); | ||
wait.until(ExpectedConditions.elementToBeClickable(By.id("celcius"))); | ||
}); | ||
} | ||
} |
22 changes: 6 additions & 16 deletions
22
...bbit-websockets-selenium/src/test/java/cucumber/examples/java/websockets/ServerHooks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,14 @@ | ||
package cucumber.examples.java.websockets; | ||
|
||
import cucumber.api.java.After; | ||
import cucumber.api.java.Before; | ||
import cucumber.api.java8.En; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
public class ServerHooks { | ||
public static final int PORT = 8887; | ||
public class ServerHooks implements En { | ||
static final int PORT = 8887; | ||
|
||
private TemperatureServer temperatureServer; | ||
|
||
@Before | ||
public void startServer() throws IOException, ExecutionException, InterruptedException { | ||
temperatureServer = new TemperatureServer(PORT); | ||
temperatureServer.start(); | ||
} | ||
|
||
@After | ||
public void stopServer() throws IOException, ExecutionException, InterruptedException { | ||
temperatureServer.stop(); | ||
public ServerHooks(){ | ||
Before(() -> temperatureServer = new TemperatureServer(PORT).start()); | ||
After(() -> temperatureServer.stop()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 8 additions & 16 deletions
24
...sockets-selenium/src/test/java/cucumber/examples/java/websockets/TemperatureStepdefs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,18 @@ | ||
package cucumber.examples.java.websockets; | ||
|
||
import cucumber.api.java.en.Then; | ||
import cucumber.api.java.en.When; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class TemperatureStepdefs { | ||
private final WebDriver webDriver; | ||
import cucumber.api.java8.En; | ||
import org.openqa.selenium.By; | ||
|
||
public class TemperatureStepdefs implements En { | ||
|
||
public TemperatureStepdefs(SharedDriver webDriver) { | ||
this.webDriver = webDriver; | ||
} | ||
|
||
@When("^I enter (.+) (celcius|fahrenheit)$") | ||
public void i_enter_temperature(double value, String unit) { | ||
webDriver.findElement(By.id(unit)).sendKeys(String.valueOf(value)); | ||
} | ||
When("^I enter (.+) (celcius|fahrenheit)$", (Double value, String unit) -> | ||
webDriver.findElement(By.id(unit)).sendKeys(String.valueOf(value))); | ||
|
||
@Then("^I should see (.+) (celcius|fahrenheit)$") | ||
public void i_should_see_temperature(double value, String unit) { | ||
assertEquals(String.valueOf(value), webDriver.findElement(By.id(unit)).getAttribute("value")); | ||
Then("^I should see (.+) (celcius|fahrenheit)$", (Double value, String unit) -> | ||
assertEquals(String.valueOf(value), webDriver.findElement(By.id(unit)).getAttribute("value"))); | ||
} | ||
} |
Oops, something went wrong.