如何定位具有相同xpath的2个文本?

问题描述 投票:0回答:2

如何在同一个xpath中定位文本? 我用过但不起作用:

//div[contains(text(),"Review") and contains(text(),"received"]

python robotframework
2个回答
0
投票

文本属于两个不同的标签。您可以查找带有

"Review"
文本的元素,该元素的子元素带有
"received"
文本

//div[contains(text(),"Review") and div[contains(text(),"received")]]

0
投票

保重,你离任务越近')'

//div[contains(text(),"Review") and contains(text(),"received")]

但这不是好的 xpath,因为“已收到”位于内部元素上

试试这个,.//* 表示任何子元素,可以在第二个包含上使用 ./div

//div[.//*[contains(text(),"Review")] and .//*[contains(text(),"received")]]

//div[contains(text(),"Review") and .//*[contains(text(),"received")]]
© www.soinside.com 2019 - 2024. All rights reserved.