XPATH: button contains text

Last updated on:

1. Element contains


Here is an example with Google Home Page:

//input[@value='Google Search']

You can read as: find "input" field where "value" equal to "Google Search"
I found out that snippets bellow works better in my current project:

2. Element with attribute and contains

//button[@type='button' and contains(., "Submit")]

3. Get child element

For example here is and simple html

To get all child div containers you could use xpath like the one below:


And then let say you want to select one specific child div container, here is how you do it:


4. Locate parent element


W3 xpath reference

View Comments

Leave a Comment

Use markdown or basic HTML and be nice.