WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
270215
[WebDriver][GTK][socket] GetElementText doesn't work for "overflow:hidden" element
https://bugs.webkit.org/show_bug.cgi?id=270215
Summary
[WebDriver][GTK][socket] GetElementText doesn't work for "overflow:hidden" el...
haruhisa.shin
Reported
2024-02-27 23:13:53 PST
The wincairo WebDriver does not seem to be able to get text from an element with "overflow:hidden" with GetElementText. This has occurred after the following change.
Bug 174617
- WebDriver: add a javascript atom to get the visible text
https://commits.webkit.org/247010@main
I cannot determine whether the current result is a spec or a bug, but I thought it was unnatural that the text could not be obtained even though it was shown. I have confirmed that this problem occurs with the following steps: 1. host the following HTML to any HTTP server. ============= <html> <body> <a id="link1" href="foo.html">LINK1</a> <a id="link2" href="foo.html" style="overflow:hidden">LINK2</a> </body> </html> ============= 2. build wincairo. 3. launch MiniBrowser.exe with environment variable WEBKIT_INSPECTOR_SERVER.
> set WEBKIT_INSPECTOR_SERVER=127.0.0.1:1641 > WebKitBuild\Release\bin64\MiniBrowser.exe
4. open the test page (hosted by step 1) by Minibrowser. 5. launch WebDriver.exe with -t and -p options.
> WebKitBuild\Release\bin64\WebDriver.exe -t 127.0.0.1:1641 -p 12345
6. execute the following script using selenium. ============= from selenium import webdriver options = webdriver.WebKitGTKOptions() driver = webdriver.Remote( command_executor="
http://{0}:{1
}".format('127.0.0.1', 12345), options=options ) elem = driver.find_element(By.ID, "link1") print(f'link1: id = {elem.get_attribute("ID")}, text = {elem.text}') elem = driver.find_element(By.ID, "link2") print(f'link2: id = {elem.get_attribute("ID")}, text = {elem.text}') driver.quit() ============= The actual result: The correct string is returned for link1, but link2 is blank. link1: id = link1, text = LINK1 link2: id = link2, text =
Attachments
Add attachment
proposed patch, testcase, etc.
haruhisa.shin
Comment 1
2024-03-04 01:25:21 PST
As the same as wincairo and playstation, I confirmed that the "overflow:hidden" property always seems to prevent WebDriver's GetElementText in GTK. I added "[GTK]" to the title.
Lauro Moura
Comment 2
2024-03-13 11:01:34 PDT
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
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug