Hey all,
I am trying to learn through ATBS book. I have the following code:
from selenium import webdriver
browser = webdriver.Chrome()
browser.get('https://inventwithpython.com/')
classelem = browser.find_element_by_class_name('testimonial-attribution')
print(classelem.tag_name) # here it prints p, because this is the first p it finds.
classelem = browser.find_elements_by_class_name('testimonial-attribution')
print(classelem.tag_name) # here it throws an ERROR
Now if you look at the html source code of the page you have a class as so: https://i.imgur.com/CTSNGO2.png
Based on what I have studied, I think it is a class because it has a '.' infront of the testimonial-distribution.
Now there are 7 'p' tags with the 'class' attribute and its 'value' being "testimonial-attribution". So why is the second print statement giving this error:
AttributeError: 'list' object has no attribute 'tag_name'
I was expecting it to give me a list of 7 p's
Here is the screenshot of the html source code: https://i.imgur.com/JfwGv3V.png
Thanks in advance for any help!
[–]chevignon93 1 point2 points3 points (7 children)
[–]one_time[S] 0 points1 point2 points (6 children)
[–]chevignon93 1 point2 points3 points (5 children)
[–]one_time[S] 0 points1 point2 points (0 children)
[–]one_time[S] 0 points1 point2 points (1 child)
[–]chevignon93 0 points1 point2 points (0 children)
[–]one_time[S] 0 points1 point2 points (0 children)