ma77c
ma77c

Reputation: 1086

Value attribute not present on input element | AngularJS, Chrome 91, Protractor

After updating chrome driver to ChromeDriver 91.0.4472.19

The value attribute have dissapeared from the input elements. Protractor cannot access the value attribute.

    let x = await xDiv.getEl("#xInput").getAttribute('value');

    // x = null

Using the Chrome Dev Tools, I am also not able to see the value attribute of any input element in the markup.

Using AngularJS 1.5.8 and Protractor/Selenium 3.141.59

Upvotes: 2

Views: 116

Answers (1)

Sergey Pleshakov
Sergey Pleshakov

Reputation: 8978

The problem you described is actually a bug in chromedriver https://bugs.chromium.org/p/chromium/issues/detail?id=1205107. It happened because of the change in chrome browser related to W3C compliance

As you can see, the plan is to fix the bug, however it is still in progress.

Meanwhile, I recommend you 2 workarounds:

  1. you can use chromedriver version 90. The latest version available is here https://chromedriver.storage.googleapis.com/LATEST_RELEASE_90.0.4430

I know that under normal circumstances this would throw incompatibility error, but somehow chromedriver 90 works with chrome 91.

You can downgrade chromedriver by running this command

webdriver-manager update --gecko=false --versions.chrome 90.0.4430.24

Note sometimes you have global, project local and Protractor specific installations of webdriver-manager. The command I gave will install chromedriver globally. In order to install locally you need to find the path to your webdriver-manager and run command like this

node ./node_modules/protractor/node_modules/webdriver-manager update --gecko=false --versions.chrome 90.0.4430.24

And some of you may need to run command in sudo mode. Keep it in mind

  1. Instead of elem.getAttribute('value') try to go with browser.executeScript('return arguments[0].value', elem); multiple users claimed it works for them

Additionally, read this answer https://stackoverflow.com/a/67888592/9150146 that proposes more hacky solutions

Upvotes: 3

Related Questions