Search in sources :

Example 31 with AutomatorException

use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.

the class WaitUntilAllImagesAreLoadedAction method execute.

@Override
public void execute() throws Exception {
    try {
        List<WebElement> elements = getWebDriverWait().until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//img")));
        Assert.notNull(elements, FAILURE_MESSAGE);
        setSuccessMessage(SUCCESS_MESSAGE);
    } catch (TimeoutException e) {
        throw new AutomatorException(FAILURE_MESSAGE, (Exception) e.getCause());
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) WebElement(org.openqa.selenium.WebElement) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 32 with AutomatorException

use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.

the class CheckboxElementStatusAction method execute.

@Override
public void execute() throws Exception {
    String status = getTestData();
    switch(status) {
        case ActionConstants.CHECKED:
            VerifySwitchEnabledAction enable = (VerifySwitchEnabledAction) this.initializeChildSnippet(VerifySwitchEnabledAction.class);
            enable.execute();
            this.setSuccessMessage(enable.getSuccessMessage());
            break;
        case ActionConstants.UN_CHECKED:
            VerifySwitchDisabledAction disable = (VerifySwitchDisabledAction) this.initializeChildSnippet(VerifySwitchDisabledAction.class);
            disable.execute();
            this.setSuccessMessage(disable.getSuccessMessage());
            break;
        default:
            setErrorMessage("Unable to Perform Verify Switch Status Action due to error at test data");
            throw new AutomatorException("Unable to Perform Verify Switch Status Action due to error at test data");
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) VerifySwitchDisabledAction(com.testsigma.automator.actions.mobile.ios.verify.VerifySwitchDisabledAction) VerifySwitchEnabledAction(com.testsigma.automator.actions.mobile.ios.verify.VerifySwitchEnabledAction)

Example 33 with AutomatorException

use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.

the class MobileNativeVerifyCheckedAction method execute.

@Override
public void execute() throws Exception {
    findElement();
    WebElement targetElement = getElement();
    String checkable = targetElement.getAttribute(CHECKABLE);
    String checked = targetElement.getAttribute(CHECKED);
    if (checkable.equals(TRUE)) {
        if (!checked.equals(TRUE)) {
            throw new AutomatorException(String.format("The element corresponding to the locator <b>\"%s:%s\"</b> is not in checked" + " state", getElementSearchCriteria().getFindByType(), getElementSearchCriteria().getByValue()));
        } else {
            log.info("The target element state is already checked, hence no action performed to uncheck.");
        }
    } else {
        throw new AutomatorException(String.format(ELEMENT_IS_NOT_CHECKBLE, getFindByType(), getLocatorValue()));
    }
    setSuccessMessage(SUCCESS_MESSAGE);
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) WebElement(org.openqa.selenium.WebElement)

Example 34 with AutomatorException

use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.

the class MobileNativeVerifyUnCheckedAction method execute.

@Override
public void execute() throws Exception {
    findElement();
    WebElement targetElement = getElement();
    String checkable = targetElement.getAttribute(CHECKABLE);
    String checked = targetElement.getAttribute(CHECKED);
    if (checkable.equals(TRUE)) {
        if (checked.equals(TRUE)) {
            throw new AutomatorException(String.format("The element corresponding to the locator <b>\"%s:%s\"</b> is not in " + "unchecked state", getElementSearchCriteria().getFindByType(), getElementSearchCriteria().getByValue()));
        } else {
            log.info("The target element state is already Unchecked, hence no action performed to check.");
        }
    } else {
        throw new AutomatorException(String.format(ELEMENT_IS_NOT_CHECKBLE, getFindByType(), getLocatorValue()));
    }
    setSuccessMessage(SUCCESS_MESSAGE);
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) WebElement(org.openqa.selenium.WebElement)

Example 35 with AutomatorException

use of com.testsigma.automator.exceptions.AutomatorException in project testsigma by testsigmahq.

the class AlertVisibilityStatusAction method execute.

@Override
public void execute() throws Exception {
    String status = getTestData();
    switch(status) {
        case ActionConstants.NOT_VISIBLE:
            VerifyAlertAbsentAction absence = (VerifyAlertAbsentAction) this.initializeChildSnippet(VerifyAlertAbsentAction.class);
            absence.execute();
            this.setSuccessMessage(absence.getSuccessMessage());
            break;
        case ActionConstants.VISIBLE:
            VerifyAlertPresentAction available = (VerifyAlertPresentAction) this.initializeChildSnippet(VerifyAlertPresentAction.class);
            available.execute();
            this.setSuccessMessage(available.getSuccessMessage());
            break;
        default:
            setErrorMessage("Unable to Perform Verify Alert Status Action due to error at test data");
            throw new AutomatorException("Unable to Perform Verify Alert Status due to error at test data");
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) VerifyAlertPresentAction(com.testsigma.automator.actions.mobile.mobileweb.verify.VerifyAlertPresentAction) VerifyAlertAbsentAction(com.testsigma.automator.actions.mobile.mobileweb.verify.VerifyAlertAbsentAction)

Aggregations

AutomatorException (com.testsigma.automator.exceptions.AutomatorException)119 TimeoutException (org.openqa.selenium.TimeoutException)31 WebElement (org.openqa.selenium.WebElement)19 IOException (java.io.IOException)12 ArrayList (java.util.ArrayList)9 Select (org.openqa.selenium.support.ui.Select)6 TestsigmaException (com.testsigma.agent.exception.TestsigmaException)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 RuntimeDataProvider (com.testsigma.automator.utilities.RuntimeDataProvider)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Map (java.util.Map)3 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)3 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)3 PathNotFoundException (com.jayway.jsonpath.PathNotFoundException)2 ElementNotDisplayedException (com.testsigma.automator.actions.exceptions.ElementNotDisplayedException)2 MobileApp (com.testsigma.automator.mobile.MobileApp)2 ObjectMapperService (com.testsigma.automator.service.ObjectMapperService)2 ErrorUtil (com.testsigma.automator.utilities.ErrorUtil)2 File (java.io.File)2 MalformedURLException (java.net.MalformedURLException)2