New issue
Advanced search Search tips

Issue 908632 link

Starred by 5 users

Issue metadata

Status: Untriaged
Owner: ----
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug

Blocking:
issue chromedriver:2642



Sign in to add a comment

XPath evaluation issue with union

Project Member Reported by johnchen@chromium.org, Nov 26

Issue description

Chrome Version: 70.0.3538.110
OS: Linux, Mac OS 10.14.1, Win10

What steps will reproduce the problem?
(1) Navigate to URL http://watir.com/examples/nested_tables.html
(2) Open "Developer tools" pane, select Console tab, and run the following JavaScript code to create two variables contain XPaths:
xpath1 = "(.//*[local-name()='table'][starts-with(@id, 'tbl')])[12]/*[local-name()='tr']"
xpath2 = "(.//*[local-name()='table'][starts-with(@id, 'tbl')])[12]/*[local-name()='tbody']/*[local-name()='tr']"
(3) Run the following JavaScript code to evaluate an XPath expression containing a union:
document.evaluate(xpath1 + '|' + xpath2, document.documentElement).iterateNext()

What is the expected result?
The XPath should return one <tr> node, since xpath1 returns 0 nodes while xpath2 returns 1 node.

What happens instead?
The XPath returns no nodes, and the JavaScript code in step 3 results in null

Note that the following expression (which switches the order of xpath1 and xpath2) evaluates correctly:
document.evaluate(xpath2 + '|' + xpath1, document.documentElement).iterateNext()

This issue appears to be related to the use of parentheses. If xpath1 is modified to remove the pair of parentheses (which isn't really necessary), then the JavaScript code in step 3 works properly.

 
Removal of the parentheses would change the meaning of the XPath so they are actually necessary
I just tried the following:

(1) Open the URL www.google.com.
(2) Open developer tools
(3) Enter $x("((.//div)[1])|.") into console and press enter
(4) Expected result would have been 
    * the first div node in the document 
    * the document node
(5) The actual result was
    * the first div node in the document 
    * some unexpected div node

This behaviour makes the union operation unpredictable. We are using selenium with google chrome and encountered described behaviour.

I posted this here since I guess it is the same bug. Propably a bit easier to reproduce.

Sign in to add a comment