Skip to content

Commit

Permalink
[BUGFIX] Harden XPath query to limit search for page tree node
Browse files Browse the repository at this point in the history
Even if page tree nodes are queried from a given context node, the
used XPath query searches for all elements in the document because
of the `//` syntax. This may lead to possible test failures in case
the queried node text appears multiple times in the document.

In order to avoid such behaviors and actually limit the XPath query
to the given context, it is now prefixed with a dot (`.`). In
addition, only following siblings of the current node are included
since page tree nodes are presented as flat node structure. This
way, the current context is now actually taken into account.
  • Loading branch information
eliashaeussler committed Nov 16, 2023
1 parent ac78c77 commit 0a8bb9e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Classes/Core/Acceptance/Helper/AbstractPageTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function ensureTreeNodeIsOpen(string $nodeText, RemoteWebElement $cont
$nodeText,
$context
) {
return $context->findElement(\Facebook\WebDriver\WebDriverBy::xpath('//*[text()=\'' . $nodeText . '\']/..'));
return $context->findElement(\Facebook\WebDriver\WebDriverBy::xpath('.//following-sibling::*//*[text()=\'' . $nodeText . '\']/..'));
});

try {
Expand Down

0 comments on commit 0a8bb9e

Please sign in to comment.