【发布时间】:2022-11-14 06:56:07
【问题描述】:
我正在尝试使用 Selenium 在 Python 中获取以下元素的 URL('href')。对于我的生活,它不起作用,这是我得到的唯一输出,例如:
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="href"]"}
这是我想从以下位置获取 ('Href') 或 ('Text') 的元素:
选择器: #tinymce > p:nth-child(20) > a
路径: //*[@id="tinymce"]/p[7]/a
完整的 Xpath: /html/body/p[7]/a
我尝试了以下方法来查找页面上的元素,但没有成功:
选择器 Xpath 完整的 Xpath
只得到:NoSuchElementException:消息:没有这样的元素:无法找到元素:
【问题讨论】:
-
这是检查网页上的元素时的路径:<p> <a href="code.private.pri">https://code.private.pri</a> </p>
标签: python selenium selenium-webdriver selenium-chromedriver