use of com.sebuilder.interpreter.Verify in project Asqatasun by Asqatasun.
the class TgTestRun method next.
/**
* Executes the next step.
*
* @return True on success.
*/
@Override
public boolean next() {
if (stepIndex == -1) {
getLog().debug("Starting test run.");
}
initRemoteWebDriver();
isStepOpenNewPage = false;
getLog().debug("Running step " + (stepIndex + 2) + ":" + getScript().steps.get(stepIndex + 1).type.toString() + " step.");
boolean result = false;
String previousUrl = null;
try {
previousUrl = getDriver().getCurrentUrl();
result = getScript().steps.get(++stepIndex).type.run(this);
// wait a second to make sure the page is fully loaded
Thread.sleep(500);
if (!isStepOpenNewPage && !StringUtils.equals(previousUrl, getDriver().getCurrentUrl())) {
fireNewPage();
}
} catch (TimeoutException te) {
result = true;
if (!isStepOpenNewPage && !StringUtils.equals(previousUrl, getDriver().getCurrentUrl())) {
getLog().debug(" The page " + getDriver().getCurrentUrl() + " is fired as new page but" + " is incomplete : " + te.getMessage());
fireNewPage();
}
} catch (UnhandledAlertException uae) {
getLog().warn(uae.getMessage());
properlyCloseWebDriver();
throw new TestRunException(currentStep() + " failed.", uae, currentStep().toString(), stepIndex);
} catch (Exception e) {
getLog().warn(e.getCause());
getLog().warn(e.getMessage());
properlyCloseWebDriver();
throw new TestRunException(currentStep() + " failed.", e, currentStep().toString(), stepIndex);
}
if (!result) {
// If a verify failed, we just note this but continue.
if (currentStep().type instanceof Verify) {
getLog().error(currentStep() + " failed.");
return false;
}
// In all other cases, we throw an exception to stop the run.
RuntimeException e = new TestRunException(currentStep() + " failed.", currentStep().toString(), stepIndex);
e.fillInStackTrace();
getLog().error(e);
properlyCloseWebDriver();
throw e;
} else {
return true;
}
}
Aggregations