Module 34: Unable to execute test case with RemoteWebDriver | Selenium Forum
M
Posted on 04/07/2016
Hi Ashish,

Please help me resolve the issue:

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;

public class Google_Search {

@Test
public void searchTest() throws MalformedURLException {

//RemoteWebDriver
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setBrowserName("firefox"); //chrome,iexplore
cap.setPlatform(Platform.ANY); //Can we windows, Linux, Since firefox will open on any OS, so Platform.ANY is given

//URL of the HUB
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),cap);
driver.get("http://gmail.com");
driver.manage().window().maximize();
driver.findElement(By.xpath("//*[@id='Email']")).sendKeys("Shettar.pavan");
driver.findElement(By.xpath("//*[@id='next']")).click();

}
}
While executing the program i am getting the below error
org.openqa.selenium.WebDriverException: Error forwarding the new session Error forwarding the request Connect to 192.168.1.125:5556 [/192.168.1.125] failed: Connection timed out: connect
Command duration or timeout: 25.30 seconds

Please find the screen shot attached for HUB, NODE & Error message displayed on Eclipse console

M
Replied on 04/07/2016

what is the node config you're using?

here is an example

java -jar selenium-server-standalone-2.32.0.jar -role node -hub http://xxx.xxx.xxx.xxx:4444/grid/register -browser browserName=firefox

Replace the xxx with the actual ip address


M
Replied on 05/07/2016

Actually my HUB & NODE are in localhost. I have executed the below commands

HUB command
java -jar selenium-server-standalone-2.53.1.jar -role hub

Node Command
java -Dwebdriver.chrome.driver=C:\Users\shettarp\Music\chromedriver_win32\chromedriver.exe -Dwebdriver.ie.driver=C:\Users\shettarp\Music\IEDriverServer_x64_2.52.2\IEDriverServer.exe -jar selenium-server-standalone-2.53.1.jar -role webdriver -hub http://localhost:4444/grid/register -port 5557 -browser browserName=firefox,maxInstances=1 -browser browserName=chrome,maxInstances=1 -browser browserName=iexplorer,maxInstances=1 -maxSession 2

Wanted to know if we are working on local host, can i mention as localhost in NODE command or do i need to mention IP address.

The problem got resolved when i run the test case from office network in home network i am facing the issue.


M
Replied on 06/07/2016

mention ip address. sometimes localhost doesn't work.