[英]Selenium + Python: Cannot get href
I'm a newbie in auto testing and got a problem. 我是自动测试的新手,遇到了问题。
Cannot get href in debug mode, try to check it on google.com, my code: 无法在调试模式下获取href,请尝试在google.com上进行检查,我的代码为:
browser.get("https://google.com/")
def beta_check_href(self):
elem = self.find_elements_by_xpath("//a[@href]")
for el in elem:
print elem.get_attribute("href")
What am I doing wrong? 我究竟做错了什么? Thx!
谢谢!
You need to replace 您需要更换
for el in elem:
print elem.get_attribute("href")
with 同
for el in elem:
print el.get_attribute("href")
Note that elem
is the list of WebElements while el
is the single WebElement from elem
list 请注意,
elem
是WebElement的列表 ,而el
是elem
列表中的单个WebElement
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.