SeleniumHQ / selenium

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

[🐛 Bug]: getAttribute and GetDomAttribute returns null #14141

Closed jpeasysoft closed 2 weeks ago

jpeasysoft commented 2 weeks ago

What happened?

I'm trying to retrieve the aria-owns attribute from the following element

<input autocomplete="off" placeholder="Bitte auswählen" class="dx-texteditor-input" aria-haspopup="listbox" aria-autocomplete="list" type="text" readonly="" spellcheck="false" tabindex="0" role="combobox" aria-expanded="false" aria-controls="dx-d7e01400-e540-860e-cba9-eda8f83eb789" aria-owns="dx-866ecb84-71b9-f0e9-4037-7412cc24303d">

but when i use element.GetAttribute("aria-owns"); or element.GetDomAttribute("aria-owns");

the result is always null. aria-expanded for example is working fine.

How can we reproduce the issue?

Create an HTML page with the mentioned element

Relevant log output

N/A

Operating System

Windows 11

Selenium version

4.19.0

What are the browser(s) and version(s) where you see this issue?

Chrome

What are the browser driver(s) and version(s) where you see this issue?

Chromedriver 126.0.6478.61

Are you using Selenium Grid?

No

github-actions[bot] commented 2 weeks ago

@jpeasysoft, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

AutomatedTester commented 2 weeks ago

Can you help us debug this a little further. Can you, on the page, open devtools and execute the following JS?

document.querySelector('input'/*use a better selector if you know it*/).getAttribute('aria-owns')
jpeasysoft commented 2 weeks ago

Hi, sorry my fault. Everything works great. I just noticed that the aria-owns element will be inserted after the element was clicked. I used the GetDomAttribute before the click.

jpeasysoft commented 2 weeks ago

Closed