xpath search for divs where the id contains specific text

后端 未结 3 1943
青春惊慌失措
青春惊慌失措 2020-12-29 18:31

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]\"
         


        
3条回答
  •  一生所求
    2020-12-29 19:29

    You can use the xpath

    //div[@contains(@id,'test')]
    

    If you want to use the first occurrence, it works fine but if it's not the first occurrence you have to go with different xpath specific to the particular element.

提交回复
热议问题