Search code examples
seleniumselenium-grid

Selenium grid newbie questions


Ok, I have already several testcases written for Webdriver approach. But now I need get the Selenium Grid for possible stress testing of the webapp.

I found this demo but its unable to control the Firefox 11. Then I found out this wiki page which is two level higher than I can understand, but that JAR File is supposedly able to control the Firefox 11.

What I need - some resources how to get the Grid started and how to let it do simple test - like writing "Hello World" into Google search bar and then clicking "Search."

EDIT This is the error when I am trying to run the grid as node

D:\_dev\selenium-grid-1.0.8\lib>java -jar selenium-server-standalone-2.20.0.jar -role node  -hub http://localhost:4444/grid/register
22-Mar-2012 10:33:48 org.openqa.grid.selenium.GridLauncher main
INFO: Launching a selenium grid node
Exception in thread "main" java.lang.NoSuchMethodError: java.lang.String.isEmpty()Z
    at org.openqa.grid.common.RegistrationRequest.getRemoteControlConfiguration(RegistrationRequest.java:585)
    at org.openqa.grid.internal.utils.SelfRegisteringRemote.startRemoteServer(SelfRegisteringRemote.java:86)
    at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:72)

And this is output from server which seems ok

D:\_dev\selenium-grid-1.0.8\lib>java -jar selenium-server-standalone-2.20.0.jar -role hub
22-Mar-2012 10:33:33 org.openqa.grid.selenium.GridLauncher main
INFO: Launching a selenium grid server
360 [main] INFO org.seleniumhq.jetty7.server.Server - jetty-7.x.y-SNAPSHOT
422 [main] INFO org.seleniumhq.jetty7.server.handler.ContextHandler - started    o.s.j.s.ServletContextHandler{/,null}
438 [main] INFO org.seleniumhq.jetty7.server.AbstractConnector - Started    [email protected]:4444

Solution

  • If you are working with windows, you need to add the path to firefox to your PATH environment variable. The reason for this is, that windows then knows what program to start, when you call firefox from command line, for example.

    Then you need to donwload the selenium server standalone and then start the hub

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

    and also the client:

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

    Now you need to create a new Java Project in Eclipse, for example like so:

    class MyFristTest{
    
    //using the @test annotation tells eclipse
    //to use junit (or tells you to import it)
    @Test
    public void myTest(){
        Selenium selenium = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://www.google.com”);
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
        driver.get("http://www.example.com");
        driver.findElement(By.linkText("RFC 2606")).click();
        driver.findElement(By.linkText("txt")).click();
    
    }
    

    If you now start the JUnit Test, it should magically work.