Home > Software engineering >  How to get the Xpath of the value which is under p tag inside the header
How to get the Xpath of the value which is under p tag inside the header

Time:12-02

How can I extract ingredient list inside the <p> tag? I tried few things and was able to get till header - Ingredients. I am look to extract the value which should be aligned with header - Ingredients.

Path I tried:

//DIV[@id="important-information"]//h4[text()='Ingredients:']/text()

Image:

enter image description here

CodePudding user response:

You can use this xpath to locate the 2nd p tag element highlighted in the image. Below xpath can be used in automation as it will return the web element-

//div[@id="important-information”]//div[2]//p[2]

And if you directly want to get the text from xpath then use below xpath-

//div[@id="important-information”]//div[2]//p[2]/text()
  • Related