//
you're reading...
Grid2

Setting up Grid2 and working with it!

Since setting up a grid and a webdriver node is something that I have been seeing as a Frequently Asked Question, I thought why not start off my “so-called” technical blog with that.

So here’s how it can be done.

I will be using a WINDOWS 7, 64 bit machine for this blog, and have chosen to work with JDK 1.6 (32 bit). Incase you are wondering why am I running a 32 bit JDK on a 64 bit Machine, the reason is simple. From my random browsing learnings, I understand that IE 64 bit doesnt have a big fan club which is why by default in a Windows 7 machine, the moment you click on IE icon, you spin off a 32 bit IE version and not the 64 bit version. But if you use 64bit JDK to spawn your Grid or your Web Driver node for that matter, it ends up spawning the 64 bit IE which is not something that we desire. This should explain why I have chosen to use 32 bit JDK.

  1. You would need a copy of the standalone jar for selenium. It can be downloaded from http://code.google.com/p/selenium/downloads/list. At the time of me writing up this blog, the version that was available was 2.17.0. So I will be referring to this particular version through-out this post.
  2. Now we would need a copy of the chrome driver so that our grid can support chrome executions as well. The chrome driver also can be downloaded from the link mentioned in Step (1).

After downloading both the above mentioned artifacts from the internet, I have chosen to organize them in a way such that I can easily figure out things. Here’s a screenshot of how my directory to which I unzipped all of these things look like.

So now that you know how my folder structure looks like (with some pretty naive arrow mark indicators 🙂 ) lets get started.

For my convenience I chose to write a simple batch file, which contains all the instructions that are needed to spawn a webdriver node as well as the grid hub. So lets dive into seeing how exactly does my “so-called” batch file looks like. (The contents of grid-startup-batch.bat file)

Assumptions :

The current directory as denoted by %CD% DOS environment variable, should have the JDK available. If not feel free to modify this environment variable to the actual location where your Java Installation is available.

grid-startup-batch.bat contents 

set HERE=%CD%
set JAVA_HOME=%HERE%\jdk1.6.0_21
set PATH=%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%PATH%
set SELENIUM_VERSION=2.17.0
set CHROME_VERSION=chrome-18.0.995.0
set HUB_URL=http://localhost:4444/grid/register
set CHROME_DRIVER_LOC=%HERE%/%CHROME_VERSION%/chromedriver.exe
start java -jar selenium-server-standalone-%SELENIUM_VERSION%.jar -role hub
start java -jar selenium-server-standalone-%SELENIUM_VERSION%.jar -role node
-Dwebdriver.chrome.driver= %CHROME_DRIVER_LOC% -hub %HUB_URL% -port 5556

This batch now has all the things that I need to kick start my Grid environment. To start the grid, all that I would need to do is, double click this batch file and voila! The grid and a webdriver node is now running.

You should see two command windows open up as below :

To open the Grid console, open a web browser of your choice and type :

http://localhost:4444/grid/console

Lets check how our Grid console looks like…

The above picture should give a good understanding of a lot of basic things.

Now lets focus on how to connect to this Grid and work with it.

For this e.g., I will be trying to connect to the IE instance that is being provided by this grid.

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName(DesiredCapabilities.internetExplorer().getBrowserName());
URL url = new URL("http://localhost:4444/wd/hub");
RemoteWebDriver driver = new RemoteWebDriver(url, capabilities);

In case you are wondering as to why am I creating a creating a new instance of DesiredCapabilities and packing in the various required values instead of merely using :

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer() ;

here is the explanation.

DesiredCapabilities.internetExplorer()

This above line will give you a capability object for IE, with the PLATFORM value set to WINDOWS.

If you do a mouse move over on the second IE icon on the grid console (first icon from the right) you will see the following info being shown there.

{seleniumProtocol=WebDriver, browserName=internet explorer, maxInstances=1}type=WebDriver

This means that the Grid only has a node which can service an Internet Explorer browser, but NOT a node which can service an Internet Explorer browser running on the PLATFORM “WINDOWS”.

So if you use

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();

You are most likely to see the below exception (This is the Grid’s way of telling you, it cannot find a node to forward your request to):

Error forwarding the new session cannot find : {platform=WINDOWS, browserName=internet explorer, version=};

So how do you run tests such that your execution is to be routed specifically to a Internet Explorer running on WINDOWS platform ?

No big deal. Just start using a node Configuration file when starting your web driver node.

Node Configuration ??!!??? What is that ?

Node Configuration is basically a JSON file that helps tell the web driver node, as to what all will your node be supporting for executions.

So how do I create a Node configuration file ?

How does it look like ?

Where can I find a sample ?

Did I read your mind, or did you end up asking the same questions that I had too ! 🙂

Here’s how you do it:

Take a look at the configuration file available here : https://gist.github.com/1106418

Once you have this configuration file ready, you would just need to modify your “grid-startup-batch.bat” that we discussed above, and replace the line

start java -jar selenium-server-standalone-%SELENIUM_VERSION%.jar -role node
-Dwebdriver.chrome.driver=%CHROME_DRIVER_LOC% -hub %HUB_URL% -port 5556

with the line

start java -jar selenium-server-standalone-%SELENIUM_VERSION%.jar -role node
-Dwebdriver.chrome.driver=%CHROME_DRIVER_LOC% -hub %HUB_URL% -port 5556  -nodeConfig webconfig.txt

where webconfig.txt is the name that you chose to give your configuration file and it is available in the current directory where you created your “grid-startup-batch.bat” batch file.

What if I wanted to know how does a full fledged configuration file look like ?

You can take a look at this file from the selenium code base :

https://github.com/SeleniumHQ/selenium/blob/master/java/server/src/org/openqa/grid/common/defaults/DefaultNodeWebDriver.json

What if I wanted to test against a specific version of a browser say “Firefox 8” in my grid ?

You will follow the same approach, but now you would set the browser version also in your DesiredCapabilities object as below :

capabilities.setVersion("8");

then modify the webconfig.txt file, add version parameter to it as below

"version":"8"

restart your Grid and you should get it done!

Some points to remember :

Grid2 will not let you set custom values to “browser name” and “platform”. But you can set whatever values you want to the browser version parameter and it has got nothing to do with your actual browser version.

Hope that de-mystifies to some extent on the basics required on how to work with Grid2.

Cheers !

Discussion

56 thoughts on “Setting up Grid2 and working with it!

  1. I had the same issue than you with Internet Explorer.
    I got it fixed by setting the platform to ANY

    #Ruby
    cap = Selenium::WebDriver::Remote::Capabilities.ie
    cap.platform = :ANY

    Posted by mattrab | January 24, 2012, 6:26 am
  2. Man God BlessYa !!!!! Your explanation is way better than the technical manual on the Grid 2 wiki. Thanks dude, you’re the best

    Posted by Dreamer | February 28, 2012, 7:26 pm
  3. this really should be put into the grid wiki, this was very helpful to me! Thanks for writing this up!

    Posted by Mike | March 13, 2012, 12:55 am
  4. This post is very helpful to me, if i want to run on selenium RC what changes needs to do

    Posted by Sreeni | March 21, 2012, 7:08 pm
  5. In this article
    start java -jar selenium-server-standalone-%SELENIUM_VERSION%.jar -role node
    -Dwebdriver.chrome.driver=%CHROME_DRIVER_LOC% -hub %HUB_URL% -port 5556 -nodeConfig webconfig.txt

    above port is 5556, but in webconfig.txt i see port =5555 is this ok.

    Posted by Sreeni | March 21, 2012, 7:21 pm
  6. can you extend this article by example how to run tests parallel ( can be one test but executed on more then one node at the same time). it would be great to find this information in one place (next to great article about configuration of grid).

    Posted by Edward Gierek | May 10, 2012, 4:12 pm
  7. Hi Krishnan,
    I was trying to test parallelly using testng. I have a virtualization software called cameyo and I have prepared multiple firefox executables and registered multiple firefoxes in same node. But while running I’m getting “Unable to bind to locking port 7054 within 45000 ms” error. Could you pls tell me what i need to do this. Running those firefoxes with FirefoxDriver is working fine.I’m using selenium2.22.0 version

    Posted by Kishor | August 17, 2012, 2:47 pm
  8. Great article. Very well done. I would also be very interested in your write-up for running tests in parallel.

    Thanks.

    Posted by Keith D Commiskey | December 1, 2012, 6:46 am
  9. Nice article, but what about when using the old fashion RC code? To my understanding, the capabilities cannot be set when using the DefaultSelenium constructor to instantiate a selenium object, correct?

    Of course, there always is the option to refactor from RC to WebDriver style, but that requires a lot of time and resources, which is not always available for QA teams.

    Do you have a tutorial to run RC code against Grid 2 and multiple versions of a same browser (ff 10, 17, etc.)?

    Thanks

    Posted by pascal | December 7, 2012, 9:03 pm
  10. Nice Article. helped me and saved my time.

    Thank a Ton!

    Posted by Satheesh | December 19, 2012, 4:32 pm
  11. Hi Krishnan,

    It is very useful article. Thanks for that. I have configured exactly i way said, but i am facing below mentioned error. I tried all possible ways.
    error is :
    The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see etc etc.
    facing same error when i try to run through ie as well.

    The batch files contents are :
    set HERE=%CD%
    set JAVA_HOME=%HERE%\jdk1.6.0_21
    set PATH=%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%PATH%

    set SELENIUM_VERSION=2.28.0
    set CHROME_VERSION=chromedriver_win_23.0.1240.0
    set HUB_URL=http://localhost:4444/grid/register
    set CHROME_DRIVER_LOC=%HERE%/%CHROME_VERSION%/chromedriver.exe
    set IE_DRIVER_LOC=D:/selinium/IEDriverServer_Win32_2.28.0/IEDriverServer.exe

    start java -jar selenium-server-standalone-%SELENIUM_VERSION%.jar -role hub

    start java -jar selenium-server-standalone-%SELENIUM_VERSION%.jar -role node -Dwebdriver.chrome.driver= %CHROME_DRIVER_LOC% -hub %HUB_URL% -port 5556

    start java -jar selenium-server-standalone-%SELENIUM_VERSION%.jar -role node -Dwebdriver.ie.driver= %IE_DRIVER_LOC% -hub %HUB_URL% -port 5557

    Lemme know if you some more info..

    Posted by Nihar | January 17, 2013, 5:42 pm
    • You are missing the chrome driver binary setting in the second node.

      Posted by Confusions Personified | January 19, 2013, 7:05 am
      • can you pls tell me little clearly. What i mean is can i know where i can find chrome binary file. Is it the same with ie case as well. I am facing same issue with ie as well. Thanks for help

        Posted by NiharBabu | January 19, 2013, 9:00 pm
      • can i know how it should be done. Because i tried adding the below line of code
        capabilities.setCapability(“chrome.binary”, “C:/Users/u0142168/AppData/Local/Google/Chrome/Application”); and run it to set chrome driver settings but failed to execute successfully, facing the same error. Same is the case with IE aswell. Please guide me.

        Posted by Nihar | January 21, 2013, 2:38 pm
      • The easiest way of doing this would be to download the chromedriver binary and IEDriver binary from the selenium site and add its location to your PATH variable.

        Posted by Confusions Personified | January 24, 2013, 11:08 am
  12. Great info krishnan, Can you create a blog for integrating grid with Jenkins? I am confused how i can start up batch and node from Jenkins. I tried to use pre-build steps for starting batch and nodes, however the jenkins hung after kicking off the batch command.

    Posted by sirus | March 15, 2013, 3:04 am
  13. HI,

    First of all Thank you so much for this article. I am a first timer for Selenium and it was quite understandable. 🙂

    However, while running my test case it fails with exception
    Exception in thread “main” org.openqa.selenium.WebDriverException:

    Error 500 Server Error

    HTTP ERROR: 500
    Problem accessing /grid/register/session. Reason:

        Server Error

    Powered by Jetty://

    I guess it has something to do with my node. It shows Invalid Parameter Exception. I could have sent you a screenshot but I can’t paste or attach here.

    Please help me! Its very critical for me.

    Thanks
    Sushmita

    Posted by Sushmita | March 15, 2013, 4:57 pm
    • Sushmita,
      You seem to have a problem in your node configuration file. Please use an online JSON validator [ something like http://jsonformatter.curiousconcept.com/ ] to check if your nodeconfig.txt file is a valid JSON file.

      Posted by Confusions Personified | March 15, 2013, 8:03 pm
      • Krishnan,

        i am new to the selenium grid and was trying to set it up with your detailed explanation above. while executing i got the same error.
        Exception in thread “main” org.openqa.selenium.WebDriverException:

        Error 500 Server Error

        HTTP ERROR: 500
        Problem accessing /grid/register/session. Reason:

        Server Error
        Powered by Jetty://
        i have checked the Json file in the online validator, it gives an error only for the “host”: ip, that has to be in string. i changed it to string. Still i receive the same error. Your help is highly appreciated.

        Thanks,
        Suresh

        Posted by Suresh | September 17, 2013, 3:44 pm
  14. Hi,

    I am getting the following error.I have tried the same way as given in this blog.Please help on resolving this,

    java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:143)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:95)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:103)
    at library.Alerts.testAlert(Alerts.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1208)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:753)
    at org.testng.TestRunner.run(TestRunner.java:613)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:335)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:330)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
    at org.testng.SuiteRunner.run(SuiteRunner.java:241)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1169)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1094)
    at org.testng.TestNG.run(TestNG.java:1006)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:107)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:199)

    Thanks,
    Akshitha

    Posted by Akshitha | March 19, 2013, 5:09 am
  15. Adding the way i tried the scenario to get more insight to the issue..

    command to start hub = java -jar selenium-server-standalone-2.31.0.jar -role hub
    command to start node = java -jar selenium-server-standalone-2.31.0.jar -role wd -hub http://localhost:4444/grid/register -port 5556 -nodeConfig h.txt

    test case=
    public class Alerts{

    @Test
    public void testAlert()
    {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName(DesiredCapabilities.internetExplorer().getBrowserName());

    try {
    WebDriver driver = new RemoteWebDriver(new URL(“http://localhost:4444/webdriver/hub”), capabilities);
    driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
    driver.get(“http://www.rediff.com/”);
    driver.findElement(By.cssSelector(“div.test_wrapperleft a div.newiconsprite.icmail”)).click();
    driver.findElement(By.cssSelector(“div#div_rediffmail form div input.vmiddle”)).click(); //or submit()
    Alert a = driver.switchTo().alert();
    System.out.println(a.getText());
    a.accept();
    //a.dismiss();
    System.out.println(driver.getTitle());
    } catch (MalformedURLException e) {
    e.printStackTrace();
    System.out.println(“inside catch”);
    }
    }
    }

    Posted by Akshitha | March 19, 2013, 5:35 am
  16. Hi,

    I configured everything as you said in the post. Its working very fine on firefox, i created many scripts. But now I need to run test cases on IE and chrome and both the browser are giving me exception.

    Exception in thread “main” org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.ie.driver system property;

    I have downloaded the drivers for both.
    Location for IE driver is : C:\Users\Administrator\Downloads\IEDriverServer_x64_2.31.0\IEDriverServer.exe
    I have also set enabled Protected mode true for all zones in IE

    Here is my code for IE

    public class Test {
    public static void main(String[] args) throws MalformedURLException {

    // Set Path where the IE driver is
    System.setProperty(“webdriver.ie.driver”,”C:\\Users\\Administrator\\Downloads\\IEDriverServer_x64_2.31.0\\IEDriverServer.exe”);

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    capabilities.setBrowserName(DesiredCapabilities.internetExplorer().getBrowserName());

    URL url = new URL(“http://localhost:4444/wd/hub”);
    WebDriver driver = new RemoteWebDriver(url, capabilities);

    //Implicit Wait
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    // And now use this to visit Google
    driver.get(“https://www.google.com”);
    }}

    My batch file
    set HERE=C:\Users\Administrator\Downloads
    set JAVA_HOME=%HERE%\jdk-7u13-windows-x64
    set PATH=%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%PATH%
    set SELENIUM_VERSION=2.29.0
    set CHROME_VERSION=chromedriver_win_26.0.1383.0
    set HUB_URL=http://localhost:4444/grid/register
    set CHROME_DRIVER_LOC=C:\Users\Administrator\Downloads\chromedriver_win_26.0.1383.0\chromedriver.exe
    set IE_DRIVER_LOC=C:\Users\Adminstrator\Downloads\IEDriverServer_x64_2.31.0\IEDriverServer.exe
    start java -jar selenium-server-standalone-2.29.0.jar -role hub
    start java -jar selenium-server-standalone-2.29.0.jar -role node
    -Dwebdriver.ie.driver=%IE_DRIVER_LOC% -hub %HUB_URL% -port 5556

    But on running test, it gives Exception as mentioned above.

    Please help! I have been struggling with these for quite some time now. Any help will be very much appreciated.

    Posted by Sushmita | April 5, 2013, 3:18 pm
    • Can you just try adding up the path wherein both the IEDriverServer binary and ChromeDriver binary reside as part of your path variable ? i.e.,

      set PATH=%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%CHROME_DRIVER_LOC%;%IE_DRIVER_LOC%;%PATH%

      Also please get rid of the System.setProperty() from your code. It is NOT required.

      Posted by Confusions Personified | April 5, 2013, 9:07 pm
      • Thanks for your response.

        I added the chrome driver and Internet explorer driver in the PATH ( as you said).

        My Chrome is at location: C:\Program Files (x86)\Google\Chrome\Application

        The post for Chrome Driver says it must be at location C:\Users\%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe

        (I cannot move or install my chrome other than the location where it is right now)

        Is Chrome binary different from Chrome Driver? I cannot find a link for Chrome /IE binary download.

        Posted by Sushmita | April 5, 2013, 11:06 pm
      • Chrome binary and chrome driver are different. Chromedriver is needed only for selenium automation.

        Posted by Confusions Personified | April 5, 2013, 11:21 pm
  17. Ok. i added chrome binary and Chrome Driver in PATH. But still getting the same error.

    Posted by Sushmita | April 6, 2013, 12:19 am
    • Hi, Please see my grid batch file. (I added both chrome binary and chrome driver location in my path)
      Batch file

      set HERE=C:\Users\Administrator\Downloads
      set JAVA_HOME=%HERE%\jdk-7u13-windows-x64
      set PATH=%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%CHROME_DRIVER_LOC%;%IE_DRIVER_LOC%;%CHROME_BINARY_LOC%;%PATH%;
      set SELENIUM_VERSION=2.29.0
      set CHROME_VERSION=chromedriver_win_26.0.1383.0
      set HUB_URL=http://localhost:4444/grid/register
      set CHROME_DRIVER_LOC=C:\Users\Administrator\Downloads\chromedriver_win_26.0.1383.0\chromedriver.exe
      set IE_DRIVER_LOC=C:\Users\Adminstrator\Downloads\IEDriverServer_x64_2.31.0\IEDriverServer.exe
      set CHROME_BINARY_LOC=C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe
      start java -jar selenium-server-standalone-2.29.0.jar -role hub
      start java -jar selenium-server-standalone-2.29.0.jar -role node
      -Dwebdriver.chrome.driver=%CHROME_DRIVER_LOC% -hub %HUB_URL% -port 5556

      My sample code:
      DesiredCapabilities capabilities = new DesiredCapabilities();
      capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
      URL url = new URL(“http://localhost:4444/wd/hub”);
      WebDriver driver = new RemoteWebDriver(url, capabilities);

      // And now use this to visit Google
      driver.get(“https://www.google.com”);

      Exception I am getting :

      Exception in thread “main” org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list
      Command duration or timeout: 608 milliseconds
      Build info: version: ‘2.29.0’, revision: ‘58258c3’, time: ‘2013-01-17 22:47:00’
      System info: os.name: ‘Windows Server 2008 R2’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.7.0_13’
      Driver info: org.openqa.selenium.remote.RemoteWebDriver
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
      at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
      at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:533)
      at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
      at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:111)
      at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129)
      at test.Test.main(Test.java:32)
      Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see ….

      Please help! I couldn’t understand what I am doing wrong now.

      Posted by Sushmita | April 8, 2013, 2:21 pm
  18. Hi Krishnan,
    Until now, I haven’t had any chance to run selenium grid on two machines and VM. So when i try to run my hub in my local machine and node in VM, it’s not working as it seems like it’s not registering to the hub. However, if i run hub and node in local machine, it just works fine.

    Since my selenium scripts along with selenium server jar files are in C: of my local machine, i don’t think i can navigate to that folder from VM. So do i need to copy my selenium folder to the VM as well. If yes, won’t that be a duplicate work?

    Waiting for your advice.
    Thanks,
    Sirus

    Posted by sirus | April 9, 2013, 7:08 pm
  19. Hello,

    Great post! I learned a lot the first time that I read it 🙂 But after install FF and IE I have a problem after launch google chrome;
    When I execute a test calling google chrome (*googlechrome), selenium wedriver opens the browser and start to launch the test cases but it doesn’t charge anything. I had the same problem with firefox and IE but I solved them opening the proxy’s/adding user sessions. I don’t know if it’s the same problem for Chrome or what’s happening.

    I work with Selenium grid 2, jenkins and a java interface. Paths for chrome.exe and chromedriver.exe are added in my environment (instances of *googlechrome appear in my grid2), in fact as I said Selenium webdriver opens the browser but doesn’t charge, I have searched for a solution during days in the web but nothing…

    Someone can help me? I have chromedriver and the references to it in my environment path.

    Thanks! 🙂

    Posted by fran | July 11, 2013, 5:01 pm
  20. Solved, we just need to add -Dhttp.proxyHost=isa.be.bvdep.net -Dhttp.proxyPort=8080 in the command line to launch the node

    Posted by fran | July 12, 2013, 8:13 pm
  21. hi,
    I want to register multiple nodes to hub (all on local machine).

    1. I have launched the hub as below and it works as expected.
    java -jar selenium-server-standalone-2.33.0.jar -role hub
    2. now, i have registered a node with below config to the hub it successfully registers
    java -Dwebdriver.chrome.driver=”E:\chromedriver.exe” -jar selenium-server-standalone-2.33.0.jar -role node -hub http://localhost:4444/grid/register -maxSession 10 -browser “browserName=chrome,platform=WINDOWS”,maxInstances=2 *-port 5555*
    3. now, when i try to register a node for either firefox/Ie to the hub in the similar fashion to point to 2 with a different port number, the batch file opens the cmd prompt and closes immediately.

    at a point of time im able to sync only one node either chrome, ff, ie to hub. Could you please let me where the issue could be.

    Posted by G Venkat | August 20, 2013, 5:24 pm
    • What happens when you try to register the second node manually without a batch file ? I.,e just run the java -jar command on the prompt ?

      Have you tried opening up a command prompt and tried running the batch file from it ? That should tell you what went wrong.

      I also would suggest that you post queries on selenium-users google forum. [ I tend to be more available on the forum than compared to the blog ].

      Posted by Confusions Personified | August 21, 2013, 6:51 am
      • Hi, I will post as suggested from next time. Below is the execption i get when i run manually from command prompt

        E:\Back>java -jar selenium-server-standalone-2.33.0.jar
        -role node -hub http://localhost:4444/grid/register -maxSession 10 -browser bro
        wserName=firefox,maxInstances=1 *-port 5565*
        23 Aug, 2013 6:46:45 PM org.openqa.grid.selenium.GridLauncher main
        INFO: Launching a selenium grid node
        23 Aug, 2013 6:46:45 PM org.openqa.grid.common.RegistrationRequest addCapability
        FromString
        INFO: Adding browserName=firefox,maxInstances=1
        18:46:46.382 INFO – Java: Sun Microsystems Inc. 1.6.0_01-b06
        18:46:46.383 INFO – OS: Windows Vista 6.1 x86
        18:46:46.395 INFO – v2.33.0, with Core v2.33.0. Built from revision 4e90c97
        18:46:46.550 INFO – RemoteWebDriver instances should connect to: http://127.0.0.
        1:5555/wd/hub
        18:46:46.553 INFO – Version Jetty/5.1.x
        18:46:46.557 INFO – Started HttpContext[/selenium-server/driver,/selenium-server
        /driver]
        18:46:46.561 INFO – Started HttpContext[/selenium-server,/selenium-server]
        18:46:46.563 INFO – Started HttpContext[/,/]
        18:46:46.571 INFO – Started org.openqa.jetty.jetty.servlet.ServletHandler@1c5f74
        3
        18:46:46.574 INFO – Started HttpContext[/wd,/wd]
        18:46:46.577 WARN – Failed to start: SocketListener0@0.0.0.0:5555
        Exception in thread “main” org.openqa.jetty.util.MultiException[java.net.SocketE
        xception: Unrecognized Windows Sockets error: 0: JVM_Bind]
        at org.openqa.jetty.http.HttpServer.doStart(HttpServer.java:691)
        at org.openqa.jetty.util.Container.start(Container.java:72)
        at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:4
        88)
        at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:30
        0)
        at org.openqa.grid.internal.utils.SelfRegisteringRemote.startRemoteServe
        r(SelfRegisteringRemote.java:135)
        at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:105)
        java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(Unknown Source)
        at java.net.ServerSocket.bind(Unknown Source)
        at java.net.ServerSocket.(Unknown Source)
        at org.openqa.jetty.util.ThreadedServer.newServerSocket(ThreadedServer.j
        ava:391)
        at org.openqa.jetty.util.ThreadedServer.open(ThreadedServer.java:476)
        at org.openqa.jetty.util.ThreadedServer.start(ThreadedServer.java:502)
        at org.openqa.jetty.http.SocketListener.start(SocketListener.java:202)
        at org.openqa.jetty.http.HttpServer.doStart(HttpServer.java:721)
        at org.openqa.jetty.util.Container.start(Container.java:72)
        at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:4
        88)
        at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:30
        0)
        at org.openqa.grid.internal.utils.SelfRegisteringRemote.startRemoteServe
        r(SelfRegisteringRemote.java:135)
        at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:105)

        Could you please help me out on the issue.

        Posted by G Venkat | August 23, 2013, 7:00 pm
      • Can you please try first using the VM argument : -Djava.net.preferIPv4Stack=true

        If that still doesn’t help, you may have to take a look at some of the other alternatives being discussed in this SO thread : http://stackoverflow.com/questions/3947555/java-net-socketexception-unrecognized-windows-sockets-error-0-jvm-bind-jboss

        As I said before, please post queries on the Selenium-users google forum

        Posted by Confusions Personified | August 23, 2013, 7:16 pm
  22. Hi Krishan,

    Great post…I have a question
    I am using Grid 2 with testng and I have set
    in my testng xml.when I run from eclipse with running as testng suite then my suite runs parallel.however If I want to run parallel using batch file using ant build.xml.

    I am not able to do that..Can you please throw some light on it?

    Or Am I missing some configuration?

    Thanks,
    Fanindra

    Posted by Fanindra | October 8, 2013, 5:08 pm
    • My Testng.xml

      Posted by Fanindra | October 8, 2013, 5:29 pm
    • Hi Krishnan and Fanindra

      How did you get it to work in parallel execution using testng.xml and Grid 2? I am getting java heap space error. I am only executing 3 tests in parallel with 3 threads and I am seeing the Java heap space error. This is the response:

      Error 500 java.lang.OutOfMemoryError: Java heap space

      HTTP ERROR: 500
      Problem accessing /wd/hub/session. Reason:

          java.lang.OutOfMemoryError: Java heap space

      Powered by Jetty://

      Not sure if I am doing anything wrong. It works fine if I don’t execute in parallel. Here is my testNG.xml


      Posted by satish | April 12, 2014, 12:43 am
  23. Nice Article.

    I am facing a challenge with setting up a grid for mobile web pages. I need to open the browsers in nodes with specified user agent strings. How to achieve this? When I do new RemoteWebDriver(), I dont have an option to set user agent. If you could shed some light on this, that would be helpful. Thanks in advance.

    Posted by Basavaraj M | December 19, 2013, 3:39 pm
  24. Hi,

    Do you have any idea about launching Internet Explorer in Selenium Grid

    Posted by Madhu | April 20, 2015, 5:13 pm
    • You dont need to do anything in specific for launching IE on the Grid. What exactly are you looking for ? Can you please send your question to the selenium-users google group ?

      Posted by Confusions Personified | April 20, 2015, 5:23 pm
      • Hi krishnan ,

        I am new to selenium grid . i have configured hub and node in a machine . But when running the test , i am facing the issue .”Error forwarding a new Session ” . As you mentioned in the Post above , i have tried using the configuration file in the same folder and executed the test .But the result is same .

        KIndly help me.

        Thanks
        Raghutej.

        Posted by raghu | August 26, 2016, 12:37 am
      • I would suggest that you please post this on the selenium-users google groups with all details. I don’t frequently monitor the blog post but I regularly keep an eye on the selenium users forum

        Posted by Confusions Personified | September 3, 2016, 9:55 pm
  25. Hi Krishnan,

    I don’t know if this a right place to post my question here. I have worked with you earlier and I know you are the best in test framework development and what not..
    My question is:
    I have to validate a html file using selenium. The html file is part of my project workspace. I use absolute path to retrieve the url, and it works well locally something like this:
    String inputFilePath = “src/main/java/elementspkg/fixtures/responsive.html”;
    String url = new File(inputFilePath).getAbsolutePath();
    driver.get(“file:///”+url);
    driver.get(“file:////Users/aspiringqa/Desktop/javatests-travis-ci-poc/src/main/java/elements‌​pkg/fixtures/responsive.html”);

    I set up travis CI to run my tests on a sauce labs machine.
    Now my test fails because the ‘url’ isn’t correct. It pulls up the travis CI absolute path like this:
    driver.get(“file:////home/travis/build/xxx/javatests-travis-ci-poc/src/main/java/elementspkg‌​/fixtures/responsive.html”);

    My Sauce lab VM doesn’t find this html file and it says page not found and my test cant proceed.

    Is there a way I can launch this html file through selenium on a sauce machine?

    Posted by eajaz | January 27, 2016, 11:12 pm
  26. Hey Krishnan, too early to comment 🙂 but indid a very goood article..Its working well with grid 3 too. Can you show us the options with gecko driver too?

    Posted by Shweta | May 19, 2018, 4:30 pm

Trackbacks/Pingbacks

  1. Pingback: Selenium Grid – sequeira ' Quality Assurance - March 4, 2016

Leave a comment