Last active
April 13, 2018 18:06
-
-
Save chukShirley/72bcc284cbd8ab7c89e13751d3dc9a98 to your computer and use it in GitHub Desktop.
Behat + Mink wait for modal to be visible
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
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