Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃悰 Bug]: WebDriverError: unknown error: net::ERR_NAME_NOT_RESOLVED when running docker image for selenium/standalone chrome #2110

Open
zshigri23 opened this issue Jan 24, 2024 · 8 comments

Comments

@zshigri23
Copy link

What happened?

When trying to run selenium test case on jenkins using selenium stand alone chrome image, i get this error
WebDriverError: unknown error: net::ERR_NAME_NOT_RESOLVED
(Session info: chrome=120.0.6099.224)
at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:524:15)
at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:601:13)
at Executor.execute (node_modules/selenium-webdriver/lib/http.js:529:28)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async thenableWebDriverProxy.execute (node_modules/selenium-webdriver/lib/webdriver.js:745:17)

I'm using node js and a windows machine with a linux agent in jenkins.
I have specified the URL in code as well.

Command used to start Selenium Grid with Docker (or Kubernetes)

command used: 
sh 'docker run -d -p 4444:4444 --shm-size="2g" -e PROXY_SETTINGS="${PROXY_SETTINGS}" selenium/standalone-chrome:4.17.0-20240123'

environment set up in pipeline script:
 environment {
        npm_config_cache='npm-cache'
        PROXY_SETTINGS = '''
            https_proxy=http://sub.proxy.company.com:1234
            HTTPS_PROXY=http://sub.proxy.company.com:1234
            '''
    }

Javascript code:
const loggingPrefs = new Preferences();
    loggingPrefs.setLevel(logging.Type.BROWSER, logging.Level.ALL);
    const options = new chrome.Options();
    options.setLoggingPrefs({ performance: 'ALL' });
    options.addArguments("--incognito");
    const caps = Capabilities.chrome();
    caps.setLoggingPrefs(loggingPrefs);
driver = new Builder().withCapabilities(Capabilities.chrome())
      .setChromeOptions(options.addArguments('--headless=new'))
      .usingServer('http://localhost:4444/wd/hub')
      .build();
    // setting values for prod and preprod urls
    const prodUrl = process.env.npm_package_config_prod;
    const preprodUrl = process.env.npm_package_config_preprod;
    //Now we check if uatURL is defined and uat is being passed in command line like --uat
    if (preprodUrl && process.argv.includes('--preprod')) {
      console.log("opening e-tst3 URL");
      await driver.get(preprodUrl);
    } else if (prodUrl && process.argv.includes('--prod')) {
      console.log("Trying the PROD version");
      await driver.get('https://www.google.com/');
    } else {
      console.log("None of the environments worked! :(");
    };

It throws the error at the 'driver.get'
I have tried to change the URL to without "www" still no luck.

Relevant log output

WebDriverError: unknown error: net::ERR_NAME_NOT_RESOLVED
  (Session info: chrome=120.0.6099.224)
      at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:524:15)
      at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:601:13)
      at Executor.execute (node_modules/selenium-webdriver/lib/http.js:529:28)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async thenableWebDriverProxy.execute (node_modules/selenium-webdriver/lib/webdriver.js:745:17)

Operating System

windows 11 but linux agent on jenkins

Docker Selenium version (image tag)

4.17

Selenium Grid chart version (chart version)

No response

Copy link

@zshigri23, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol
Copy link
Member

diemol commented Jan 24, 2024

I do not think PROXY_SETTINGS is used by Docker. Has this worked before or are you trying to figure out how to set a proxy?

@zshigri23
Copy link
Author

zshigri23 commented Jan 24, 2024

No its never worked, i was just trying out different ways to make it work.
I saw one of your answers to a related post to set up proxy but not sure how.
I've tried pass in as a command as listed on the docker documentation, but to no avail. For example
docker run --env HTTP_PROXY="http://proxy.example.com:3128" redis

Also to clarify, my command to run the docker is being used in the pipeline script.

@zshigri23
Copy link
Author

I just tested it to change the URL to google.com(with no proxy) and it opened that but not able to open company website.
any idea how i can set the proxy?
below is without proxy
stage('Run Selenium Container') { steps { script { // Run Selenium container sh 'docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome:4.17.0-20240123' } } }

@VietND96
Copy link
Member

Can you try to configure the proxy at level Docker network? https://docs.docker.com/network/proxy/

@zshigri23
Copy link
Author

are you talking about the ~/.docker/config.json set up?

@VietND96
Copy link
Member

are you talking about the ~/.docker/config.json set up?

Yes
Also, your error is similar to this one #1920

@VietND96
Copy link
Member

I'm using node js and a windows machine with a linux agent in jenkins

Also, are your test script and selenium container running on the same machine?
I guess it might not in the same machine, test script is checked out and executed in linux agent, and container run on windows machine.

.usingServer('http://localhost:4444/wd/hub')

localhost in node js script might try to reach the service on the localhost within that machine

docker run -d -p 4444:4444 --shm-size="2g" -e PROXY_SETTINGS="${PROXY_SETTINGS}" selenium/standalone-chrome:4.17.0-20240123

Try to add --network=host to docker command run to see any help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants