I have two xpath selectors that find exactly the same element, but I wonder which one is better from code, speed of execution, readability points of view etc.
First Xpath :
//*[@id="some_id"]/table/tbody/tr[td[contains(., "Stuff_01")]]//ancestor-or-self::td/input[@value="Stuff_02"]
Second Xpath:
//tr[td[@title="Stuff_01"]]//ancestor-or-self::td/input[@value="Stuff_02"]
The argument for example is that if the code of the page will be changed and for example some "tbody"
will be moved that the first one won't work, is it true ?
So any way which variant of the code is better and why ?
I would appreciate an elaborate answer, because this is crucial to the workflow.
@id
or other anchor point to hone in on a reduced subtree before further restraining the selection space.