use of com.axway.ats.uiengine.exceptions.VerificationException in project ats-framework by Axway.
the class AbstractRealBrowserDriver method handleExpectedPopups.
/**
* <b>Note:</b> For internal use only
*/
public void handleExpectedPopups() {
while (!expectedPopupsQueue.isEmpty()) {
IExpectedPopup expectedPopup = expectedPopupsQueue.poll();
if (expectedPopup instanceof ExpectedAlert) {
ExpectedAlert expectedAlert = (ExpectedAlert) expectedPopup;
new RealHtmlElementState(new RealHtmlAlert(this)).waitToBecomeExisting();
Alert alert = getAlert();
if (expectedAlert.expectedText != null && !expectedAlert.expectedText.equals(alert.getText())) {
throw new VerificationException("The expected alert message was: '" + expectedAlert.expectedText + "', but actually it is: '" + alert.getText() + "'");
}
alert.accept();
} else if (expectedPopup instanceof ExpectedPrompt) {
ExpectedPrompt expectedPrompt = (ExpectedPrompt) expectedPopup;
new RealHtmlElementState(new RealHtmlPrompt(this)).waitToBecomeExisting();
Alert prompt = getAlert();
if (expectedPrompt.expectedText != null && !expectedPrompt.expectedText.equals(prompt.getText())) {
throw new VerificationException("The expected prompt text was: '" + expectedPrompt.expectedText + "', but actually it is: '" + prompt.getText() + "'");
}
if (expectedPrompt.clickOk) {
prompt.sendKeys(expectedPrompt.promptValueToSet);
prompt.accept();
} else {
prompt.dismiss();
}
} else if (expectedPopup instanceof ExpectedConfirm) {
ExpectedConfirm expectedConfirm = (ExpectedConfirm) expectedPopup;
new RealHtmlElementState(new RealHtmlConfirm(this)).waitToBecomeExisting();
Alert confirm = getAlert();
if (expectedConfirm.expectedText != null && !expectedConfirm.expectedText.equals(confirm.getText())) {
throw new VerificationException("The expected confirmation message was: '" + expectedConfirm.expectedText + "', but actually it is: '" + confirm.getText() + "'");
}
if (expectedConfirm.clickOk) {
confirm.accept();
} else {
confirm.dismiss();
}
}
UiEngineUtilities.sleep();
}
}
use of com.axway.ats.uiengine.exceptions.VerificationException in project ats-framework by Axway.
the class MobileElement method clickIfExists.
// public T click() {
//
// new MobileElementState( this ).waitToBecomeExisting();
//
// try {
// try {
// MobileElementFinder.findElement( appiumDriver, this ).click();
// } catch( ElementNotVisibleException enve ) { // element is not currently visible and may not be manipulated
//
// new MobileElementState( this ).waitToBecomeDisplayed();
// MobileElementFinder.findElement( appiumDriver, this ).click();
// }
// return ( T ) this;
// } catch( Exception e ) {
// throw new MobileOperationException( this, "click", e );
// }
// }
/**
* Click/tap the element if exists.
*
* @param waitingTimeout timeout in milliseconds to wait for the element to appear
*/
@PublicAtsApi
public boolean clickIfExists(int waitingTimeout) {
int currentStateChangeDelay = UiEngineConfigurator.getInstance().getElementStateChangeDelay();
try {
UiEngineConfigurator.getInstance().setElementStateChangeDelay(waitingTimeout);
appiumDriver.manage().timeouts().implicitlyWait(waitingTimeout, TimeUnit.MILLISECONDS);
long endTime = System.currentTimeMillis() + waitingTimeout;
new MobileElementState(this).waitToBecomeExisting();
// the element exists but may be still not clickable
do {
try {
MobileElementFinder.findElement(appiumDriver, this).click();
return true;
} catch (Exception e) {
}
UiEngineUtilities.sleep(500);
} while (endTime - System.currentTimeMillis() > 0);
} catch (VerificationException ve) {
// do nothing, the element doesn't exist
} finally {
UiEngineConfigurator.getInstance().setElementStateChangeDelay(currentStateChangeDelay);
appiumDriver.manage().timeouts().implicitlyWait(currentStateChangeDelay, TimeUnit.MILLISECONDS);
}
return false;
}
use of com.axway.ats.uiengine.exceptions.VerificationException in project ats-framework by Axway.
the class HiddenHtmlConfirm method clickOk.
@Override
@PublicAtsApi
public void clickOk(final String expectedConfirmText) {
isProcessed = false;
webClient.setConfirmHandler(new ConfirmHandler() {
@Override
public boolean handleConfirm(Page currentPage, String confirmationText) {
isProcessed = true;
if (!confirmationText.equals(expectedConfirmText)) {
throw new VerificationException("The expected confirm message was: '" + expectedConfirmText + "', but actually it is: '" + confirmationText + "'");
}
return true;
}
});
}
use of com.axway.ats.uiengine.exceptions.VerificationException in project ats-framework by Axway.
the class HiddenHtmlPrompt method clickCancel.
@Override
@PublicAtsApi
public void clickCancel(final String expectedText) {
isProcessed = false;
webClient.setPromptHandler(new PromptHandler() {
@Override
public String handlePrompt(Page currentPage, String promptText, String defaultValue) {
isProcessed = true;
if (!promptText.equals(expectedText)) {
throw new VerificationException("The expected prompt text was: '" + expectedText + "', but actually it is: '" + promptText + "'");
}
return null;
}
});
}
use of com.axway.ats.uiengine.exceptions.VerificationException in project ats-framework by Axway.
the class HiddenHtmlConfirm method clickCancel.
@Override
@PublicAtsApi
public void clickCancel(final String expectedConfirmText) {
isProcessed = false;
webClient.setConfirmHandler(new ConfirmHandler() {
@Override
public boolean handleConfirm(Page currentPage, String confirmationText) {
isProcessed = true;
if (!confirmationText.equals(expectedConfirmText)) {
throw new VerificationException("The expected confirm message was: '" + expectedConfirmText + "', but actually it is: '" + confirmationText + "'");
}
return false;
}
});
}
Aggregations