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

Python 如何定位具有相同xpath的2个文本?,python,frameworks,robot,Python,Frameworks,Robot,如何在同一xpath中定位文本? 我用过但不工作: //div[contains(text(),"Review") and contains(text(),"received"] 文本属于两个不同的标签。您可以查找包含“Review”文本的元素,该元素的子元素包含“received”文本 //div[contains(text(),"Review") and div[contains(text(),"received")]] 当心,你离任务越近越好 但这不是好的xpath,因为“receiv

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

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

文本属于两个不同的标签。您可以查找包含
“Review”
文本的元素,该元素的子元素包含
“received”
文本

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

当心,你离任务越近越好

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

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

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

您丢失了close')-->//div[contains(text(),“Review”)和contains(text(),“received”)]
//div[.//*[contains(text(),"Review")] and .//*[contains(text(),"received")]]
//div[contains(text(),"Review") and .//*[contains(text(),"received")]]