I have written the code to run tests in parallel.I have started selenium hub on my ubuntu machine and registered 2 nodes to it one node from virtual machine and another node from different system.My code is working on node running on virtual machine but doesn't run on remote machine.
Here is my code
package com.example.selenium;
import org.testng.annotations.Test;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
public class ParllelTest {
static RemoteWebDriver driver;
@BeforeTest (alwaysRun=true)
@Parameters({"platform","browserName","remoteurl"})
public void beforeTest(String platform,String browserName,String remoteurl) throws MalformedURLException {
DesiredCapabilities cap = null;
if(browserName.equals("firefox")) {
cap=new DesiredCapabilities().firefox();
cap.setPlatform(Platform.VISTA);
cap.setBrowserName("firefox");
}
else if(browserName.equals("firefox"))
{
cap=new DesiredCapabilities().firefox();
cap.setBrowserName("firefox");
cap.setPlatform(Platform.WIN8);
}
driver=new RemoteWebDriver(new URL(remoteurl),cap);
}
@Test
public void googlesearch()
{
driver.get("http://www.gmail.com");
driver.findElement(By.name("username")).sendKeys("xxx");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.name("password")).sendKeys("xxxx");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.id("click")).click();
}
}
And corresponding xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="TestSuite" thread-count="4" parallel="tests" >
<test verbose="3" name="Vista">
<paramaters>
<parameter name="platform" value="VISTA"/>
<parameter name="browserName" value="firefox"/>
<parameter name="remoteurl" value="http://10.X.X.X:5557/wd/hub"/>
</paramaters>
<classes>
<class name="com.example.selenium.ParllelTest">
<method>
<include name="googlesearch"/>
</method>
</class>
</classes>
</test>
<test verbose="3" name="windows">
<paramaters>
<parameter name="platform" value="WIN8"/>
<parameter name="browserName" value="firefox"/>
<parameter name="remoteurl" value="http://10.X.X.X:5553/wd/hub"/>
</paramaters>
<classes>
<class name="com.example.selenium.ParllelTest">
<method>
<include name="googlesearch"/>
</method>
</class>
</classes>
</test>
Here is the specification of remote machine where iam trying to run the test firefox version:44 selenium jar:2.53.0 platform:Windows 8
Iam getting following error while trying to run the test
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Though i can use chrome browser on my remote machine problem is i want execute tests on more than 10 devices in parallel so setting chrome driver path in every machine would be hectic task. Iam stuck here can someone help me ?