use of org.cerberus.exception.CerberusEventException in project cerberus-source by cerberustesting.
the class WebDriverService method doSeleniumActionSelect.
@Override
public MessageEvent doSeleniumActionSelect(Session session, Identifier object, Identifier property) {
MessageEvent message;
try {
Select select;
try {
AnswerItem answer = this.getSeleniumElement(session, object, true, true);
if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) {
WebElement webElement = (WebElement) answer.getItem();
if (webElement != null) {
select = new Select(webElement);
this.selectRequestedOption(select, property, object.getIdentifier() + "=" + object.getLocator());
message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_SELECT);
message.setDescription(message.getDescription().replace("%ELEMENT%", object.getIdentifier() + "=" + object.getLocator()));
message.setDescription(message.getDescription().replace("%DATA%", property.getIdentifier() + "=" + property.getLocator()));
return message;
}
}
return answer.getResultMessage();
} catch (NoSuchElementException exception) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELECT_NO_SUCH_ELEMENT);
message.setDescription(message.getDescription().replace("%ELEMENT%", object.getIdentifier() + "=" + object.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 (CerberusEventException ex) {
LOG.warn(ex);
return ex.getMessageError();
}
}
use of org.cerberus.exception.CerberusEventException in project cerberus-source by cerberustesting.
the class WebDriverService method selectRequestedOption.
private void selectRequestedOption(Select select, Identifier property, String element) throws CerberusEventException {
MessageEvent message;
try {
if (property.getIdentifier().equalsIgnoreCase("value")) {
select.selectByValue(property.getLocator());
} else if (property.getIdentifier().equalsIgnoreCase("label")) {
select.selectByVisibleText(property.getLocator());
} else if (property.getIdentifier().equalsIgnoreCase("index") && StringUtil.isInteger(property.getLocator())) {
select.selectByIndex(Integer.parseInt(property.getLocator()));
} else if (property.getIdentifier().equalsIgnoreCase("regexValue") || property.getIdentifier().equalsIgnoreCase("regexIndex") || property.getIdentifier().equalsIgnoreCase("regexLabel")) {
java.util.List<WebElement> list = select.getOptions();
if (property.getIdentifier().equalsIgnoreCase("regexValue")) {
for (WebElement option : list) {
String optionValue = option.getAttribute("value");
Pattern pattern = Pattern.compile(property.getLocator());
Matcher matcher = pattern.matcher(optionValue);
if (matcher.find()) {
select.selectByValue(optionValue);
}
}
} else if (property.getIdentifier().equalsIgnoreCase("regexLabel")) {
for (WebElement option : list) {
String optionLabel = option.getText();
Pattern pattern = Pattern.compile(property.getLocator());
Matcher matcher = pattern.matcher(optionLabel);
if (matcher.find()) {
select.selectByVisibleText(optionLabel);
}
}
} else if (property.getIdentifier().equalsIgnoreCase("regexIndex") && StringUtil.isInteger(property.getLocator())) {
for (WebElement option : list) {
Integer id = 0;
Pattern pattern = Pattern.compile(property.getLocator());
Matcher matcher = pattern.matcher(id.toString());
if (matcher.find()) {
select.selectByIndex(Integer.parseInt(property.getLocator()));
}
id++;
}
}
} else {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELECT_NO_IDENTIFIER);
message.setDescription(message.getDescription().replace("%IDENTIFIER%", property.getIdentifier()));
throw new CerberusEventException(message);
}
} catch (NoSuchElementException exception) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELECT_NO_SUCH_VALUE);
message.setDescription(message.getDescription().replace("%ELEMENT%", element));
message.setDescription(message.getDescription().replace("%DATA%", property.getIdentifier() + "=" + property.getLocator()));
throw new CerberusEventException(message);
} catch (WebDriverException exception) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELENIUM_CONNECTIVITY);
message.setDescription(message.getDescription().replace("%ERROR%", exception.getMessage().split("\n")[0]));
LOG.warn(exception.toString());
throw new CerberusEventException(message);
} catch (PatternSyntaxException e) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELECT_REGEX_INVALIDPATERN);
message.setDescription(message.getDescription().replace("%PATERN%", property.getLocator()));
message.setDescription(message.getDescription().replace("%ERROR%", e.getMessage()));
throw new CerberusEventException(message);
}
}
use of org.cerberus.exception.CerberusEventException in project cerberus-source by cerberustesting.
the class DataLibService method getFromDataLib.
@Override
public AnswerList<HashMap<String, String>> getFromDataLib(TestDataLib lib, TestCaseCountryProperties testCaseCountryProperty, TestCaseExecution tCExecution, TestCaseExecutionData testCaseExecutionData) {
AnswerItem<HashMap<String, String>> resultColumns;
AnswerList<HashMap<String, String>> resultData;
AnswerList<HashMap<String, String>> result;
MessageEvent msg = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS);
// Length contains the nb of rows that the result must fetch. If defined at 0 we force at 1.
Integer nbRowsRequested = 0;
try {
nbRowsRequested = Integer.parseInt(testCaseExecutionData.getLength());
if (nbRowsRequested < 1) {
nbRowsRequested = 1;
}
} catch (NumberFormatException e) {
LOG.error(e.toString());
}
/**
* Gets the list of columns (subdata) to get from TestDataLibData.
*/
resultColumns = getSubDataFromType(lib);
HashMap<String, String> columnList = null;
// Manage error message.
if (resultColumns.getResultMessage().getCode() == MessageEventEnum.PROPERTY_SUCCESS_GETFROMDATALIB_SUBDATA.getCode()) {
AnswerItem answerDecode = new AnswerItem();
columnList = resultColumns.getItem();
// Now that we have the list of column with subdata and value, we can try to decode it.
if (columnList != null) {
for (Map.Entry<String, String> entry : columnList.entrySet()) {
// Loop on all Column in order to decode all values.
// SubData
String eKey = entry.getKey();
// Parsing Answer
String eValue = entry.getValue();
try {
answerDecode = variableService.decodeStringCompletly(eValue, tCExecution, null, false);
columnList.put(eKey, (String) answerDecode.getItem());
if (!(answerDecode.isCodeStringEquals("OK"))) {
// If anything wrong with the decode --> we stop here with decode message in the action result.
result = new AnswerList();
result.setDataList(null);
msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_GLOBAL_SUBDATAISSUE);
msg.setDescription(msg.getDescription().replace("%SUBDATAMESSAGE%", answerDecode.getMessageDescription().replace("%FIELD%", "Column value '" + eValue + "'")));
result.setResultMessage(msg);
LOG.debug("Datalib interupted due to decode 'column value' Error.");
return result;
}
} catch (CerberusEventException cex) {
LOG.warn(cex);
}
}
}
} else if (resultColumns.getResultMessage().getCode() == MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_SUBDATA.getCode()) {
result = new AnswerList();
result.setDataList(null);
msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_GLOBAL_SUBDATAISSUE);
msg.setDescription(msg.getDescription().replace("%SUBDATAMESSAGE%", resultColumns.getMessageDescription()));
result.setResultMessage(msg);
return result;
}
/**
* Get List of DataObject in a format List<Map<String>> - 1 item per row
* with key = column and value = content
*/
int rowLimit = testCaseCountryProperty.getRowLimit();
if (testCaseCountryProperty.getNature().equalsIgnoreCase(TestCaseCountryProperties.NATURE_STATIC)) {
// If Nature of the property is static, we don't need to getch more than reqested record.
rowLimit = nbRowsRequested;
}
resultData = getDataObjectList(lib, columnList, rowLimit, tCExecution, testCaseExecutionData);
// Manage error message.
if (resultData.getResultMessage().getCode() == MessageEventEnum.PROPERTY_SUCCESS_GETFROMDATALIB_DATA.getCode()) {
if (resultData.getDataList().size() < nbRowsRequested) {
// We check if the data provided is enought to provide the answer.
result = new AnswerList();
result.setDataList(null);
msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_GLOBAL_NOTENOUGHTDATA);
msg.setDescription(msg.getDescription().replace("%DATAMESSAGE%", resultData.getMessageDescription()).replace("%NBREQUEST%", Integer.toString(nbRowsRequested)));
result.setResultMessage(msg);
return result;
}
} else if (resultData.getResultMessage().getCode() == MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_GENERIC_NODATA.getCode()) {
result = new AnswerList();
result.setDataList(null);
msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_GLOBAL_NODATA);
msg.setDescription(msg.getDescription().replace("%DATAMESSAGE%", resultData.getMessageDescription()));
result.setResultMessage(msg);
return result;
} else {
result = new AnswerList();
result.setDataList(null);
msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_GLOBAL_DATAISSUE);
msg.setDescription(msg.getDescription().replace("%DATAMESSAGE%", resultData.getMessageDescription()));
result.setResultMessage(msg);
return result;
}
/**
* Filter out the result from requested rows depending on the nature
*/
result = filterWithNature(testCaseCountryProperty.getNature(), resultData, tCExecution, testCaseCountryProperty, nbRowsRequested);
// Manage error message.
if (result.getResultMessage().getCode() == MessageEventEnum.PROPERTY_SUCCESS_GETFROMDATALIB_NATURE.getCode()) {
msg = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMDATALIB_GLOBAL);
msg.setDescription(msg.getDescription().replace("%DATAMESSAGE%", resultData.getMessageDescription()).replace("%FILTERNATUREMESSAGE%", result.getMessageDescription()));
result.setResultMessage(msg);
} else if (result.getResultMessage().getCode() == MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_GENERIC_NATURENOMORERECORD.getCode()) {
// if the script does not return
result.setDataList(null);
msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_GLOBAL_NODATALEFT);
msg.setDescription(msg.getDescription().replace("%DATAMESSAGE%", resultData.getMessageDescription()).replace("%FILTERNATUREMESSAGE%", result.getMessageDescription()));
result.setResultMessage(msg);
} else {
// other error had occured
result.setDataList(null);
msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_GLOBAL_GENERIC);
msg.setDescription(msg.getDescription().replace("%DATAMESSAGE%", resultData.getMessageDescription()).replace("%FILTERNATUREMESSAGE%", result.getMessageDescription()));
result.setResultMessage(msg);
}
return result;
}
use of org.cerberus.exception.CerberusEventException in project cerberus-source by cerberustesting.
the class ActionService method doAction.
@Override
public TestCaseStepActionExecution doAction(TestCaseStepActionExecution testCaseStepActionExecution) {
MessageEvent res;
TestCaseExecution tCExecution = testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution();
AnswerItem<String> answerDecode = new AnswerItem();
/**
* Decode the object field before doing the action.
*/
try {
// When starting a new action, we reset the property list that was already calculated.
tCExecution.setRecursiveAlreadyCalculatedPropertiesList(new ArrayList());
answerDecode = variableService.decodeStringCompletly(testCaseStepActionExecution.getValue1(), tCExecution, testCaseStepActionExecution, false);
testCaseStepActionExecution.setValue1((String) answerDecode.getItem());
if (!(answerDecode.isCodeStringEquals("OK"))) {
// If anything wrong with the decode --> we stop here with decode message in the action result.
testCaseStepActionExecution.setActionResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Action Value1"));
testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));
testCaseStepActionExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());
testCaseStepActionExecution.setEnd(new Date().getTime());
LOG.debug("Action interupted due to decode 'Action Value1' Error.");
return testCaseStepActionExecution;
}
} catch (CerberusEventException cex) {
testCaseStepActionExecution.setActionResultMessage(cex.getMessageError());
testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(cex.getMessageError().getMessage()));
testCaseStepActionExecution.setEnd(new Date().getTime());
return testCaseStepActionExecution;
}
try {
// When starting a new action, we reset the property list that was already calculated.
tCExecution.setRecursiveAlreadyCalculatedPropertiesList(new ArrayList());
answerDecode = variableService.decodeStringCompletly(testCaseStepActionExecution.getValue2(), tCExecution, testCaseStepActionExecution, false);
testCaseStepActionExecution.setValue2((String) answerDecode.getItem());
if (!(answerDecode.isCodeStringEquals("OK"))) {
// If anything wrong with the decode --> we stop here with decode message in the action result.
testCaseStepActionExecution.setActionResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Action Value2"));
testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));
testCaseStepActionExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());
testCaseStepActionExecution.setEnd(new Date().getTime());
LOG.debug("Action interupted due to decode 'Action Value2' Error.");
return testCaseStepActionExecution;
}
} catch (CerberusEventException cex) {
testCaseStepActionExecution.setActionResultMessage(cex.getMessageError());
testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(cex.getMessageError().getMessage()));
testCaseStepActionExecution.setEnd(new Date().getTime());
return testCaseStepActionExecution;
}
/**
* Timestamp starts after the decode. TODO protect when property is
* null.
*/
testCaseStepActionExecution.setStart(new Date().getTime());
String value1 = testCaseStepActionExecution.getValue1();
String value2 = testCaseStepActionExecution.getValue2();
String propertyName = testCaseStepActionExecution.getPropertyName();
LOG.debug("Doing Action : " + testCaseStepActionExecution.getAction() + " with value1 : " + value1 + " and value2 : " + value2);
// When starting a new action, we reset the property list that was already calculated.
tCExecution.setRecursiveAlreadyCalculatedPropertiesList(new ArrayList());
try {
switch(testCaseStepActionExecution.getAction()) {
case TestCaseStepAction.ACTION_CLICK:
res = this.doActionClick(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_MOUSELEFTBUTTONPRESS:
res = this.doActionMouseLeftButtonPress(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_MOUSELEFTBUTTONRELEASE:
res = this.doActionMouseLeftButtonRelease(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_DOUBLECLICK:
res = this.doActionDoubleClick(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_RIGHTCLICK:
res = this.doActionRightClick(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_MOUSEOVER:
res = this.doActionMouseOver(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_FOCUSTOIFRAME:
res = this.doActionFocusToIframe(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_FOCUSDEFAULTIFRAME:
res = this.doActionFocusDefaultIframe(tCExecution);
break;
case TestCaseStepAction.ACTION_SWITCHTOWINDOW:
res = this.doActionSwitchToWindow(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_MANAGEDIALOG:
res = this.doActionManageDialog(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_OPENURLWITHBASE:
res = this.doActionOpenURL(tCExecution, value1, value2, true);
break;
case TestCaseStepAction.ACTION_OPENURLLOGIN:
testCaseStepActionExecution.setValue1(testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getCountryEnvironmentParameters().getUrlLogin());
res = this.doActionUrlLogin(tCExecution);
break;
case TestCaseStepAction.ACTION_OPENURL:
res = this.doActionOpenURL(tCExecution, value1, value2, false);
break;
case TestCaseStepAction.ACTION_EXECUTEJS:
res = this.doActionExecuteJS(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_OPENAPP:
res = this.doActionOpenApp(tCExecution, value1);
break;
case TestCaseStepAction.ACTION_CLOSEAPP:
res = this.doActionCloseApp(tCExecution, value1);
break;
case TestCaseStepAction.ACTION_SELECT:
res = this.doActionSelect(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_KEYPRESS:
res = this.doActionKeyPress(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_TYPE:
res = this.doActionType(tCExecution, value1, value2, propertyName);
break;
case TestCaseStepAction.ACTION_HIDEKEYBOARD:
res = this.doActionHideKeyboard(tCExecution);
break;
case TestCaseStepAction.ACTION_SWIPE:
res = this.doActionSwipe(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_WAIT:
res = this.doActionWait(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_WAITVANISH:
res = this.doActionWaitVanish(tCExecution, value1);
break;
case TestCaseStepAction.ACTION_CALLSERVICE:
res = this.doActionCallService(testCaseStepActionExecution, value1);
break;
case TestCaseStepAction.ACTION_EXECUTESQLUPDATE:
res = this.doActionExecuteSQLUpdate(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_EXECUTESQLSTOREPROCEDURE:
res = this.doActionExecuteSQLStoredProcedure(tCExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_CALCULATEPROPERTY:
res = this.doActionCalculateProperty(testCaseStepActionExecution, value1, value2);
break;
case TestCaseStepAction.ACTION_DONOTHING:
res = new MessageEvent(MessageEventEnum.ACTION_SUCCESS);
break;
// DEPRECATED ACTIONS FROM HERE.
case TestCaseStepAction.ACTION_MOUSEOVERANDWAIT:
res = this.doActionMouseOverAndWait(tCExecution, value1, value2);
res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());
logEventService.createForPrivateCalls("ENGINE", "mouseOverAndWait", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");
LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action mouseOverAndWait triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");
break;
case TestCaseStepAction.ACTION_REMOVEDIFFERENCE:
res = this.doActionRemoveDifference(testCaseStepActionExecution, value1, value2);
res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());
logEventService.createForPrivateCalls("ENGINE", "removeDifference", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");
LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action removeDifference triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");
break;
case TestCaseStepAction.ACTION_GETPAGESOURCE:
res = this.doActionGetPageSource(testCaseStepActionExecution);
res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());
logEventService.createForPrivateCalls("ENGINE", "getPageSource", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");
LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action getPageSource triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");
break;
case TestCaseStepAction.ACTION_TAKESCREENSHOT:
res = this.doActionTakeScreenshot(testCaseStepActionExecution);
res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());
logEventService.createForPrivateCalls("ENGINE", "takeScreenshot", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");
LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action takeScreenshot triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");
break;
case TestCaseStepAction.ACTION_CLICKANDWAIT:
res = this.doActionClickWait(tCExecution, value1, value2);
res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());
logEventService.createForPrivateCalls("ENGINE", "clickAndWait", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");
LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action clickAndWait triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");
break;
case TestCaseStepAction.ACTION_ENTER:
res = this.doActionKeyPress(tCExecution, value1, "RETURN");
res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());
logEventService.createForPrivateCalls("ENGINE", "enter", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");
LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action enter triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");
break;
case TestCaseStepAction.ACTION_SELECTANDWAIT:
res = this.doActionSelect(tCExecution, value1, value2);
this.doActionWait(tCExecution, StringUtil.NULL, StringUtil.NULL);
res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());
logEventService.createForPrivateCalls("ENGINE", "selectAndWait", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");
LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action selectAndWait triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");
break;
default:
res = new MessageEvent(MessageEventEnum.ACTION_FAILED_UNKNOWNACTION);
res.setDescription(res.getDescription().replace("%ACTION%", testCaseStepActionExecution.getAction()));
}
} catch (final Exception unexpected) {
LOG.error("Unexpected exception: " + unexpected.getMessage(), unexpected);
res = new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC).resolveDescription("DETAIL", unexpected.getMessage());
}
LOG.debug("Result of the action : " + res.getCodeString() + " " + res.getDescription());
/**
* In case 1/ the action is flaged as being Forced with a specific
* return code = PE and 2/ the return of the action is stoping the test
* --> whatever the return of the action is, we force the return to move
* forward the test with no screenshot, pagesource.
*/
if (testCaseStepActionExecution.getForceExeStatus().equals("PE") && res.isStopTest()) {
res.setDescription(res.getDescription() + " -- Execution forced to continue.");
res.setDoScreenshot(false);
res.setGetPageSource(false);
res.setStopTest(false);
res.setMessage(MessageGeneralEnum.EXECUTION_PE_TESTEXECUTING);
}
testCaseStepActionExecution.setActionResultMessage(res);
/**
* Determine here the impact of the Action on the full test return code
* from the ResultMessage of the Action.
*/
testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(res.getMessage()));
/**
* Determine here if we stop the test from the ResultMessage of the
* Action.
*/
testCaseStepActionExecution.setStopExecution(res.isStopTest());
testCaseStepActionExecution.setEnd(new Date().getTime());
return testCaseStepActionExecution;
}
use of org.cerberus.exception.CerberusEventException in project cerberus-source by cerberustesting.
the class ActionService method doActionManageDialog.
private MessageEvent doActionManageDialog(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, "manageDialog", tCExecution);
/**
* Get Identifier (identifier, locator)
*/
Identifier identifier = identifierService.convertStringToIdentifier(element);
identifierService.checkWebElementIdentifier(identifier.getIdentifier());
if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
return webdriverService.doSeleniumActionManageDialog(tCExecution.getSession(), identifier);
}
message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
message.setDescription(message.getDescription().replace("%ACTION%", "ManageDialog"));
message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));
return message;
} catch (CerberusEventException ex) {
LOG.fatal("Error doing Action ManageDialog :" + ex);
return ex.getMessageError();
}
}
Aggregations