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);
}
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);
}
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;
}
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;
}
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");
}
}
Aggregations