Skip to content

Instantly share code, notes, and snippets.

@danteoh
Last active December 18, 2015 05:28
Show Gist options
  • Save danteoh/5732414 to your computer and use it in GitHub Desktop.
Save danteoh/5732414 to your computer and use it in GitHub Desktop.
$timeToFail = time() + $this->config['time_tolerance'];
$el = null;
while(!$this->timeToleranceReached($timeToFail) && !$el){
$page = $this->session->getPage();
$el = null;
try {
\Symfony\Component\CssSelector\CssSelector::toXPath($selector);
$el = $page->find('css', $selector);
} catch (\Symfony\Component\CssSelector\Exception\ParseException $e) {}
try {
if (!$el) $el = @$page->find('xpath',$selector);
} catch (\Exception $e) {
}
}
if (!$el) \PHPUnit_Framework_Assert::fail("CSS or XPath for '$selector' not found'");
return $el;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment