Selenium 'WebElement' 对象没有属性 'Get_Attribute' [英] Selenium 'WebElement' object has no attribute 'Get_Attribute'

查看:104
本文介绍了Selenium 'WebElement' 对象没有属性 'Get_Attribute'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Python 中使用 Selenium webdriver (chrome),我试图从网页上的所有链接中获取 href.当我尝试以下操作时:

I'm using Selenium webdriver (chrome) with Python, I'm trying to get the href from all the links on the webpage. When I try the following:

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

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

它设法获取所有链接,但在 get_attribute 上出现错误:

It manages to get all the links, but on get_attribute I get an error:

'WebElement' 对象没有属性 'Get_Attribute'

'WebElement' object has no attribute 'Get_Attribute'

尽管我到处看它似乎应该可以工作.

Though everywhere I looked it seems like it should work.

推荐答案

Get_Attribute"属性不存在,但get_attribute"属性存在:

The "Get_Attribute" property doesn't exist, but the "get_attribute" property does:

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

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

这篇关于Selenium 'WebElement' 对象没有属性 'Get_Attribute'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆