Title: [226047] releases/WebKitGTK/webkit-2.18/Source/WebKit
Revision
226047
Author
carlo...@webkit.org
Date
2017-12-18 09:00:21 -0800 (Mon, 18 Dec 2017)

Log Message

Merge r225388 - WebDriver: link and partial links queries don't work in xhtml documents
https://bugs.webkit.org/show_bug.cgi?id=180191

Reviewed by Brian Burg.

We convert the queries to use xpath, which works for html documents, but it doesn't work for xhtml. In case of
xhtml we would need to provide a namespace resolver and elements would need to be prefixed with 'xhtml:'. It's
easier to simply iterate the link elements and compare the text.

Fixes: imported/w3c/webdriver/tests/retrieval/find_element_from_element.py::test_xhtml_namespace[link text-full link text]
       imported/w3c/webdriver/tests/retrieval/find_element_from_element.py::test_xhtml_namespace[partial link text-link text]
       imported/w3c/webdriver/tests/retrieval/find_element_from_elements.py::test_xhtml_namespace[link text-full link text]
       imported/w3c/webdriver/tests/retrieval/find_element_from_elements.py::test_xhtml_namespace[partial link text-link text]
       imported/w3c/webdriver/tests/retrieval/find_element.py::test_xhtml_namespace[link text-full link text]
       imported/w3c/webdriver/tests/retrieval/find_element.py::test_xhtml_namespace[partial link text-link text]
       imported/w3c/webdriver/tests/retrieval/find_elements.py::test_xhtml_namespace[link text-full link text]
       imported/w3c/webdriver/tests/retrieval/find_elements.py::test_xhtml_namespace[partial link text-link text]

* UIProcess/Automation/atoms/FindNodes.js:
(switch):
(tryToFindNode):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKit/ChangeLog (226046 => 226047)


--- releases/WebKitGTK/webkit-2.18/Source/WebKit/ChangeLog	2017-12-18 17:00:17 UTC (rev 226046)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKit/ChangeLog	2017-12-18 17:00:21 UTC (rev 226047)
@@ -1,3 +1,27 @@
+2017-12-01  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        WebDriver: link and partial links queries don't work in xhtml documents
+        https://bugs.webkit.org/show_bug.cgi?id=180191
+
+        Reviewed by Brian Burg.
+
+        We convert the queries to use xpath, which works for html documents, but it doesn't work for xhtml. In case of
+        xhtml we would need to provide a namespace resolver and elements would need to be prefixed with 'xhtml:'. It's
+        easier to simply iterate the link elements and compare the text.
+
+        Fixes: imported/w3c/webdriver/tests/retrieval/find_element_from_element.py::test_xhtml_namespace[link text-full link text]
+               imported/w3c/webdriver/tests/retrieval/find_element_from_element.py::test_xhtml_namespace[partial link text-link text]
+               imported/w3c/webdriver/tests/retrieval/find_element_from_elements.py::test_xhtml_namespace[link text-full link text]
+               imported/w3c/webdriver/tests/retrieval/find_element_from_elements.py::test_xhtml_namespace[partial link text-link text]
+               imported/w3c/webdriver/tests/retrieval/find_element.py::test_xhtml_namespace[link text-full link text]
+               imported/w3c/webdriver/tests/retrieval/find_element.py::test_xhtml_namespace[partial link text-link text]
+               imported/w3c/webdriver/tests/retrieval/find_elements.py::test_xhtml_namespace[link text-full link text]
+               imported/w3c/webdriver/tests/retrieval/find_elements.py::test_xhtml_namespace[partial link text-link text]
+
+        * UIProcess/Automation/atoms/FindNodes.js:
+        (switch):
+        (tryToFindNode):
+
 2017-11-30  Brian Burg  <bb...@apple.com>
 
         Web Automation: computeElementLayout does not correctly translate iframe client coordinates to main frame coordinates

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKit/UIProcess/Automation/atoms/FindNodes.js (226046 => 226047)


--- releases/WebKitGTK/webkit-2.18/Source/WebKit/UIProcess/Automation/atoms/FindNodes.js	2017-12-18 17:00:17 UTC (rev 226046)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKit/UIProcess/Automation/atoms/FindNodes.js	2017-12-18 17:00:21 UTC (rev 226047)
@@ -35,18 +35,12 @@
         strategy = "css selector";
         query = "[name=\"" + escape(query) + "\"]";
         break;
-    case "link text":
-        strategy = "xpath";
-        query = ".//a[@href][normalize-space(descendant-or-self::text()) = \"" + escape(query) + "\"]";
-        break;
-    case "partial link text":
-        strategy = "xpath";
-        query = ".//a[@href][contains(normalize-space(descendant-or-self::text()), \"" + escape(query) + "\")]";
-        break;
     }
 
     switch (strategy) {
     case "css selector":
+    case "link text":
+    case "partial link text":
     case "tag name":
     case "class name":
     case "xpath":
@@ -70,6 +64,32 @@
                     return ancestorElement.querySelector(query) || null;
                 return Array.from(ancestorElement.querySelectorAll(query));
 
+            case "link text":
+                let linkTextResult = [];
+                for (let link of ancestorElement.getElementsByTagName("a")) {
+                    if (link.text.trim() == query) {
+                        linkTextResult.push(link);
+                        if (firstResultOnly)
+                            break;
+                    }
+                }
+                if (firstResultOnly)
+                    return linkTextResult[0] || null;
+                return linkTextResult;
+
+            case "partial link text":
+                let partialLinkResult = [];
+                for (let link of ancestorElement.getElementsByTagName("a")) {
+                    if (link.text.includes(query)) {
+                        partialLinkResult.push(link);
+                        if (firstResultOnly)
+                            break;
+                    }
+                }
+                if (firstResultOnly)
+                    return partialLinkResult[0] || null;
+                return partialLinkResult;
+
             case "tag name":
                 let tagNameResult = ancestorElement.getElementsByTagName(query);
                 if (firstResultOnly)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to