Skip to content

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

Description

@whimboo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-atomsJavaScript chunks generated by Google closureI-defectSomething is not working as intended

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions