Skip to content

Instantly share code, notes, and snippets.

@phpdave
Created February 17, 2016 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpdave/9027afec42ad7a87480b to your computer and use it in GitHub Desktop.
Save phpdave/9027afec42ad7a87480b to your computer and use it in GitHub Desktop.
<?php
/*before this is all your code that is doing things to the browser and perhaps submitting some data via ajax*/
//Lets make the webdriver wait for the ajax call
$webdriverWait = new WebDriverWait($driver, 10);
$webdriverWait->until(
//pass in our closure
function($driver)
{
echo 'loop...';
try
{
//Wait for jQuery to be done processing ajax request
$result = (0 === count($driver->executeScript("return jQuery.active == 0")));
}
catch (\Exception $ex) {
//catch an exception when execScript is called when an alert box is open.
//the Facebook driver will automatically handle closing the alert box
//return true so we can break out of the loop, and
$result = true;
}
return $result;
}
);
/*continue with your script*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment