2

I'm running Selenium in Python ide with geckodriver.

The site I'm trying to open has a timer of 30 seconds that after this 30 seconds a button appears and I send a click on it.

What I'm asking is the following: Can I somehow ignore/skip/speed up the waiting time?

Right now what I'm doing is the following:

driver = webdriver.Firefox()
driver.get("SITE_URL")
sleep(30)
driver.find_element_by_id("proceed").click()

Which is very inefficient because every time I run the code to do some tests I need to wait.

Thanks in advance, Avi.

UPDATE: I haven't found a way to get over the obstacle but until I do I'm trying to focus the next achievable progress:

<video class="jw-video jw-reset" disableremoteplayback="" webkit-playsinline="" playsinline="" preload="metadata" src="//SITE.SITE.SITE/SITE/480/213925.mp4?token=jbavPPLqNqkQT1SEUt4crg&amp;time=1525458550" style="object-fit: fill;"></video>

(censored site's name)

In each page there is a video, all the videos are under the class "jw-video jw-reset" I had trouble using find element by class so I used:

WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "video[class='jw-video jw-reset']")))

It works but I can't figure how to select the element's src...

1
  • 1
    Well obviously you have to find out how the website does the 30 second delay and find out how to influence it. It's not going to happen in your code... Commented May 4, 2018 at 6:37

1 Answer 1

4

As per your code trial you can remove the time.sleep(30) and induce WebDriverWait for the element to be clickable as follows :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
# lines of code
WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.ID, "proceed"))).click()

Note : Configure the WebDriverWait instance with the maximum time limit as per your usecase. The expected_conditions method element_to_be_clickable() will return the WebElement as soon as the element is visible and enabled such that you can click it.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! WebDriverWait is very helpful!

Your Answer

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.