get_attribute('textContent') and get_attribute('innerText') do not work

632 views
Skip to first unread message

Wenfeng Wang

unread,
May 26, 2021, 12:10:08 PM5/26/21
to ChromeDriver Users
Hi, we just upgrade chrome and chromedriver to 91,  we found function get_attribute('textContent') and get_attribute('innerText') do not work, they all reture None, but ele.text works fine.

Wenfeng Wang

unread,
May 26, 2021, 12:12:13 PM5/26/21
to ChromeDriver Users
Maybe it is  "Resolved issue 3746: attribute endpoint incorrectly updates values" that causes this issue.

John Chen

unread,
May 26, 2021, 12:52:31 PM5/26/21
to Wenfeng Wang, ChromeDriver Users
textContent and innerText are properties, not attributes. Please use get_property instead.

--
You received this message because you are subscribed to the Google Groups "ChromeDriver Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromedriver-us...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chromedriver-users/4cee8f2f-7e32-4f27-b4d0-47b03f9814edn%40googlegroups.com.

Wenfeng Wang

unread,
May 26, 2021, 1:35:15 PM5/26/21
to ChromeDriver Users

Thanks John, I will change them to  get_property and test it, and let you know the result ASAP

Wenfeng Wang

unread,
May 26, 2021, 4:26:22 PM5/26/21
to ChromeDriver Users
After change to  get_property(),   get_property( 'textContent' )  and  get_property( 'innerText' ) work, Thanks John

Steve Desmond

unread,
Jun 10, 2021, 10:19:47 AM6/10/21
to ChromeDriver Users
It looks like the same is true about `innerHTML` too? We just upgraded to v91 and some of our tests are failing...

James Pendleton

unread,
Jun 28, 2021, 8:15:20 AM6/28/21
to ChromeDriver Users
I wish they would please fix this, we have hundreds of tests that rely on this

Mathias Bynens

unread,
Jun 28, 2021, 8:16:51 AM6/28/21
to Steve Desmond, ChromeDriver Users
innerHTML is also a property, not an attribute. Use get_property.

James Pendleton

unread,
Jun 28, 2021, 8:37:49 AM6/28/21
to ChromeDriver Users
I use webdriver.js and there isn't a get_property function I do not think is there?   Besides, this has worked for years and years and years :)

John Chen

unread,
Jul 2, 2021, 2:33:45 AM7/2/21
to James Pendleton, ChromeDriver Users
Latest version of webdriver.js from Selenium does have getProperty method, which should be able to retrieve textContent and innerText properties. If you're using an older version of webdriver.js, you can either upgrade to a newer version, or you can run simple JavaScript snippet in Chrome to retrieve properties, e.g., driver.executeScript('return arguments[0].textContent', element).

I'm sorry for all the inconvenience this change has caused, but the previous behavior of ChromeDriver's getAttribute didn't comply with W3C standard, and was causing problems for users who expect standard-compliant WebDriver implementation.

Reply all
Reply to author
Forward
0 new messages