Link to home
Start Free TrialLog in
Avatar of Hiro 714
Hiro 714

asked on

selenium python question

I want to list URLs in elems. Please advise.
elems = driver.find_elements_by_xpath("//a[contains(@href,'abc.com')]")
#for elem in elems:
url = elems.get_attribute("href")
print(url)

Open in new window

I'm getting this error.
AttributeError                            Traceback (most recent call last)
<ipython-input-291-f30319c0a4c2> in <module>
      2 #for elem in elems:
      3
----> 4 url = elems.get_attribute("href")
      5 print(url)

AttributeError: 'list' object has no attribute 'get_attribute'

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial