Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: Selenium's "getText" atom returns wrong capitalized text when underscores are used since PR 8736 #13779

Closed
whimboo opened this issue Apr 5, 2024 · 5 comments · Fixed by #13792

Comments

@whimboo
Copy link
Contributor

whimboo commented Apr 5, 2024

What happened?

For any HTML element that uses a text-transform of capitalize thegetText atom fails to return the correct text if underscores are used. Instead of Test_text it returns Test_Text.

How can we reproduce the issue?

You can take the following example:

<div style="text-transform: capitalize;">test_text

Here the atom returns Test_Text instead of Test_text.

Applying the following change makes it work:

-    var re = goog.userAgent.IE ? /(^|\s|\b)(\S)/g : /(^|[^\d\p{L}\p{S}])([\p{Ll}|\p{S}])/gu;
+    var re = goog.userAgent.IE ? /(^|\s|\b)(\S)/g : /(^|\s|\b)(\S)/gu;

That means that the change from PR #8736 triggered this regression.

@k7z45 could you please take a look?

Relevant log output

Here an excerpt from the log when using this atom in Firefox:

1712307672711	Marionette	DEBUG	3 -> [0,6,"WebDriver:GetElementText",{"id":"875c627d-1025-48e7-98be-a0cae9a65b2f"}]
1712307672717	Marionette	DEBUG	3 <- [1,6,null,{"value":"Test_Text"}]

Operating System

All

Selenium version

All

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

All

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

All

Are you using Selenium Grid?

No response

Copy link

github-actions bot commented Apr 5, 2024

@whimboo, 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!

@diemol
Copy link
Member

diemol commented Apr 9, 2024

@whimboo would you like to send a PR? I can review it and merge it.

@whimboo
Copy link
Contributor Author

whimboo commented Apr 9, 2024

Sadly I don't have the time at the moment. If someone else can provide a patch and test it would be great.

diemol added a commit that referenced this issue Apr 9, 2024
@diemol diemol linked a pull request Apr 9, 2024 that will close this issue
8 tasks
@diemol
Copy link
Member

diemol commented Apr 9, 2024

I created #13792 based on your comment, @whimboo.

diemol added a commit that referenced this issue Apr 10, 2024
* Fixing atom to capitalize text

Credit to @whimboo

Fixes #13779

* Adding a test
Copy link

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.

@github-actions github-actions bot locked and limited conversation to collaborators May 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants