ElementNotVisible Exception in Selenium
In Selenium, different methods can be used to reference an element. These include finding elements by username, id, xpath, etc.
However, if Selenium cannot find the element referenced, it returns the following error:
ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
Solution
The following solutions can be tried to ensure that the problem is solved.
- This error may occur if selenium starts finding the element before the page is loaded. Sleep will not work since every device requires a different amount of time to load the webpage. The easiest way to resolve this is to use the following.
// Wait until an element with id password appears
password = WebDriverWait(driver, 3).until(EC.visibility_of_element_located((By.id, "password")))
- Another reason could be that javascript embedded
fakeelements that can’t be detected by selenium. To solve this use the following.
driver.execute_script("document.querySelectorAll('label.boxed')[2].click()")
This code will select the second object in an array of objects and click on it.
- Another solution could be finding the element immediately before the target element. Then, press the tab to move onto the next element.
//find the element preceding the target element
username = br.find_element_by_name("username")
// use tab to move to the next hidden element.
username.send_keys(Keys.TAB)
//now you can send your password
username.send_keys("your password")
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved