Skip to content

Instantly share code, notes, and snippets.

  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Selenium webdriver wait for ajax with Python
from selenium import webdriver
from import WebDriverWait
from selenium.common.exceptions import WebDriverException
def ajax_complete(driver):
return 0 == driver.execute_script("return")
except WebDriverException:
def my_automation_test():
ff_driver = webdriver.Firefox()
#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
Copy link

hl2055 commented Aug 29, 2017

I think it's better to use return not driver.execute_script("return jQuery &&") instead of passing exception.

Copy link

formynet commented Oct 9, 2017


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment