Skip to content

webdriver.Builder().forBrowser('chrome').build() hangs indefinitely #3997

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
raghuAtWings opened this issue May 9, 2017 · 3 comments
Closed
Labels
C-nodejs JavaScript Bindings

Comments

@raghuAtWings
Copy link

raghuAtWings commented May 9, 2017

Meta -

OS:
ubuntu (linux)
Selenium Version:
"selenium-webdriver": "^3.4.0",
Browser:
chrome

Browser Version:
Google Chrome 58.0.3029.81

Expected Behavior -

All tests should run without getting error on getting webdriver

Actual Behavior -

call to build webdriver hangs

Steps to reproduce -

I am using mocha and selenium to do end to end integration testing. I am using beforeEach and afterEach hook to initialize browser and kill it after each test. Here is my js file which has both the methods

    const webdriver = require('selenium-webdriver')
    require('selenium-webdriver/chrome')
    require('chromedriver')
    global.driver = {}
    
    // setup
    beforeEach(async function () {
      this.timeout(60000)
      try {
        driver = await new webdriver.Builder().forBrowser('chrome').build()
        await driver.manage().window().setSize(1600, 900)
      } catch (ex) {
        console.log(ex.stack)
      }
    
    })
    
    afterEach(async function () {
      this.timeout(60000)
      await driver.quit()
    })

Now when i run the test suit on jenkins i very frequently see this ("email already registered" is a test name)

✓ email domain not allowed (4167ms)
    1) "before each" hook for "email already registered"


  39 passing (9m)
  1 pending
  1 failing

  1)  "before each" hook for "email already registered":
     Error: Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

The thing to notice is that once this error comes the subsequent tests do not run. My test suit has 100s of tests and in the run above it quit once it encountered this beforeEach error and didn't run next set of tests.

@jleyba jleyba added the C-nodejs JavaScript Bindings label May 14, 2017
@jleyba
Copy link
Contributor

jleyba commented May 14, 2017

This is #3037

You need to update your test with:

const {promise} = require('selenium-webdriver');
promise.USE_PROMISE_MANAGER = false;

See this example:

https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/example/async_await_test.js

@jleyba jleyba closed this as completed May 14, 2017
@raghuAtWings
Copy link
Author

raghuAtWings commented May 15, 2017

FYI this was already there. I had this in my code and still saw this behavior

I would like to reopen this.

@neutraali
Copy link

neutraali commented Jan 28, 2019

Also stuck on a similar issue - Calling:

this.driver = new Builder()
	.forBrowser('chrome')
	.setChromeOptions(opts)
	.setChromeService(srvc)
	.build();

... Just seems to hang and nothing happens - For the first run of the tests. On the second run (e.g. running the exact same tests again) everything seems to work. This is a problem notably with CI, as the first run is all you're going to get. As far as relevant libraries go we're running with:

    "chai": "4.2.0",
    "mocha": "5.0.5",
    "selenium-webdriver": "4.0.0-alpha.1"

Here's the last few lines of our webdriver.log:

[1.047][INFO]: COMMAND Navigate { "url": "http://localhost:8080/" }
[1.047][INFO]: Waiting for pending navigations...
[1.049][INFO]: Done waiting for pending navigations. Status: ok
[1.151][INFO]: Waiting for pending navigations...
[2.746][INFO]: Done waiting for pending navigations. Status: ok
[2.746][INFO]: RESPONSE Navigate
[2.746][INFO]: COMMAND Quit {}
[2.796][INFO]: RESPONSE Quit

^ So it ultimately terminates due to a Mocha timeout. Increasing or decreasing the timeout has no effect. It seems to initialize the session (?) and send the first "navigate" -command but then hangs and ultimately quits. Couldn't say what we're doing wrong here.

UPDATE:

FWIW some browser information:

chromium-browser - Chromium 61.0
chromium-chromedriver - ChromeDriver 2.30

@lock lock bot locked and limited conversation to collaborators Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-nodejs JavaScript Bindings
Projects
None yet
Development

No branches or pull requests

3 participants