use of org.cerberus.engine.entity.Identifier in project cerberus-source by cerberustesting.
the class ActionService method doActionFocusToIframe.
private MessageEvent doActionFocusToIframe(TestCaseExecution tCExecution, String object, String property) {
MessageEvent message;
String element;
try {
/**
* Get element to use String object if not empty, String property if
* object empty, throws Exception if both empty)
*/
element = getElementToUse(object, property, "focusToIframe", tCExecution);
/**
* Get Identifier (identifier, locator)
*/
Identifier identifier = identifierService.convertStringToIdentifier(element);
identifierService.checkWebElementIdentifier(identifier.getIdentifier());
if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
return webdriverService.doSeleniumActionFocusToIframe(tCExecution.getSession(), identifier);
}
message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
message.setDescription(message.getDescription().replace("%ACTION%", "FocusToIframe"));
message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));
return message;
} catch (CerberusEventException ex) {
LOG.fatal("Error doing Action FocusToIframe :" + ex);
return ex.getMessageError();
}
}
use of org.cerberus.engine.entity.Identifier in project cerberus-source by cerberustesting.
the class ActionService method doActionWait.
private MessageEvent doActionWait(TestCaseExecution tCExecution, String object, String property) {
MessageEvent message;
String element;
long timeToWaitInMs = 0;
Identifier identifier = null;
try {
/**
* Get element to use String object if not empty, String property if
* object empty, null if both are empty
*/
element = getElementToUse(object, property, "wait", tCExecution);
if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI) || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK) || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA) || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {
/**
* if element is integer, set time to that value else Get
* Identifier (identifier, locator)
*/
if (StringUtil.isNullOrEmpty(element)) {
timeToWaitInMs = tCExecution.getCerberus_action_wait_default();
} else if (StringUtil.isInteger(element)) {
timeToWaitInMs = Long.valueOf(element);
} else {
identifier = identifierService.convertStringToIdentifier(element);
}
if (identifier != null && identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {
return sikuliService.doSikuliActionWait(tCExecution.getSession(), identifier.getLocator(), "");
} else if (identifier != null && identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {
return sikuliService.doSikuliActionWait(tCExecution.getSession(), "", identifier.getLocator());
} else if (identifier != null) {
identifierService.checkWebElementIdentifier(identifier.getIdentifier());
return webdriverService.doSeleniumActionWait(tCExecution.getSession(), identifier);
} else {
return this.waitTime(timeToWaitInMs);
}
} else {
// For any other application we wait for the integer value.
if (StringUtil.isNullOrEmpty(element)) {
// Get default wait from parameter
timeToWaitInMs = tCExecution.getCerberus_action_wait_default();
} else if (StringUtil.isInteger(element)) {
timeToWaitInMs = Long.valueOf(element);
}
return this.waitTime(timeToWaitInMs);
}
} catch (CerberusEventException ex) {
LOG.fatal("Error doing Action Wait :" + ex);
return ex.getMessageError();
}
}
use of org.cerberus.engine.entity.Identifier in project cerberus-source by cerberustesting.
the class ActionService method doActionMouseOver.
private MessageEvent doActionMouseOver(TestCaseExecution tCExecution, String object, String property) {
MessageEvent message;
String element;
try {
/**
* Get element to use String object if not empty, String property if
* object empty, throws Exception if both empty)
*/
element = getElementToUse(object, property, "mouseOver", tCExecution);
/**
* Get Identifier (identifier, locator)
*/
Identifier identifier = identifierService.convertStringToIdentifier(element);
if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {
return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "");
} else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {
return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator());
} else {
identifierService.checkWebElementIdentifier(identifier.getIdentifier());
return webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier);
}
} else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {
identifierService.checkSikuliIdentifier(identifier.getIdentifier());
if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {
return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "");
} else {
return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator());
}
}
message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
message.setDescription(message.getDescription().replace("%ACTION%", "mouseOver"));
message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));
return message;
} catch (CerberusEventException ex) {
LOG.fatal("Error doing Action MouseOver :" + ex);
return ex.getMessageError();
}
}
use of org.cerberus.engine.entity.Identifier in project cerberus-source by cerberustesting.
the class ActionService method doActionMouseLeftButtonPress.
private MessageEvent doActionMouseLeftButtonPress(TestCaseExecution tCExecution, String object, String property) {
MessageEvent message;
String element;
try {
/**
* Get element to use String object if not empty, String property if
* object empty, throws Exception if both empty)
*/
element = getElementToUse(object, property, "mouseLeftButtonPress", tCExecution);
/**
* Get Identifier (identifier, locator)
*/
Identifier identifier = identifierService.convertStringToIdentifier(element);
identifierService.checkWebElementIdentifier(identifier.getIdentifier());
if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
return webdriverService.doSeleniumActionMouseDown(tCExecution.getSession(), identifier);
}
message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
message.setDescription(message.getDescription().replace("%ACTION%", "MouseDown"));
message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));
return message;
} catch (CerberusEventException ex) {
LOG.fatal("Error doing Action MouseDown :" + ex);
return ex.getMessageError();
}
}
use of org.cerberus.engine.entity.Identifier in project cerberus-source by cerberustesting.
the class ActionService method doActionOpenURL.
private MessageEvent doActionOpenURL(TestCaseExecution tCExecution, String object, String property, boolean withBase) {
MessageEvent message;
String element;
try {
/**
* Get element to use String object if not empty, String property if
* object empty, throws Exception if both empty)
*/
element = getElementToUse(object, property, "openUrl[WithBase]", tCExecution);
/**
* Get Identifier (identifier, locator)
*/
Identifier identifier = new Identifier();
identifier.setIdentifier("url");
identifier.setLocator(element);
if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
return webdriverService.doSeleniumActionOpenURL(tCExecution.getSession(), tCExecution.getUrl(), identifier, withBase);
}
message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
message.setDescription(message.getDescription().replace("%ACTION%", "OpenURL[WithBase]"));
message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));
return message;
} catch (CerberusEventException ex) {
LOG.fatal("Error doing Action OpenUrl :" + ex);
return ex.getMessageError();
}
}
Aggregations