A basic distributed installation was covered in Section 23.2.2, “A Distributed Testing Environment”.
23.7.1. Running Tests Remotely
Remote tests are just like locally executed JUnit tests, except instead of using a browser driver, you use a RemoteWebDriver that can connect to the hub. The hub delegates the connection to a grid node with the desired capabilities, that is, which browsers are installed in a suitable node. The capabilities are described with a DesiredCapabilities object.
For example, in the example tests given in the example folder, we create and use a remote driver as follows:
@Test
public void testRemoteWebDriver() throws MalformedURLException {
//Require Firefox in the test node DesiredCapabilities capability =
DesiredCapabilities.firefox();
//Create a remote web driver that connects to a hub
//running in the local host
WebDriver driver = TestBench.createDriver( new RemoteWebDriver(new URL(
"http://localhost:4444/wd/hub"), capability));
// Then use it to run a test as you would use any web driver try {
driver.navigate().to( "http://demo.vaadin.com/sampler#TreeActions");
WebElement e = driver.findElement(By.xpath( "//div[@class='v-tree-node-caption']"+ "/div[span='Desktops']"));
new Actions(driver).moveToElement(e).contextClick(e)
.perform(); } finally {
driver.quit();
}
}
Please see the API documentation of the DesiredCapabilities class for a complete list of supported capabilities.
Running the example requires that the hub service and the nodes are running. Starting them is described in the subsequent sections. Please refer to Selenium documentation [http://seleniumhq.org/docs/07_selenium_grid.html] for more detailed information.
23.7.2. Starting the Hub
The TestBench grid hub listens to calls from test runners and delegates them to the grid nodes. The grid hub service is included in the Vaadin TestBench JAR and you can start it with the following command:
$ java -jar vaadin-testbench-standalone-3.1.0.jar \ -role hub
You can open the control interface of the hub also with a web browser. Using the default port, just open URL http://localhost:4444/. Once you have started one or more grid nodes, as instructed in the next section, the "console" page displays a list of the grid nodes with their browser capabilities.