public function waitForElementUntilIsNotPresent(By $locator, $timeOutSeconds = 5) { for ($second = 0;; $second++) { if ($second >= $timeOutSeconds) { return false; } $result = $this->findElement($locator, true) === null; if ($result) { return true; } sleep(1); } return false; }