SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.83k stars 8.21k forks source link

javascript error: Cannot read property 'getAttribute' of null with ChromeDriver 76 #7485

Closed vbaranov closed 5 years ago

vbaranov commented 5 years ago

🐛 Bug Report

I updated ChromeDriver from 74 -> 76 and got this error when started e2e tests of Chrome extension:

     JavascriptError: javascript error: Cannot read property 'getAttribute' of null
  (Session info: chrome=76.0.3809.100)
      at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:550:15)
      at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:560:13)
      at Executor.execute (node_modules/selenium-webdriver/lib/http.js:486:26)
      at process._tickCallback (internal/process/next_tick.js:68:7)

The error appears immediately on Chrome web driver build here https://github.com/poanetwork/nifty-wallet/blob/fix-gasprice-estimation/test/e2e/func.js#L56-L69, that is called by https://github.com/poanetwork/nifty-wallet/blob/fix-gasprice-estimation/test/e2e/nw.spec.js#L38-L43

There was no error with ChromeDriver 74.x

To Reproduce

The same scenario as in test script section below ⬇️

Clone repository -> install dependencies -> start e2e tests

Expected behavior

There shouldn't be error

Test script or set of commands reproducing this issue

git clone https://github.com/poanetwork/nifty-wallet -b fix-gasprice-estimation
npm i
npm run test:e2e:chrome

Environment

OS: OSX 10.14.6 Browser: Chrome Browser version: 76.0.3809.100 Browser Driver version: ChromeDriver 76.0.0 Language Bindings version: Node js v10.16.0, "selenium-webdriver": "^4.0.0-alpha.4"

mslowiak commented 5 years ago

I have got same issue when I have upgrade from 73 -> 77.

Same code works well with 73, and not working with 77

After some debug I have found that webdriver.pageSource() returns null, so any method related to html (in this case getAttribute) won't work.

twalpole commented 5 years ago

Are you running the latest releases of chromedriver - 76.0.3809.126 for Chrome 76.x.x.x - 77.0.3865.40 for Chrome 77.x.x.x . Both have fixes for serializing/deserializing JS objects which could potentially cause what you're seeing.

vbaranov commented 5 years ago

I managed to fix it by the downgrading of chromedriver npm package down to chromedriver@2.41.0.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.