如何获取 header 内 p 标签下的值的 Xpath

How to get the Xpath of the value which is under p tag inside the header

如何提取 <p> 标签内的成分列表?我尝试了一些东西,直到 header - 配料。我希望提取应与 header - Ingredients.

对齐的值

我试过的路径:

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

图片:

您可以使用此 xpath 定位图像中突出显示的第二个 p 标签元素。下面的 xpath 可以用于自动化,因为它将 return 网络元素 -

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

如果你想直接从 xpath 中获取文本,那么使用下面的 xpath-

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