Bug 174499

Summary: Web Automation: link and partial link queries don't work if text link contains trailing or leading whitespaces
Product: WebKit Reporter: Carlos Garcia Campos <cgarcia>
Component: WebKit2Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, buildbot, joepeck, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 174498    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Rebased patch
bburg: review+, buildbot: commit-queue-
Archive of layout-test-results from ews116 for mac-elcapitan none

Description Carlos Garcia Campos 2017-07-14 03:14:14 PDT
This is causing test test_Driver_Can_Get_Link_By_Link_Test_Ignoring_Trailing_Whitespace to fail. The selenium atoms don't use xpath for links, they use css query to get all links and then they compare with the *visible* text. I think we can keep using xpath, though, but using normalize-space() function to compare with the given text.

========================================================================================== FAILURES ==========================================================================================
_______________________________________________________ test_Driver_Can_Get_Link_By_Link_Test_Ignoring_Trailing_Whitespace[WebKitGTK] ________________________________________________________

driver = <selenium.webdriver.webkitgtk.webdriver.WebDriver (session="add1a4bd-2753-4b49-96b1-fd9dfa64e6d0")>, pages = <conftest.Pages object at 0x7ff814790490>

    def test_Driver_Can_Get_Link_By_Link_Test_Ignoring_Trailing_Whitespace(driver, pages):
        pages.load("simpleTest.html")
>       link = driver.find_element(By.LINK_TEXT, "link with trailing space")

E       NoSuchElementException: Message:

../selenium/webdriver/remote/errorhandler.py:193: NoSuchElementException
Comment 1 Carlos Garcia Campos 2017-07-14 03:18:57 PDT
Created attachment 315414 [details]
Patch

This won't apply because it depends on patch attached to bug #174498. Note also that this still doesn't fix test_Driver_Can_Get_Link_By_Link_Test_Ignoring_Trailing_Whitespace, but now it fails because of our poor implementation of GetText:

========================================================================================== FAILURES ==========================================================================================
_______________________________________________________ test_Driver_Can_Get_Link_By_Link_Test_Ignoring_Trailing_Whitespace[WebKitGTK] ________________________________________________________

driver = <selenium.webdriver.webkitgtk.webdriver.WebDriver (session="e5b70972-d8f7-4de9-8324-d6f4e3607345")>, pages = <conftest.Pages object at 0x7f3257a58490>

    def test_Driver_Can_Get_Link_By_Link_Test_Ignoring_Trailing_Whitespace(driver, pages):
        pages.load("simpleTest.html")
        link = driver.find_element(By.LINK_TEXT, "link with trailing space")
        assert link.get_attribute("id") == "linkWithTrailingSpace"
>       assert link.text == "link with trailing space"
E       assert 'link with trailing space ' == 'link with trailing space'
E         - link with trailing space 
E         ?                         -
E         + link with trailing space

selenium/webdriver/common/driver_element_finding_tests.py:568: AssertionError
Comment 2 Radar WebKit Bug Importer 2017-07-14 08:29:01 PDT
<rdar://problem/33316679>
Comment 3 Carlos Garcia Campos 2017-07-17 00:05:52 PDT
Created attachment 315644 [details]
Rebased patch

It should apply now
Comment 4 Build Bot 2017-07-17 01:33:32 PDT
Comment on attachment 315644 [details]
Rebased patch

Attachment 315644 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/4134321

New failing tests:
security/contentSecurityPolicy/video-with-data-url-allowed-by-media-src-star.html
Comment 5 Build Bot 2017-07-17 01:33:33 PDT
Created attachment 315648 [details]
Archive of layout-test-results from ews116 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews116  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 6 BJ Burg 2017-07-17 10:40:13 PDT
Comment on attachment 315644 [details]
Rebased patch

r=me

I had no idea this function was a thing.
Comment 7 Carlos Garcia Campos 2017-07-17 23:28:37 PDT
(In reply to Brian Burg from comment #6)
> Comment on attachment 315644 [details]
> Rebased patch
> 
> r=me
> 
> I had no idea this function was a thing.

Me neither :-P Note that the spec explicitly says we should apply the visible text algorithm here, but just normalizing spaces will cover mot of the cases I think, anyway.
Comment 8 Carlos Garcia Campos 2017-07-17 23:29:09 PDT
Committed r219604: <http://trac.webkit.org/changeset/219604>