Bug 174619 - WebDriver: handle invalid selector errors
Summary: WebDriver: handle invalid selector errors
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-07-18 01:56 PDT by Carlos Garcia Campos
Modified: 2017-07-18 23:12 PDT (History)
3 users (show)

See Also:


Attachments
Patch (7.23 KB, patch)
2017-07-18 02:01 PDT, Carlos Garcia Campos
bburg: review+
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews125 for ios-simulator-wk2 (997.04 KB, application/zip)
2017-07-18 03:28 PDT, Build Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2017-07-18 01:56:09 PDT
ยง12. Element Retrieval. Step 6: If a DOMException, SyntaxError, XPathException, or other error occurs during the execution of the element location strategy, return error invalid selector. https://www.w3.org/TR/webdriver/#dfn-find

We are currently handling only XPathException and only when it's an invalid expression. In the xpath case, the spec also says "If any item in result is not an element return an error with error code invalid selector.", so we should also handle TYPE_ERR (The expression could not be converted to return the specified type.). However, since the spec says "or other error", I think we can simplify this and simply throw InvalidSelector inside the catch, without checking any specific error. This is causing 14 failures in driver_element_finding_tests.py:

selenium/webdriver/common/driver_element_finding_tests.py ........................FF...........F..F.......F..FFFFFFFF..........F.F.................
================================================================================== short test summary info ===================================================================================
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Finding_ASingle_Element_By_Empty_Tag_Name_Should_Throw[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Finding_Multiple_Elements_By_Empty_Tag_Name_Should_Throw[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Finding_Multiple_Elements_By_Empty_Class_Name_Should_Throw[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Finding_Multiple_Elements_By_Invalid_Class_Name_Should_Throw[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Should_Be_Able_To_Find_Element_By_XPath_With_Namespace[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Should_Throw_InvalidSelectorException_When_XPath_Is_Syntactically_Invalid_In_Driver_Find_Element[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Should_Throw_InvalidSelectorException_When_XPath_Is_Syntactically_Invalid_In_Driver_Find_Elements[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Should_Throw_InvalidSelectorException_When_XPath_Is_Syntactically_Invalid_In_Element_Find_Element[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Should_Throw_InvalidSelectorException_When_XPath_Is_Syntactically_Invalid_In_Element_Find_Elements[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Should_Throw_InvalidSelectorException_When_XPath_Returns_Wrong_Type_In_Driver_Find_Element[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Should_Throw_InvalidSelectorException_When_XPath_Returns_Wrong_Type_In_Driver_Find_Elements[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Should_Throw_InvalidSelectorException_When_XPath_Returns_Wrong_Type_In_Element_Find_Element[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Should_Throw_InvalidSelectorException_When_XPath_Returns_Wrong_Type_In_Element_Find_Elements[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Finding_Multiple_Elements_By_Empty_Css_Selector_Should_Throw[WebKitGTK]
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Finding_Multiple_Elements_By_Invalid_Css_Selector_Should_Throw[WebKitGTK]

Only one of those is a different issue.
Comment 1 Carlos Garcia Campos 2017-07-18 02:01:36 PDT
Created attachment 315782 [details]
Patch

selenium/webdriver/common/driver_element_finding_tests.py ................................................F........................................
================================================================================== short test summary info ===================================================================================
FAIL selenium/webdriver/common/driver_element_finding_tests.py::test_Should_Be_Able_To_Find_Element_By_XPath_With_Namespace[WebKitGTK]
Comment 2 Carlos Garcia Campos 2017-07-18 02:05:51 PDT
(In reply to Carlos Garcia Campos from comment #1)
> Created attachment 315782 [details]
> Patch
> 
> selenium/webdriver/common/driver_element_finding_tests.py
> ................................................F............................
> ............
> =============================================================================
> ===== short test summary info
> =============================================================================
> ======
> FAIL
> selenium/webdriver/common/driver_element_finding_tests.py::
> test_Should_Be_Able_To_Find_Element_By_XPath_With_Namespace[WebKitGTK]

btw, this test is marked xfail in all the drivers, so I'll do the same marking it as raising invalid selector.
Comment 3 Build Bot 2017-07-18 03:28:07 PDT
Comment on attachment 315782 [details]
Patch

Attachment 315782 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/4140770

New failing tests:
imported/w3c/IndexedDB-private-browsing/idbfactory_open12.html
Comment 4 Build Bot 2017-07-18 03:28:08 PDT
Created attachment 315788 [details]
Archive of layout-test-results from ews125 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125  Port: ios-simulator-wk2  Platform: Mac OS X 10.12.5
Comment 5 BJ Burg 2017-07-18 15:26:56 PDT
Comment on attachment 315782 [details]
Patch

r=me
Comment 6 Radar WebKit Bug Importer 2017-07-18 15:27:19 PDT
<rdar://problem/33387681>
Comment 7 Carlos Garcia Campos 2017-07-18 23:12:00 PDT
Committed r219652: <http://trac.webkit.org/changeset/219652>