testing-framework icon indicating copy to clipboard operation
testing-framework copied to clipboard

[BUGFIX] Harden XPath query to limit search for page tree node

Open eliashaeussler opened this issue 1 year ago • 4 comments

Even if page tree nodes are queried from a given context node, the currently used XPath query searches for all elements in the document instead. That's because of the // syntax, which searches in the whole document, regardless of which context is given. This may lead to possible test failures in case the queried node text appears multiple times in the document, for example when trying to access the root page tree node whose text appears twice on the page – next to the TYPO3 logo in the topbar and as root node in the page tree. With the current implementation, the XPath query would match the text in the topbar instead of the text of the root node.

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.

As an additional fix, property accesses of static properties in AbstractPageTree is now changed from self:: to static:: to properly respect overridden properties in extended classes. This is especially necessary for the overridden properties in TYPO3 core's FileTree.

Patch in TYPO3 core: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80039

:bulb: If this PR will be merged, I'll update the TYPO3 core patch accordingly.

eliashaeussler avatar Jul 16 '23 07:07 eliashaeussler