miguelrgonzalez / Play--Selenium-webdrive

Play! Selenium webdrive support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Selenium

Provides selenium webdriver support for play applications.

Sample application

Under sample/sample-app you can find a simple selenium test example using the module.

Configuration

So far only 2 configuration items must be added:

test.selenium.browsers

List of browsers you want the tests to be executed at

 test.selenium.browsers=firefox,iexplorer,chrome,safari : 

test.selenium.hub.url

Url of the selenium grid server

 test.selenium.hub.url=http://localhost:4444/wd/hub

Creating tests

Create your test as you would normally do using testng and extend the class play.modules.selenium.custom.BaseTest

Example:

public class GoogleTest extends BaseTest {
    public GoogleTest(DesiredCapabilities cap, String hub) throws Exception {
        super(cap, hub);
    }
    @Test
    public void checkWebpage () {
        driver.get("http://www.google.com");
        driver.findElement(By.name("q")).sendKeys("Swets");
        driver.findElement(By.name("q")).submit();
        driver.close();
    }
}

Running the tests

First start the server. You should run something like this:

java -jar selenium-server-standalone-2.20.0.jar -role hub

The start all the different nodes you want:

java -jar selenium-server-standalone-2.20.0.jar -role node -hub http://<selenium grid server>:4444/grid/register

If you plan to use internet explorer browser on you test you need to be a little bit more specific when starting the node:

java -jar selenium-server-standalone-2.20.0.jar -role node -hub http://<selenium grid server>:4444/grid/register -browser "browserName=internet explorer,version=8,platform=WINDOWS"

This is to workaround a bug on how selenium identifies the node’s platform. Issue 1699

And finally you can run your tests:

ant runTestNG

About

Play! Selenium webdrive support


Languages

Language:Java 80.7%Language:Python 19.3%