1

I am working on Python BDD with selenium, and I am using

self.driver = webdriver.Chrome(
    service=ChromeService(
        ChromeDriverManager().install()
    ),
    options=chrome_options
)

to launch the chrome browser. This is working fine when it is running in local but when I try to run it through Jenkins I get the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
OSError: [Errno 101] Network is unreachable

I tried to change the proxy setting in Jenkins but still facing the problem.

Oluwafemi Sule
  • 36,144
  • 1
  • 56
  • 81
Pritish
  • 11
  • 2
  • Do you get the same problem when you run the python script from within the Jenkins machine/container (not using Jenkins)? If so, there might be something blocking the connection from the Jenkins host itself that is unrelated to Jenkins. – M B Jan 09 '23 at 03:28
  • If I run it from terminal, then I have to do proxy setting then below step get succussed and get another error of network unreachable. ""self.driver = webdriver.Chrome( service=ChromeService( ChromeDriverManager().install() ), options=chrome_options )"" another error: raise exception_class(value) selenium.common.exceptions.WebDriverException: Message: Network Error (dns_unresolved_hostname) Your requested host "localhost" could not be resolved by DNS. – Pritish Jan 09 '23 at 06:06
  • `Your requested host "localhost" could not be resolved by DNS.` is there anything running on localhost? – M B Jan 10 '23 at 10:18
  • No, Only Jenkins is running. – Pritish Jan 10 '23 at 15:09
  • I upgraded selenium, from 4.5 to 4.7.2 so now network error is gone but getting a different error of "selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed." "selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)" – Pritish Jan 10 '23 at 15:13
  • Check this answer: https://stackoverflow.com/a/50642913/3730626 – M B Jan 11 '23 at 03:15

0 Answers0