Created
December 10, 2015 06:05
-
-
Save algotrader-dotcom/60a591867e6783ba21f5 to your computer and use it in GitHub Desktop.
Selenium webdriver wait for ajax with Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.common.exceptions import WebDriverException | |
def ajax_complete(driver): | |
try: | |
return 0 == driver.execute_script("return jQuery.active") | |
except WebDriverException: | |
pass | |
def my_automation_test(): | |
ff_driver = webdriver.Firefox() | |
ff_driver.get("http://domain.tld") | |
#wait for ajax items to load | |
WebDriverWait(ff_driver, 10).until( | |
ajax_complete, "Timeout waiting for page to load") | |
assert "ajax loaded string" in ff_driver.page_source |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why?