0 votes
in Xpath Interview Questions by
How do you handle text in XPath which is dynamic?

1 Answer

0 votes
by

Using the text function, we can find the elements using the text present in them.

<button type="button">Blueberry</button>    (Blueberry is text here)

xpath with text : //button[text()='Blueberry']​

But when the text is dynamic we have to use contains function along with text function. For this to work some part of the string must be static.

<button type="button">*****berry</button>

xpath with text : //button[contains(text(),'berry')]​

Related questions

0 votes
asked Jul 24, 2021 in Xpath Interview Questions by Robindeniel
0 votes
asked Jul 23, 2021 in Xpath Interview Questions by kamalkhandelwal29
...