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

SeleniumPython

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Python
Python

Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive set of standard libraries, including NumPy, SciPy, Django, PyQuery, and PyLibrary.

6K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo