简体   繁体   English

Python Selenium 找不到 XPath

[英]Python Selenium can't find XPath

I need to find the XPath for the Text (Can you find me?):我需要找到文本的 XPath(你能找到我吗?): 在此处输入图像描述

Tried it for about 10 minutes but wasn't able to do it.尝试了大约 10 分钟,但无法做到。

You have id, use it.你有身份证,用它。

driver.find_element_by_id("modal-root-header").text

If id is not unique for some reason, use xpath:如果 id 由于某种原因不是唯一的,请使用 xpath:

driver.find_element_by_xpath("//h4[@id='modal-root-header']").text

If .text won't work, try .get_attribute("value") , or .get_attribute("innerText")如果.text不起作用,请尝试.get_attribute("value").get_attribute("innerText")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM