Search in sources :

Example 1 with AutomatorException

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

the class ScrollInsideElementToBottomAction method execute.

@Override
public void execute() throws Exception {
    findElement();
    try {
        WebElement webElement = getElement();
        JavascriptExecutor js = (JavascriptExecutor) getDriver();
        js.executeScript("arguments[0].scrollTo(0,arguments[0].scrollHeight);", webElement);
    } catch (Exception e) {
        log.error("unable to sctoll inside an element", e);
        throw new AutomatorException(String.format(FAILURE_MESSAGE, getFindByType(), getLocatorValue()));
    }
    setSuccessMessage(SUCCESS_MESSAGE);
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) WebElement(org.openqa.selenium.WebElement) AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Example 2 with AutomatorException

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

the class SelectMultipleOptionByIndexAction method execute.

@Override
protected void execute() throws Exception {
    findElement();
    Select selectElement = new Select(getElement());
    List<Integer> multipleOptions = getIntegerArray();
    for (int i = 0; i < multipleOptions.size(); i++) {
        Integer multipleValue = multipleOptions.get(i);
        selectByIndex(selectElement, multipleValue);
        selectedIndexList.add(multipleValue);
    }
    List<WebElement> webElements = selectElement.getAllSelectedOptions();
    if (webElements.size() < multipleOptions.size()) {
        List<String> selectedIndex = new ArrayList<>();
        for (WebElement webElement : webElements) {
            selectedIndex.add(webElement.getText());
        }
        throw new AutomatorException(String.format(ELEMENTS_MISMATCHED, getTestData(), getFindByType(), getLocatorValue(), selectedIndex));
    }
    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 3 with AutomatorException

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

the class SelectOptionByIndexAction method execute.

@Override
protected void execute() throws Exception {
    findElement();
    Select selectElement = new Select(getElement());
    try {
        selectElement.selectByIndex(NumberFormatter.getIntegerValue(getTestData(), String.format(ELEMENT_IS_NOT_A_NUMBER, getTestData())));
        setSuccessMessage(SUCCESS_MESSAGE);
    } catch (Exception e) {
        throw new AutomatorException(String.format(FAILURE_MESSAGE, getTestData(), getFindByType(), getLocatorValue(), getTestData()));
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) Select(org.openqa.selenium.support.ui.Select) AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Example 4 with AutomatorException

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

the class SelectOptionByValueAction method execute.

@Override
protected void execute() throws Exception {
    findElement();
    Select selectElement = new Select(getElement());
    try {
        selectElement.selectByValue(getTestData());
        setSuccessMessage(SUCCESS_MESSAGE);
    } catch (NoSuchElementException e) {
        throw new AutomatorException(String.format(FAILURE_MESSAGE, getTestData(), getFindByType(), getLocatorValue(), getTestData()));
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) Select(org.openqa.selenium.support.ui.Select) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 5 with AutomatorException

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

the class SelectOptionByVisibleTextAction method execute.

@Override
protected void execute() throws Exception {
    try {
        findElement();
        Select selectElement = new Select(getElement());
        selectElement.selectByVisibleText(getTestData());
        setSuccessMessage(SUCCESS_MESSAGE);
    } catch (NoSuchElementException e) {
        throw new AutomatorException(String.format(FAILURE_MESSAGE, getTestData(), getFindByType(), getLocatorValue(), getTestData()));
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) Select(org.openqa.selenium.support.ui.Select) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

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