I hope this question is unique and will help also other testers.
I need the solution for python selenium.
I need to replace several time.sleep()
lines of code, by time explicit waits.
When Chrome sleeps for few seconds before every element which is expected to be clicked, the test runs successfully, without, it fails.
So it goes like this:
driver.find_element_by_xpath("x").click()
time.sleep(5)
driver.find_element_by_xpath("y").click()
time.sleep(5)
driver.find_element_by_xpath("z").click()
time.sleep(5)
...
Implicity wait is not enough, for sure.
Here is the recommended code:
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.ID, 'someid')))
I look at this example code, but it seems that I must refer to every single ID, in my case several times.
So the question is:
Is there any global solution to use explicit wait for every element in script, without multiplying lines of code?