Created
February 17, 2016 17:32
-
-
Save phpdave/9027afec42ad7a87480b to your computer and use it in GitHub Desktop.
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
<?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