Skip to content

Commit

Permalink
test createsurveytest
Browse files Browse the repository at this point in the history
  • Loading branch information
TonisOrmisson committed Dec 30, 2017
1 parent 49c806c commit 67131d1
Show file tree
Hide file tree
Showing 3 changed files with 226 additions and 243 deletions.
6 changes: 1 addition & 5 deletions tests/TestBaseClassView.php
Expand Up @@ -62,11 +62,7 @@ protected function findViewTag($name, $view)
$filename = self::$screenshotsFolder. '/'.$name.'.png';
$element = null;
try {
$element = self::$webDriver->wait(2)->until(
WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(
WebDriverBy::id('action::' . $name)
)
);
$element = self::find(WebDriverBy::id('action::' . $name));
} catch (\Exception $e) {
//throw new Exception($e->getMessage());
$screenshot = self::$webDriver->takeScreenshot();
Expand Down
47 changes: 47 additions & 0 deletions tests/TestBaseClassWeb.php
Expand Up @@ -233,4 +233,51 @@ protected static function deleteLoginTimeout()
->createCommand('DELETE FROM {{failed_login_attempts}}')
->execute();
}

/**
* @param WebDriverBy $selector
* @param int $waitSecondsUntil
* @return mixed
* @throws \Exception
*/
protected static function findAndClick($selector,$waitSecondsUntil = 2){
try {
$clickable = self::$webDriver->wait($waitSecondsUntil)->until(
WebDriverExpectedCondition::elementToBeClickable($selector)
);
$clickable->click();
sleep(1);

$screenshot = self::$webDriver->takeScreenshot();
$filename = self::$screenshotsFolder .'/'.time().microtime().'_AfterGoodClick.png';
file_put_contents($filename, $screenshot);
return $clickable;
} catch (\Exception $ex) {
$screenshot = self::$webDriver->takeScreenshot();
$filename = self::$screenshotsFolder .'/'.time().microtime().'_FailedClic.png';
file_put_contents($filename, $screenshot);
}

}

/**
* @param WebDriverBy $selector
* @param int $waitSecondsUntil
* @return mixed
* @throws \Exception
*/
protected static function find($selector,$waitSecondsUntil = 1){
try {
$element = self::$webDriver->wait($waitSecondsUntil)->until(
WebDriverExpectedCondition::presenceOfElementLocated($selector)
);
return $element;
} catch (\Exception $ex) {
$screenshot = self::$webDriver->takeScreenshot();
$filename = self::$screenshotsFolder .'/'.time().microtime().'_FailedFindElement.png';
file_put_contents($filename, $screenshot);
throw $ex;
}

}
}

0 comments on commit 67131d1

Please sign in to comment.