Skip to content

Instantly share code, notes, and snippets.

@oziks
Created February 6, 2014 10:31
Show Gist options
  • Save oziks/8841798 to your computer and use it in GitHub Desktop.
Save oziks/8841798 to your computer and use it in GitHub Desktop.
<?php
namespace FeatureContext\Page;
use SensioLabs\Behat\PageObjectExtension\PageObject\Page;
class BasePage extends Page
{
/**
* Try until
*
* @param callable $lambda lambda method
* @param int $timeout Timeout second
*
* @return mixed
*/
public function tryUntil($lambda, $timeout = 30)
{
for ($i = 0; $i < $timeout; $i++) {
try {
return $lambda($this);
} catch (\Exception $e) {
if ($timeout == $i) {
throw $e;
}
}
sleep(1);
}
}
....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment