From 0a8bb9ee2c226a8ac0c4cc96086256b99fa29fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Sat, 15 Jul 2023 20:33:48 +0200 Subject: [PATCH] [BUGFIX] Harden XPath query to limit search for page tree node 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. --- Classes/Core/Acceptance/Helper/AbstractPageTree.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Core/Acceptance/Helper/AbstractPageTree.php b/Classes/Core/Acceptance/Helper/AbstractPageTree.php index f7886ebf..2f1e0db0 100644 --- a/Classes/Core/Acceptance/Helper/AbstractPageTree.php +++ b/Classes/Core/Acceptance/Helper/AbstractPageTree.php @@ -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 {