Write dynamic XPath with contains() and starts-with()
Automation taskEasy-MediumAsked in: Accenture, Capgemini, Infosys, TCS, Wipro
The most asked locator task: "The id changes on every load, like user_8273. Write an XPath that still finds it." starts-with() and contains() match only the stable part of a value or of the text, so the changing number no longer matters. Here, on a page of links, you find one link by part of its text and another by the start of its id.