[Webkit-unassigned] [Bug 270215] [WebDriver][GTK][socket] GetElementText doesn't work for "overflow:hidden" element

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Mar 13 11:01:34 PDT 2024


https://bugs.webkit.org/show_bug.cgi?id=270215

Lauro Moura <lmoura at igalia.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lmoura at igalia.com

--- Comment #2 from Lauro Moura <lmoura at igalia.com> ---
Looks like a bug in WebKit's WebDriver code indeed. From WebDriver's `Get Element Text` spec at https://w3c.github.io/webdriver/#get-element-text :

> The Get Element Text command intends to return an element's text “as rendered”. An element's rendered text is also used for locating a elements by their link text and partial link text.

> One of the major inputs to this specification was the open source Selenium project. This was in wide-spread use before this specification written, and so had set user expectations of how the Get Element Text command should work. As such, the approach presented here is known to be flawed, but provides the best compatibility with existing users. 

> ...

> 4. Let rendered text be the result of performing implementation-specific steps whose result is exactly the same as the result of a Function.[[Call]](null, element) with bot.dom.getVisibleText as the this value.

`bot.dom.getVisibleText`[1] indeed works in Cog (WPE HEAD) and Epiphany (44.2, WebKitGTK 2.40.2, from flatpak), returning the text from the visible `overflow:hidden` element, thus it's something in our WebDriver implementation.

Some time ago, bug174617 improved WebKit's implementation of this function, but it seems it's missing to cover some overflow edge cases like the one in this example (These are indeed quite complicated rules).

Here, looks like it's this[2] check inside `isElementSubtreeHiddenByOverflow()`, which results in a visible child text node being assumed as hidden by overflow.

Thanks for reporting this issue.

PS: While testing, I noticed Selenium's `bot.dom.getVisibleText()` returns - in the 3 major engines - the full element text if some portion of it is visible, not only the visible part. I added some tests in [2] and will contact the Selenium and WebDriver spec team for clarification. Maybe the spec might need an extra comment.

[1] Selenium reference function https://github.com/SeleniumHQ/selenium/blob/a6b161a159c3d581b130f03a2e6e35f577f38dec/javascript/atoms/dom.js#L1007
[2] WebKit implementation of getElementText https://github.com/WebKit/WebKit/blame/349c5a3059a9047c7d9939deab1e2bbd4dc08e10/Source/WebKit/UIProcess/Automation/atoms/utils.js#L132
[3] Other overflow:hidden edge cases https://github.com/lauromoura/selenium/commit/093fad71cbe8341a1385b2a0e5894d853e812a6e

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240313/309494a6/attachment.htm>


More information about the webkit-unassigned mailing list