Finding An Element From A List Of Webelements In Selenium Using Python
class = 'a1'This is a follow-up question to: Accessing a webelement within a list of webelement in Selenium using Pything HTML File TEST2.html
Solution 1:
I was using double quotes where only single quotes are needed.
find_element_by_tag_name requires double quotes, find_element_by_class_name requires Single quotes.
Documentation here
So:
driver = webdriver.Chrome()
url = 'C:\\Users\\ed821\\Downloads\\TEST2.html'
driver.get(url)
titles = driver.find_elements_by_class_name("pp")
for title in titles:
heading = title.find_element_by_tag_name("h1") ## This works
heading2 = title.find_element_by_class_name('a1') ## This worksprint("Title is:" + heading.text)
print("Also: " + heading2.text)
Post a Comment for "Finding An Element From A List Of Webelements In Selenium Using Python"