XPath evaluation issue with union |
|
Issue descriptionChrome 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.
,
Dec 3
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 |
|
Comment 1 by twalp...@gmail.com
, Nov 26