Search in sources :

Example 1 with VerificationException

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();
    }
}
Also used : RealHtmlElementState(com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState) RealHtmlAlert(com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlAlert) ExpectedConfirm(com.axway.ats.uiengine.internal.realbrowser.ExpectedConfirm) RealHtmlConfirm(com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlConfirm) ExpectedAlert(com.axway.ats.uiengine.internal.realbrowser.ExpectedAlert) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) IExpectedPopup(com.axway.ats.uiengine.internal.realbrowser.IExpectedPopup) ExpectedAlert(com.axway.ats.uiengine.internal.realbrowser.ExpectedAlert) Alert(org.openqa.selenium.Alert) RealHtmlAlert(com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlAlert) RealHtmlPrompt(com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlPrompt) ExpectedPrompt(com.axway.ats.uiengine.internal.realbrowser.ExpectedPrompt)

Example 2 with VerificationException

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;
}
Also used : VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) MobileElementState(com.axway.ats.uiengine.utilities.mobile.MobileElementState) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 3 with VerificationException

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;
        }
    });
}
Also used : ConfirmHandler(com.gargoylesoftware.htmlunit.ConfirmHandler) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) Page(com.gargoylesoftware.htmlunit.Page) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 4 with VerificationException

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;
        }
    });
}
Also used : VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) Page(com.gargoylesoftware.htmlunit.Page) PromptHandler(com.gargoylesoftware.htmlunit.PromptHandler) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 5 with VerificationException

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;
        }
    });
}
Also used : ConfirmHandler(com.gargoylesoftware.htmlunit.ConfirmHandler) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) Page(com.gargoylesoftware.htmlunit.Page) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)18 PublicAtsApi (com.axway.ats.common.PublicAtsApi)17 UiElementException (com.axway.ats.uiengine.exceptions.UiElementException)12 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)12 NotSupportedOperationException (com.axway.ats.uiengine.exceptions.NotSupportedOperationException)10 VerifyEqualityException (com.axway.ats.uiengine.exceptions.VerifyEqualityException)10 VerifyNotEqualityException (com.axway.ats.uiengine.exceptions.VerifyNotEqualityException)10 JTableFixture (org.fest.swing.fixture.JTableFixture)10 TableCell (org.fest.swing.data.TableCell)6 Page (com.gargoylesoftware.htmlunit.Page)4 ConfirmHandler (com.gargoylesoftware.htmlunit.ConfirmHandler)2 JTabbedPaneFixture (org.fest.swing.fixture.JTabbedPaneFixture)2 JTableHeaderFixture (org.fest.swing.fixture.JTableHeaderFixture)2 UiElementProperties (com.axway.ats.uiengine.elements.UiElementProperties)1 RealHtmlAlert (com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlAlert)1 RealHtmlConfirm (com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlConfirm)1 RealHtmlPrompt (com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlPrompt)1 MobileOperationException (com.axway.ats.uiengine.exceptions.MobileOperationException)1 ExpectedAlert (com.axway.ats.uiengine.internal.realbrowser.ExpectedAlert)1 ExpectedConfirm (com.axway.ats.uiengine.internal.realbrowser.ExpectedConfirm)1