【发布时间】:2021-12-27 22:30:48
【问题描述】:
我目前正在尝试执行这个命令,尝试选择:
driver.find_element_by_xpath("//a[contains(@href, 'mailto')]/@href").getAttribute("href")
<a href="X">时得到X。
它显示了这个错误:
invalid selector: The result of the xpath expression "//a[contains(@href, 'mailto')]/@href" is: [object Attr]. It should be an element.
我尝试过 .getAttribute 但没有成功。谁能帮我解决这个问题?
谢谢
【问题讨论】:
-
始终将代码和标记添加为文本,并将其格式化为代码。无法轻松搜索或复制和粘贴图像以验证解决方案。谢谢。
标签: python selenium xpath css-selectors getattribute