您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python – Selenium’WebElement’对象没有属性’Get_Attribute’

5b51 2022/1/14 8:23:06 python 字数 1565 阅读 570 来源 www.jb51.cc/python

我正在使用Selenium webdriver(chrome)和 Python,试图从页面上的所有链接获取href.当我尝试以下内容时: items = driver.find_elements_by_tag_name("a") print items for item in items: href = item.Get_Attribute('href') print href

概述

items = driver.find_elements_by_tag_name("a")
print items

for item in items:
    href = item.get_attribute('href')
    print href

它设法获取所有链接,但在get_attribute上我收到一个错误

‘WebElement’对象没有属性’Get_Attribute’

虽然我看到的任何地方似乎都应该有效.

解决方案吗

谢谢!

items = driver.find_elements_by_tag_name("a")
print items

for item in items:
    href = item.get_attribute('href')
    print href

总结

以上是编程之家为你收集整理的python – Selenium’WebElement’对象没有属性’Get_Attribute’全部内容,希望文章能够帮你解决python – Selenium’WebElement’对象没有属性’Get_Attribute’所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶