getAttribute("value") doesn't work with driver 91.0.4472.19 and Chrome 91.0.4472.77

Viewed 2412

After Chrome and driver update to 91th version I found the VBA macro with driver 91.0.4472.19 (win32) become return empty string ("") from input tag 'value' attribute:

Dim ch As SeleniumWrapper.WebDriver
Dim el As WebElement
' some code here ...
ch.findElementById("htmlLoginId").SendKeys login
Set el = ch.findElementById("htmlLoginId")
txt = el.getAttribute("value")

With older driver version 90.0.4430.24 this works fine. Hope it will be fixed in next driver versions.

Is there another way to get value from input[type=text] tag? I want to avoid situation if this bug will not be fixed in 92th version and 90th driver version become incompatible.

5 Answers

We have been fighting with this issue a couple of days since the new chrome driver came out. A workaround we did was to bypass calls to the webdriver's getAttribute method if we want to retrieve properties (that are not html attributes) of the element and instead use the following custom script:

browser.executeScript(`return arguments[0].${this.textAttribute}`, el);

The above example is valid for protractor, which is what we are using. If your stack is different, you need to call the appropriate alternative to browser.executeScript, but the script itself would be quite the same.

We did it!

ARG CHROME_VERSION="90.0.4430.212-1"
RUN wget --no-verbose -O /tmp/chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb \
  && apt install -y /tmp/chrome.deb \
  && rm /tmp/chrome.deb
./webdriver-manager update --versions.chrome 90.0.4430.24

I am reproducing this doing getAttribute('innerHTML') as well. As another workaround, run tests with Firefox instead of Chrome

We are also facing the similar issue while getting attribute data of an element using GetAttribute() of web element in C#. Struggled two days to find out what the root cause is. And for us it is not possible to make workarounds as code base is already frozen. Waiting for the fix. And as per the issue https://bugs.chromium.org/p/chromium/issues/detail?id=1205107 it may take couple of weeks to release another version with fix.

The issue has been fixed with the new release of ChromeDriver 91.0.4472.101 and ChromeDriver 92.0.4515.43

Related