Skip to content

Instantly share code, notes, and snippets.

@chukShirley
Last active April 13, 2018 18:06
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 chukShirley/72bcc284cbd8ab7c89e13751d3dc9a98 to your computer and use it in GitHub Desktop.
Save chukShirley/72bcc284cbd8ab7c89e13751d3dc9a98 to your computer and use it in GitHub Desktop.
Behat + Mink wait for modal to be visible
class MyContext extends RawMinkContext
{
private function waitForMyModalToBeVisible()
{
$modalId = 'myModal'
$this->spin(function($context) {
return ($context->getSession()->getPage()->findById($modalId)->isVisible());
});
}
private function spin($lambda)
{
while (true)
{
try {
$var = $lambda($this);
if ($lambda($this)) {
return true;
}
} catch (\Exception $e) {
// do nothing
}
sleep(1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment