Search in sources :

Example 56 with AutomatorException

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

the class SelectMultipleOptionByTextAction method execute.

@Override
protected void execute() throws Exception {
    findElement();
    Select selectElement = new Select(getElement());
    String[] multipleOptions = getTestData().split(",");
    for (int i = 0; i < multipleOptions.length; i++) {
        String multipleText = multipleOptions[i];
        selectOptionByText(selectElement, multipleText);
        selectedTextList.add(multipleText);
    }
    List<WebElement> webElements = selectElement.getAllSelectedOptions();
    if (webElements.size() < multipleOptions.length) {
        List<String> selectedText = new ArrayList<>();
        for (WebElement webElement : webElements) {
            selectedText.add(webElement.getText());
        }
        throw new AutomatorException(String.format(ELEMENTS_MISMATCHED, getTestData(), getFindByType(), getLocatorValue(), selectedText));
    }
    setSuccessMessage(SUCCESS_MESSAGE);
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) Select(org.openqa.selenium.support.ui.Select) ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement)

Example 57 with AutomatorException

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

the class SelectMultipleOptionByValueAction method execute.

@Override
protected void execute() throws Exception {
    findElement();
    Select selectElement = new Select(getElement());
    String[] multipleOptions = getTestData().split(",");
    for (int i = 0; i < multipleOptions.length; i++) {
        String multipleValue = multipleOptions[i];
        selectOptionByValue(selectElement, multipleValue);
        selectedValueList.add(multipleValue);
    }
    List<WebElement> webElements = selectElement.getAllSelectedOptions();
    if (webElements.size() < multipleOptions.length) {
        List<String> selectedValue = new ArrayList<>();
        for (WebElement webElement : webElements) {
            selectedValue.add(webElement.getText());
        }
        throw new AutomatorException(String.format(ELEMENTS_MISMATCHED, getTestData(), getFindByType(), getLocatorValue(), selectedValue));
    }
    setSuccessMessage(SUCCESS_MESSAGE);
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) Select(org.openqa.selenium.support.ui.Select) ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement)

Example 58 with AutomatorException

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

the class StoreCookieNameAction method getAvailableCookieNames.

private List<String> getAvailableCookieNames() throws AutomatorException {
    List<String> cooKieName = new ArrayList<>();
    Set<Cookie> allCookies = getDriver().manage().getCookies();
    if (!allCookies.isEmpty()) {
        for (Cookie cookie : allCookies) {
            cooKieName.add(cookie.getName());
        }
    } else {
        throw new AutomatorException(FAILURE_NO_COOKIES);
    }
    return cooKieName;
}
Also used : Cookie(org.openqa.selenium.Cookie) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) ArrayList(java.util.ArrayList)

Example 59 with AutomatorException

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

the class StoreCookieValueAction method getAvailableCookieNames.

private List<String> getAvailableCookieNames() throws AutomatorException {
    List<String> cooKieName = new ArrayList<>();
    Set<Cookie> allCookies = getDriver().manage().getCookies();
    if (!allCookies.isEmpty()) {
        for (Cookie cookie : allCookies) {
            cooKieName.add(cookie.getName() + "=" + cookie.getValue());
        }
    } else {
        throw new AutomatorException(FAILURE_NO_COOKIES);
    }
    return cooKieName;
}
Also used : Cookie(org.openqa.selenium.Cookie) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) ArrayList(java.util.ArrayList)

Example 60 with AutomatorException

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

the class ClickOnButtonInTheBrowserProxyAction method execute.

@Override
public void execute() throws Exception {
    String button = getTestData();
    switch(button) {
        case ActionConstants.REFRESH:
            ReLoadCurrentPageAction refresh = (ReLoadCurrentPageAction) this.initializeChildSnippet(ReLoadCurrentPageAction.class);
            refresh.execute();
            this.setSuccessMessage(refresh.getSuccessMessage());
            break;
        case ActionConstants.BACK:
            NavigateBackAction back = (NavigateBackAction) this.initializeChildSnippet(NavigateBackAction.class);
            back.execute();
            this.setSuccessMessage(back.getSuccessMessage());
            break;
        case ActionConstants.FORWARD:
            NavigateForwardAction forward = (NavigateForwardAction) this.initializeChildSnippet(NavigateForwardAction.class);
            forward.execute();
            this.setSuccessMessage(forward.getSuccessMessage());
            break;
        default:
            setErrorMessage("Unable to Click on Button in the Browser due to error at test data");
            throw new AutomatorException("Unable to Click on Button in the Browser due to error at test data");
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) NavigateBackAction(com.testsigma.automator.actions.common.NavigateBackAction) NavigateForwardAction(com.testsigma.automator.actions.common.NavigateForwardAction)

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