2

Current scenario is some page needs more time to loading. I want click an element when it was present, But no need wait for whole page load complete. How to fix this problem? Can provide some demo or example?

Thanks a lot.

1 Answers1

0

The driver.get() call is blocking. There is a beta feature in the Firefox driver that could work combined with explicit waits:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


profile = webdriver.FirefoxProfile()
profile.set_preference("webdriver.load.strategy", "unstable")
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)

driver.get("http://somedomain/url_that_delays_loading")
try:
    element = WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.ID,'someid'))
    )
finally:
    driver.quit()
elyase
  • 39,479
  • 12
  • 112
  • 119
  • I just tired your code on "https://www.box.com". Just take "Login" button as example. I want click it when it was present no need waiting page load complete. I just tried the code but the the page still loading after "Login" button present. – Haomin Zeng Sep 15 '14 at 09:54
  • In fact I don't think this method works. It is mainly for setting the waiting-timeout, but the main action (click) will be executed with the same dynamics as if we have just called the find element function. – 5agado Sep 15 '14 at 09:58