Selenium Webdriver - NoSuchElementExceptions Selenium Webdriver - NoSuchElementExceptions selenium selenium

Selenium Webdriver - NoSuchElementExceptions


driver = webdriver.WhatEverBrowser()driver.implicitly_wait(60) # This line will cause it to search for 60 seconds

it only needs to be inserted in your code once ( i usually do it right after creating webdriver object)

for example if your page for some reason takes 30 seconds to load ( buy a new server), and the element is one of the last things to show up on the page, it pretty much just keeps checking over and over and over again if the element is there for 60 seconds, THEN if it doesnt find it, it throws the exception.

also make sure your scope is correct, ie: if you are focused on a frame, and the element you are looking for is NOT in that frame, it will NOT find it.


I see that too. What I do is just wait it out...

you could try:

while True:    try:        x = driver.find_by_name('some_name')        break    except NoSuchElementException:        time.sleep(1)        # possibly use driver.get() again if needed

Also, try updating your selenium to the newest version with pip install --update selenium


I put my money on frame as I had similar issue before :)

Check your html again and check if you are dealing with frame. If it is then switching to correct frame will be able to locate the element.

Python

driver.switch_to_frame("frameName")

Then search for element.

If not, try put wait time as others suggested.