Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xpath search for divs where the id contains specific text

On my HTML page I have forty divs but I only want one div

Using agility pack to search and get all the divs with Ids I use this

"//div[@id]" 

BUT how do I search for divs with Ids where the id contains the text "test"

<div id="outerdivtest1></div>" 

Thanks

like image 738
Hello-World Avatar asked Aug 29 '12 11:08

Hello-World


2 Answers

Use the contains function:

//div[contains(@id,'test')] 
like image 180
choroba Avatar answered Oct 12 '22 12:10

choroba


I've used this with for the CSS class:

//div[@class = 'atom'] 

I assume it's similar with id's.

like image 27
Remy Avatar answered Oct 12 '22 11:10

Remy