1

I installed selenium node on AWS windows and started it. And I setup Jenkins, git, Seleniuim hub on AWS Linux. When i'm building app on Jenkins, selenium hub is trying to connect to selenium node of AWS windows with private IP address. And i'm getting following exception:

org.openqa.selenium.WebDriverException: 
Error forwarding the new session Error forwarding the request Connect to windows_private_ip:5555 [/windows_private_ip] failed: Connection timed out (Connection timed out)
Command duration or timeout: 190.25 seconds
Build info: version: '3.5.1', revision: '9c21bb67ef', time: '2017-08-17T15:26:08.955Z'
System info: host: 'some_host_name', ip: 'some_ip', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.76-3.78.amzn1.x86_64', java.version: '1.8.0_151'
Driver info: driver.version: RemoteWebDriver
Caused by: org.openqa.grid.common.exception.GridException: Error forwarding the new session Error forwarding the request Connect to windows_private_ip:5555 [/windows_private_ip] failed: Connection timed out (Connection timed out)

Grid Node command:

C:\Users\Administrator>java -Dwebdriver.chrome.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register

My code is:

if (browser.equalsIgnoreCase("FF")) {
            System.setProperty("webdriver.gecko.driver", "drivers/windows-driver/geckodriver.exe");
            DesiredCapabilities cap = DesiredCapabilities.firefox();
            // Set the platform where we want to run our test- we can use
            // MAC and Linux and other platforms as well
            cap.setPlatform(Platform.ANY);
            cap.setCapability("gecko", true);
            // Here you can use hub address, hub will take the
            // responsibility to execute the test on respective node
            URL url = new URL("http://hub_public_ip:4444/wd/hub");
            // Create driver with hub address and capability
            gbb = PageFactory.initElements(new RemoteWebDriver(url, cap), GuruBase.class);
        } else if (browser.equalsIgnoreCase("IE")) {
            System.setProperty("webdriver.ie.driver", "drivers/windows-driver/IEDriverServer.exe");
            gbb = PageFactory.initElements(new InternetExplorerDriver(), GuruBase.class);

        } else if (browser.equalsIgnoreCase("GC")) {
            System.setProperty("webdriver.chrome.driver", "drivers/windows-driver/chromedriver.exe");
            ChromeOptions cho = new ChromeOptions();
            cho.addArguments("disabled-extensions");
            cho.addArguments("--start-maximized");
            gbb = PageFactory.initElements(new ChromeDriver(cho), GuruBase.class);
        }

        else if (browser.equalsIgnoreCase("html")) {
            gbb = PageFactory.initElements(new HtmlUnitDriver(true), GuruBase.class);
        }

I'm running selenium hub on Jenkins.

Anil Jagtap
  • 1,740
  • 4
  • 27
  • 44

3 Answers3

1

A quick solution will be to change :

java -Dwebdriver.gecko.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register

As you are using Dwebdriver.gecko.driver with chromedriver.exe

To either :

  • Use GeckoDriver :

    java -Dwebdriver.gecko.driver=./drivers/windows-driver/geckodriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
    
  • Use Chromedriver :

    java -Dwebdriver.chrome.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
    

Additionally, you need to check your if() loop as you have a mixed up representation of Windows and Linux styles in System.setProperty() line as follows :

  • GeckoDriver :

    System.setProperty("webdriver.gecko.driver", "drivers/windows-driver/geckodriver.exe");
    
  • ChromeDriver :

    System.setProperty("webdriver.chrome.driver", "drivers/windows-driver/chromedriver");
    
  • IEDriverServer :

    System.setProperty("webdriver.ie.driver", "drivers/windows-driver/IEDriverServer.exe");
    

Note : On Windows Systems you need to mention the extension .exe part e.g. geckodriver.exe while on Linux Systems you need strip off the extension .exe part e.g. chromedriver

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • @DebenjanB, I changed gecko with chrome. But still getting same exception. – Anil Jagtap Feb 27 '18 at 08:14
  • @DebenjanB, I did all changes you suggested but getting same issue. – Anil Jagtap Feb 27 '18 at 09:40
  • See you are still messing up the _Linux System_ based commands. Grid Node Command still includes `chromedriver.exe` as well as your code block includes `geckodriver.exe`and `IEDriverServer.exe`. Read my answe carefully. – undetected Selenium Feb 27 '18 at 09:41
  • @DebenjanB, I'm firing Grid node command on AWS windows. I want to execute script on chrome browser on windows system. And I started Grid hub on Jenkins on AWS linux. And i'm getting **INFO: Marking the node http:// aws_windows_private-IP:5555 as down: cannot reach the node for 2 tries Feb 27, 2018 9:51:28 AM org.openqa.grid.selenium.proxy.DefaultRemoteProxy onEvent** – Anil Jagtap Feb 27 '18 at 09:54
  • I think you are confusing on how Grid Hub & Node connects. **selenium hub is trying to connect to selenium node of AWS windows** is incorrect. Rather _Grid Hub_ **forwards the request**. Update the question with all your _Framework Configuration_, _Code Block_ , _Grid Hub Command_, _Grid Node Command_ and complete _Error Stack Trace_ for further analysis. – undetected Selenium Feb 27 '18 at 10:02
  • @DebenjanB, I'm getting above error with FireFox browser with firefox grid node command. When i'm firing grid command for chrome getting **java.lang.IllegalStateException: The driver is not executable: /var/lib/jenkins/workspace/My_Login_Windows_FireFox/drivers/windows-driver/chromedriver.exe** – Anil Jagtap Feb 27 '18 at 10:05
  • Of-coarse you are seeing the correct **java.lang.IllegalStateException** as you are trying with **FireFox browser with firefox grid node command** through **`chromedriver.exe`** – undetected Selenium Feb 27 '18 at 10:10
1

This probably caused by your ip not matched. I met the same error and I found that there are two IPv4 address for my machine. One is Eather net and another is WLAN. Steps:

  • Disconnect the Wi-Fi.
  • Use command : ipconfig to check my IPv4 address (there's only one IP there).
  • With one IP only it should create session correctly.
Kai
  • 3,104
  • 2
  • 19
  • 30
Jing Li
  • 21
  • 1
0

Perhaps you are using your office computer to make transaction between your node and your hub.

to some extent, you can push your code from office computer <=> github <=> AWS EC2 console. but registering it as a node / hub and trying to execute the test case may not be possible.

please try with a server in same environment.

Kalyan .P
  • 3
  • 4