Not able to run test cases on Grid | Selenium Forum
M
Posted on 15/08/2016
Hello,

I have successfully configured Grid and Node but my test cases do not run. I get the below error message.

org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities [{browserName=Chrome, version=, platform=WINDOWS}]
Command duration or timeout: 207 milliseconds

I am using the below commands to start node and hub. Do I need to mentioned both ie driver and chrome driver in the command as below for both Hub and Node?

//Hub
java -Dwebdriver.ie.driver=C:\Selenium\IEDriverServer.exe -Dwebdriver.chrome.driver=C:\Selenium\chromedriver.exe -jar selenium-server-standalone-3.0.0-beta2.jar -port 4444 -role hub -timeout 30

//Node
java -Dwebdriver.ie.driver=C:\Selenium\IEDriverServer.exe -Dwebdriver.chrome.driver=C:\Selenium\chromedriver.exe -jar selenium-server-standalone-3.0.0-beta2.jar -role webdriver -browser browserName=firefox,maxInstances=3,platform=WINDOWS -browser browserName=chrome,maxInstances=2,platform=WINDOWS -hub http://10.0.0.94:4444/grid/register -port 5557

M
Replied on 16/08/2016

send a screen shot of test cases.


M
Replied on 16/08/2016

Please see the screenshots. I tried all possible ways but still getting the same error.


M
Replied on 17/08/2016

where are you initialing driver? where are you setting desired capabilities.


M
Replied on 17/08/2016

Hello,

I am initializing driver in my Basetest case and in hub. Please let me know where I am going wrong since the program runs fine if I do not use grid ie.., I keep boolean gridRun = false

Hub start command:

java -Dwebdriver.ie.driver=C:\Selenium\IEDriverServer.exe -Dwebdriver.chrome.driver=C:\Selenium\chromedriver.exe -jar selenium-server-standalone-3.0.0-beta2.jar -role webdriver -browser browserName=firefox,version=48,maxInstances=3,platform=WINDOWS -hub http://10.0.0.94:4444/grid/register -port 5557


M
Replied on 18/08/2016

let me see the code for initializing driver in basetest.java


M
Replied on 21/08/2016

Please see the code below.


public class BaseTest {

public WebDriver driver;
public Properties prop;
//private locatorKey
public String locatorKey;

public ExtentReports rep = ExtentManager.getInstance();
public ExtentTest test;
boolean gridRun = true;

public void init(){
if(prop==null)
{
prop=new Properties();
try {
FileInputStream fs = new FileInputStream(System.getProperty("user.dir")+"//src//test//resources//projectconfig.properties");
prop.load(fs);

} catch (Exception e) {
e.printStackTrace();
}
}
}
public void openBrowser(String bType) throws IOException
{

test.log(LogStatus.INFO,"Opening Browser "+bType);

if(!gridRun)

{

if(bType.equals("Mozilla")){

driver=new FirefoxDriver();

}

else if(bType.equals("Chrome")){
System.setProperty("webdriver.chrome.driver",prop.getProperty("chromedriver_exe"));
driver=new ChromeDriver();
}

else if(bType.equals("IE")){
System.setProperty("webdriver.ie.driver",prop.getProperty("iedriver_exe"));
//DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
//caps.setCapability("ignoreZoomSetting", true);
driver = new InternetExplorerDriver();
//driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
//driver.manage().window().maximize();
}

}

else //grid

{
DesiredCapabilities caps=null;

if(bType.equals("Mozilla")){
caps = DesiredCapabilities.firefox();
caps.setBrowserName("firefox");
caps.setJavascriptEnabled(true);
caps.setPlatform(org.openqa.selenium.Platform.WINDOWS);
}

else if(bType.equals("Chrome")){
caps = DesiredCapabilities.chrome();
caps.setBrowserName("Chrome");
caps.setPlatform(org.openqa.selenium.Platform.WINDOWS);
}
else if(bType.equals("IE")){
caps = DesiredCapabilities.internetExplorer();
caps.setBrowserName("IE");
caps.setPlatform(org.openqa.selenium.Platform.WINDOWS);
}

try {
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), caps);

}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();

test.log(LogStatus.INFO,"Browser Opened Successfully "+bType);

}}


M
Replied on 22/08/2016

delete this line

[code:pbb2h2ao]caps.setBrowserName("firefox");
[/code:pbb2h2ao]


M
Replied on 22/08/2016

I commented that line, still getting the below error..

org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities [{browserName=chrome, version=, platform=WINDOWS}]
Command duration or timeout: 16 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'GG-SPECTRE', ip: '10.0.0.94', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.remote.RemoteWebDriver


M
Replied on 23/08/2016

do that for


caps.setBrowserName("Chrome");
caps.setBrowserName("IE");

also


M
Replied on 23/08/2016

Hello,

I had already made the suggested changes but still getting the error. Please see the below code.
if(!gridRun)

{

if(bType.equals("Mozilla")){

driver=new FirefoxDriver();

}

else if(bType.equals("Chrome")){
System.setProperty("webdriver.chrome.driver",prop.getProperty("chromedriver_exe"));
driver=new ChromeDriver();
}

else if(bType.equals("IE")){
System.setProperty("webdriver.ie.driver",prop.getProperty("iedriver_exe"));
//DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
//caps.setCapability("ignoreZoomSetting", true);
driver = new InternetExplorerDriver();
//driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
//driver.manage().window().maximize();
}

}

else //grid

{
DesiredCapabilities caps=null;

if(bType.equals("Mozilla")){
caps = DesiredCapabilities.firefox();
//caps.setBrowserName("firefox");
caps.setJavascriptEnabled(true);
caps.setPlatform(org.openqa.selenium.Platform.WINDOWS);
}

else if(bType.equals("Chrome")){
caps = DesiredCapabilities.chrome();
//caps.setBrowserName("Chrome");
caps.setPlatform(org.openqa.selenium.Platform.WINDOWS);
}
else if(bType.equals("IE")){
caps = DesiredCapabilities.internetExplorer();
//caps.setBrowserName("IE");
caps.setPlatform(org.openqa.selenium.Platform.WINDOWS);
}

try {
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), caps);

}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();

test.log(LogStatus.INFO,"Browser Opened Successfully "+bType);

}}


M
Replied on 24/08/2016

are you sure its a same error or is it different error?


M
Replied on 24/08/2016

yes, its the same error. please see below.

Error forwarding the new session cannot find : Capabilities [{browserName=chrome, version=, platform=WINDOWS}]
Command duration or timeout: 14 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'GG-SPECTRE', ip: '10.0.0.94', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.remote.RemoteWebDriver


M
Replied on 25/08/2016

hmm. . . . at what time can you come on skype?


M
Replied on 27/08/2016

I am available on below timmings. Please let me know a suitable time.

saturday and sunday - 6AM IST to 10:30 AM and 6:30 PM to 10 PM IST

Monday to Friday - 6AM IST to 10:30 AM


M
Replied on 29/08/2016

ping me on skype when you're available.

ask for vaibhav. ok?