panther
panther copied to clipboard
XPath nth element selector is treated as CSS, and is invalid
A valid XPath selector for nth element, e.g. (//a)[3] is treated as a CSS selector because it does not start with a /, which causes an "invalid selector" exception to be thrown.
https://github.com/symfony/panther/blob/e53feac1df95f2022979e86f40b2540306581c3c/src/Client.php#L726
Good catch. Maybe could we introduce a new parameter to force the selector to be interpreted as xpath?
It might be nice to have that option. I would think simply changing that line to this would fix the issue as well since CSS selectors cannot start with an open parenthesis:
return empty( $locator ) || !in_array( $locator[0], [ '/', '(' ] )
This works for me. Do you want to open a PR?