0

I am learning selenum with python and the explicit wait method doesn't work to click on the 'accept cookies' button. Otherwise, the time.sleep method work and I would like to understant why the explicit wait method doersn't work. I typed this code : (sorry for my bad english, I'm french...)

driver.get("https://demo.guru99.com/test/newtours/")
driver.maximize_window()
WebDriverWait(driver, 30).until(EC.frame_to_be_available_and_switch_to_it((By.ID, "gdpr-consent-notice")))
WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="save"]/span[1]/div/span'))).click()
asked Feb 7, 2022 at 13:51
9
  • Hello every one ! :) Commented Feb 7, 2022 at 13:56
  • What do mean by "doesn't work"? What are trying to achieve and what issue are going through? Commented Feb 7, 2022 at 15:38
  • To click to the accept cookies button we need to do a switch to frame before. The problème is theWebDriverWait in the second assertion The following code work : Commented Feb 7, 2022 at 17:35
  • WebDriverWait(driver, 30).until(EC.frame_to_be_available_and_switch_to_it((By.ID, "gdpr-consent-notice"))) Commented Feb 7, 2022 at 17:38
  • time.sleep(1) Commented Feb 7, 2022 at 17:41

1 Answer 1

1

Why do you want to use the explicit wait? Selenium by default has a timeout when you use findelement, that I think it's about 10 seconds. If you want to know more about this issue, I found that website(blog). https://blog.devgenius.io/browser-automation-with-python-and-selenium-5-waits-4b9e4636548c or that other https://selenium-python.readthedocs.io/waits.html

answered Mar 17, 2022 at 13:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.