Sunday, June 22, 2014

Running Script on Selenium Grid

On previous post we learn how to configure Selenium grid and Node.Now we will try to learn how we can access Selenium Grid from our code.

Actually we do not need to change lots of things we just need to change the driver initialize part it should be looks like that
        
       DesiredCapabilities cap =new DesiredCapabilities();
       cap.setBrowserName("firefox");
       WebDriver driver = new RemoteWebDriver(new URL("http://Machine IP or localhost:PortNumber in which port hub is running/wd/hub"), cap); 
this is the main thing for the Selenium Grid script code rest of the part is same as the normal script.

If firefox is installed in other than default location then we need to specify the location of the firefox binary when we configure the node,node setup command should be looks like that

java -jar "path of selenium-server-standalone-2.41.0.jar" -role node -hub "http://Machine IP or localhost:PortNumber in which port hub is running/grid/register" -browser "firefox_binary=firefox binary path, browserName=firefox"

 If we need to run the script on IE then it is little bit tricky,we need to register the IE diver to the node, the command looks like that


java -jar "path of selenium-server-standalone-2.41.0.jar" -role node -hub "http://Machine IP or localhost:PortNumber in which port hub is running/grid/register" -Dwebdriver.ie.driver="path of 32 bit 64 bit IEDriverServer.exe"

 and need to set this into the code

cap.setBrowserName("internet explorer");




4 comments: