use of org.openqa.selenium.NoSuchElementException in project cerberus-source by cerberustesting.
the class WebDriverService method doSeleniumActionType.
@Override
public MessageEvent doSeleniumActionType(Session session, Identifier identifier, String valueToType, String propertyName, boolean waitForVisibility, boolean waitForClickability) {
MessageEvent message;
try {
AnswerItem answer = this.getSeleniumElement(session, identifier, waitForVisibility, waitForClickability);
if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) {
WebElement webElement = (WebElement) answer.getItem();
if (webElement != null) {
webElement.clear();
if (!StringUtil.isNull(valueToType)) {
webElement.sendKeys(valueToType);
}
message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_TYPE);
message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));
if (!StringUtil.isNull(valueToType)) {
message.setDescription(message.getDescription().replace("%DATA%", ParameterParserUtil.securePassword(valueToType, propertyName)));
} else {
message.setDescription(message.getDescription().replace("%DATA%", "No property"));
}
return message;
}
}
return answer.getResultMessage();
} catch (NoSuchElementException exception) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_TYPE_NO_SUCH_ELEMENT);
message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));
LOG.debug(exception.toString());
return message;
} catch (TimeoutException exception) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_TIMEOUT);
message.setDescription(message.getDescription().replace("%TIMEOUT%", String.valueOf(session.getCerberus_selenium_wait_element())));
LOG.warn(exception.toString());
return message;
} catch (WebDriverException exception) {
LOG.warn(exception.toString());
return parseWebDriverException(exception);
}
}
use of org.openqa.selenium.NoSuchElementException in project cerberus-source by cerberustesting.
the class ControlService method verifyElementInElement.
private MessageEvent verifyElementInElement(TestCaseExecution tCExecution, String element, String childElement) {
if (LOG.isDebugEnabled()) {
LOG.debug("Control : verifyElementInElement on : '" + element + "' is child of '" + childElement + "'");
}
MessageEvent mes;
if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI) || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)) {
if (!StringUtil.isNull(element) && !StringUtil.isNull(childElement)) {
try {
Identifier identifier = identifierService.convertStringToIdentifier(element);
Identifier childIdentifier = identifierService.convertStringToIdentifier(childElement);
if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {
if (this.webdriverService.isElementInElement(tCExecution.getSession(), identifier, childIdentifier)) {
mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTINELEMENT);
mes.resolveDescription("STRING2", element);
mes.resolveDescription("STRING1", childElement);
return mes;
} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTINELEMENT);
mes.resolveDescription("STRING2", element);
mes.resolveDescription("STRING1", childElement);
return mes;
}
} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NO_SUCH_ELEMENT);
mes.resolveDescription("SELEX", new NoSuchElementException("").toString());
mes.resolveDescription("ELEMENT", element);
return mes;
}
} catch (WebDriverException exception) {
return parseWebDriverException(exception);
}
} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTINELEMENT);
mes.resolveDescription("STRING2", element);
mes.resolveDescription("STRING1", childElement);
return mes;
}
} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
mes.resolveDescription("CONTROL", "verifyElementInElement");
mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());
return mes;
}
}
use of org.openqa.selenium.NoSuchElementException in project cerberus-source by cerberustesting.
the class AppiumService method clearField.
@Override
public MessageEvent clearField(final Session session, final Identifier identifier) {
try {
final TouchAction action = new TouchAction(session.getAppiumDriver());
if (identifier.isSameIdentifier(Identifier.Identifiers.COORDINATE)) {
final Coordinates coordinates = getCoordinates(identifier);
click(session, identifier);
} else {
click(session, identifier);
// action.press(ElementOption.element(getElement(session, identifier, false, false))).waitAction(WaitOptions.waitOptions(Duration.ofMillis(8000))).release().perform();
// MobileElement element = (MobileElement) session.getAppiumDriver().findElementByAccessibilityId("SomeAccessibilityID");
// element.clear();
// WebElement elmt = this.getElement(session, identifier, false, false);
this.getElement(session, identifier, false, false).clear();
}
return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_CLEAR).resolveDescription("ELEMENT", identifier.toString());
} catch (NoSuchElementException e) {
if (LOG.isDebugEnabled()) {
LOG.debug(e.getMessage());
}
return new MessageEvent(MessageEventEnum.ACTION_FAILED_CLEAR_NO_SUCH_ELEMENT).resolveDescription("ELEMENT", identifier.toString());
} catch (WebDriverException e) {
LOG.warn(e.getMessage());
return parseWebDriverException(e);
}
}
use of org.openqa.selenium.NoSuchElementException in project cerberus-source by cerberustesting.
the class AppiumService method click.
@Override
public MessageEvent click(final Session session, final Identifier identifier) {
try {
final TouchAction action = new TouchAction(session.getAppiumDriver());
if (identifier.isSameIdentifier(Identifier.Identifiers.COORDINATE)) {
final Coordinates coordinates = getCoordinates(identifier);
action.tap(PointOption.point(coordinates.getX(), coordinates.getY())).perform();
} else {
action.tap(ElementOption.element(getElement(session, identifier, false, false))).perform();
}
return new MessageEvent(MessageEventEnum.ACTION_SUCCESS_CLICK).resolveDescription("ELEMENT", identifier.toString());
} catch (NoSuchElementException e) {
if (LOG.isDebugEnabled()) {
LOG.debug(e.getMessage());
}
return new MessageEvent(MessageEventEnum.ACTION_FAILED_CLICK_NO_SUCH_ELEMENT).resolveDescription("ELEMENT", identifier.toString());
} catch (WebDriverException e) {
LOG.warn(e.getMessage());
return parseWebDriverException(e);
}
}
use of org.openqa.selenium.NoSuchElementException in project cerberus-source by cerberustesting.
the class AppiumService method wait.
@Override
public MessageEvent wait(Session session, Identifier identifier) {
MessageEvent message;
try {
WebElement elmt = this.getElement(session, identifier, false, false);
message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT);
message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));
return message;
} catch (NoSuchElementException exception) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_WAIT_NO_SUCH_ELEMENT);
message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator()));
LOG.debug(exception.toString());
return message;
} catch (WebDriverException exception) {
LOG.error("Exception during Appium Wait Operation.", exception);
return parseWebDriverException(exception);
}
}
Aggregations