Issue
I cannot find element by class attribute using selenium from this site. Unfortunately I get an NoSuchElementException. But at the same time I am sure that this element exists on the page:
<div class="page-header mb-3">
<h1>Log In to Djinni</h1>
</div>
Here code of my program:
dr = webdriver.Chrome()
dr.get("https://djinni.co/login")
dr.maximize_window()
header = dr.find_element(By.CLASS_NAME, "page-header mb-3") #NoSuchElementException
print(header.text)
Can anyone tell me what the reason is?
Solution
Simple mistake.
You are looking for the class page-header mb-3 - this is two classes, page-header and mb-3
If you specify either of these classes instead of both it will work.
dr = webdriver.Chrome()
dr.get("https://djinni.co/login")
dr.maximize_window()
header = dr.find_element(By.CLASS_NAME, "page-header") #This works
print(header.text)
Answered By - Pat McGee
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.