XPath 'contains' helps you locate web elements with specific text, even if you only know part of it.
Here's the basic syntax:
//tagname[contains(@attribute, 'value')]
📌 tagname: The HTML tag (e.g., button, a)
📌 @attribute: The attribute (e.g., text(), @id, @class)
📌 value: The partial text you want to find
Example:
To find a button with 'Buy' on a shopping site:
//button[contains(text(), 'Buy')]
This will find any button with 'Buy' in it, like 'Buy Now' or 'Buy It,' making your tests more robust.
📖 Check the link in our bio for more details!
https://www.educba.com/xpath-contains/
👍 Like, share, and subscribe for more tech tips!
#XPath #WebDevelopment #TechTips #Coding #Automation #WebTesting #LearnCoding #InstaTech #TechEducation