green_limeade
green_limeade

Reputation: 51

Geckodriver/Firefox issue when running Robot Framework Selenium tests inside Docker container

As part of my project's build pipeline, we are required to run a series of ssh/web acceptance tests using Robot Framework and Docker. Currently, we are creating a docker container and running both ssh and selenium web tests inside the docker container.

Python - 2.7 RobotFramework - 3.1.1 SeleniumLibrary (for Robot) - 3.3.1 Selenium - 3.1 geckodriver - 0.21.0 Firefox - 60.7.0

When I am attempting to hit an IP address, I keep running into this error:

WebDriverException: Message: Reached error page: about:neterror?e=connectionFailure&u=http%3A//172.20.0.158/&c=UTF-8&f=regular&d=Firefox%20can%E2%80%99t%20establish%20a%20connection%20to%20the%20server%20at%20172.20.0.158.

Initially I was suspicious that this could be related to an issue with using the incompatible versions of the libraries for Selenium, GeckoDriver, and Firefox. However, after some testing, I am able to hit some addresses, like http://www.google.com, but not an IP address.

Here are the two tests below: The Google Test is passing, but the Jenkins Test is failing, with the error message above.

Google Test
    Open Browser    http://www.google.com   ff
    Page Should Contain     Google
    Close Browser

Jenkins Test
    Open Browser    http://100.00.00.00   ff
    Page Should Contain     Jenkins
    Close Browser

(I didn't put in the actual IP address)

The IP address for the Jenkins test, when I access it in the browser hits the Jenkins server so I know the IP is correct. I am just unsure why there is errors with firefox being unable to establish a connection.

Please let me know if you need more information - I can provide it. Thank you!

Upvotes: 0

Views: 809

Answers (1)

Todor Minakov
Todor Minakov

Reputation: 20067

In the error message the address you're trying to open is 172.20.0.158. If that is the actual one you're hitting, then it's in one of the private ranges - the 172.16.0.0/12 more specifically (e.g. a range like the more popular in home networks 192.168.0.0/24 - non-routeable from other networks).
If your docker node can't access it, then its routing table is most probably misconfigured. You said you were able to open the target url, but you must probably tried from another machine (your work one, the docker host?), which has its routes set as they are supposed to.

As there is sshd running on the docker, connect to it and try opening the url with:

curl http://172.20.0.158/

If it succeeds, then it's a Firefox issue; if it fails with a similar error, then it's a network configuration.
And while in a ssh session, you can print the routing table with this command:

ip route

(or, netstat -rn for the "old school" :) output format).

Upvotes: 0

Related Questions