Closed a-ctor closed 3 months ago
@a-ctor, thank you for creating this issue. We will troubleshoot it as soon as we can.
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!
Hi @titusfortner ,
I'm uncertain if this issue is specific to .NET. I attempted the example provided with selenium-webdriver (versions 4.10.x - 4.19.x), and I couldn't replicate the problem described. getText retrieved all the texts as below
It is not .NET specific, I executed the code above on my local (selenium 4.18.1):
So is this an issue or not?
I am closing this because we have yet to get more information.
This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.
What happened?
Hi,
we use the
.visually-hidden
definition from https://a11y-guidelines.orange.com/en/articles/accessible-hiding/ to provide accessibility texts that are only visible for screen reader users. We test our applications with Selenium and encountered an inconsistency that seems like a bug in Selenium. When retrieving the text content of an element, some of the visually hidden children are included while others are not.Consider the provided HTML sample. It contains the previously mentioned
.visually-hidden
CSS class and four elements of note:span
with text contentNormal Text
,span
with text contentNormal Text
2 that is containd in a<p>
elementScreen reader text
,Screen reader text 2
that is contained in a<p>
elementWhen retrieving the text content of the
target
element, the parent container of all four elements, I would expect the output to contain the text content of just element 1. and 2 (only the visible elements) or of elements 1., 2., 3., and 4. (all elements regardless of visibility).Instead the text from 1., 2., and 3. are returned while 4. is excluded. For some reason, the
<p>
element prevents the 4. element to be included in the text content. This effect can also be reproduced by replacing the<p>
with other elements like<pre>
or<li>
. My initial assumption was thatdisplay: block
elements prevent this issue but other elements like<div>
don't prevent this problem.Here is a basic setup to reproduce this issue in C#, I don't know if the problem can be reproduced with other language bindings as well. Adjust the URL to point to a local file containing the HTML.
Running this code, regardless of browser (Chrome/Edge/Firefox), will print:
As mentioned before, I don't know if that is considered a bug but its seemingly arbitrary behavior seems like a bug to me. If you need anything more from me I am happy to help.
Cheers Patrick
How can we reproduce the issue?
Relevant log output
Operating System
Windows 10
Selenium version
C# 4.18.1
What are the browser(s) and version(s) where you see this issue?
Chrome 122, Firefox 123, Edge 122
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 122.0.6261.94, Microsoft Edge WebDriver 122.0.2365.52
Are you using Selenium Grid?
No response