Skip to content
Advertisement

Does an XPath change if the content inside it changes?

Does the Xpath change if the content inside the XPath changes?

I.e. the website changes the text in the XPath from ‘supports’ to ‘support’. Would the XPath change even if the text change or will it stay the same?

Advertisement

Answer

XPath is a syntax to locate element on the page based on it attributes like tag name, class name, id, href etc values. Also it can be located relatively to other elements.
So, if you are locating the element based on it’s tag name and class name (for example) and you changing the element text content this will not affect selecting this element with previously created XPath locator.
However if you are locating the element based on it’s text content and you changing that text – that XPath locator will obviously not find that element no more since now no more presented element with the old text on this web page.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement