I have been programming a bot using Selenium to automate a tutorial series my school forces me to do. In this tutorial there is one video which halfway through prompts the user with a form and some questions. I have been attempting to use this code to wait while the video plays and until the form is visible
WebDriverWait(driver, 1000).until(
EC.presence_of_element_located((By.ID, "answer_content_A11A59DC-2C74-11EE-83FC-C435C68A4852"))
)
This ID is NOT visible at the start of the video, BUT once the form appears can be found. However, the script never gets past the WebDriverWait() block.
I have also tried waiting based on the prescence of other elements but they seem to bring up the same problem. Each time they get stuck on WebDriverWait().
Then I tried just waiting 30 seconds for the form to become visible, but this didn’t work either.
#Presses Play on Video
driver.find_element(By.CLASS_NAME, "slip_button_icon").click()
#Full duration of Video
time.sleep(30)
driver.find_element(By.ID, "answer_content_A11A59DC-2C74-11EE-83FC-C435C68A4852").click()
This error comes up even though when I command F the ID in my Selenium browser I am able to locate it.
An error occurred: Message: no such element: Unable to locate element: {“method”:”css selector”,”selector”:”[id=”answer_content_A11A59DC-2C74-11EE-83FC-C435C68A4852″]”}
(Session info: chrome=127.0.6533.72); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Aidan Rooney is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.