XPathManupulator parentesis handling bug
Consider following input:
- prefix:
descendant-or-self::*[@id = 'checkbox-with-preceding-label'] - xpath:
(//label[@for = 'checkbox-with-preceding-label'])[1]
I expect result to be descendant-or-self::*[@id = 'checkbox-with-preceding-label']/(//label[@for = 'checkbox-with-preceding-label'])[1] (both prefix and xpath combined using /).
In reality this produced this xpath: (descendant-or-self::*[@id = 'checkbox-with-preceding-label']//label[@for = 'checkbox-with-preceding-label'])[1] (the prefix is injected into parenthesis and produces xpath that doesn't match what's expected).
I'm using parentheses in xpath to specify which of found elements I want to get. It as well can be 5th element, so using find instead of findAll method isn't a viable solution.
P.S.
I'm trying to find matching label by for attribute across the document, but I start with checkbox xpath, that I can't change.
Right now I've changed xpath to look like (preceding::label[@for = 'checkbox-with-preceding-label'] | following::label[@for = 'checkbox-with-preceding-label'])[1] and it works. Maybe there is a better way.
The app I'm used to evaluate that XPATH is called Phathology (http://celestialteapot.com/pathology/) and it works in there. However it doesn't any other XPATH evaluator I've tried. I guess using () in between of / is forbidden in XPATH.
yep, it is forbidden (which is why prepending a prefix is so complex).
The case of (//label[@for = 'checkbox-with-preceding-label'])[1] is indeed not covered in the XPathManipulator currently (it is very complex as it might require altering the parent, and none of the Mink selectors will produce such XPath)
@stof , can you suggest alternative xpath for locating checkbox/radio label, when I'm already on it other then in https://github.com/minkphp/Mink/issues/593#issuecomment-52387653 comment?