0

How to wait for ajax load before performing any activity in selenium webdriver? I have a form where i fill form fields through my script and click on a button and next form is opened and few fields get prepopulated from the last form i filled, i want to wait on that form so that the form gets filled and after that my next script runs ie until my ajax loads. I am using java.

I think Wait Until is used but i am not sure how to use this. Or if there is some other solution kindly suggest..

himanshu
  • 1
  • 2
  • you can check [this](http://stackoverflow.com/questions/14498355/selenium-ajax-wait-if-ajax-returns-no-elements), [this](http://lifegoeasy.blogspot.in/2014/01/selenium-webdriver-how-to-handle-ajax.html) or [this](http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp) for info on wait. – Amith Mar 25 '14 at 05:40

1 Answers1

0

You can use the waitForCondition method as explained in this post.

Ultimately you'll end up with a timeout or your test may never complete. For example:

public void waitForJQuery() {
    WebDriverBackedSelenium webDriverBackedSelenium = new WebDriverBackedSelenium(driver, driver.getCurrentUrl());
    webDriverBackedSelenium.waitForCondition("(typeof(sjq)==='undefined') || sjq.active == 0", JAVASCRIPT_TIMEOUT);
}
Community
  • 1
  • 1
radimpe
  • 3,197
  • 2
  • 27
  • 46