How to use getTestCaseStepExecution method of org.cerberus.crud.entity.TestCaseStepActionExecution class

Best Cerberus-source code snippet using org.cerberus.crud.entity.TestCaseStepActionExecution.getTestCaseStepExecution

Source:ActionService.java Github

copy

Full Screen

...109 private static final String MESSAGE_DEPRECATED = "[DEPRECATED]";110 @Override111 public TestCaseStepActionExecution doAction(TestCaseStepActionExecution testCaseStepActionExecution) {112 MessageEvent res;113 TestCaseExecution tCExecution = testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution();114 AnswerItem<String> answerDecode = new AnswerItem();115 /**116 * Decode the object field before doing the action.117 */118 try {119 // When starting a new action, we reset the property list that was already calculated.120 tCExecution.setRecursiveAlreadyCalculatedPropertiesList(new ArrayList());121 answerDecode = variableService.decodeStringCompletly(testCaseStepActionExecution.getValue1(),122 tCExecution, testCaseStepActionExecution, false);123 testCaseStepActionExecution.setValue1((String) answerDecode.getItem());124 if (!(answerDecode.isCodeStringEquals("OK"))) {125 // If anything wrong with the decode --> we stop here with decode message in the action result.126 testCaseStepActionExecution.setActionResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Action Value1"));127 testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));128 testCaseStepActionExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());129 testCaseStepActionExecution.setEnd(new Date().getTime());130 LOG.debug("Action interupted due to decode 'Action Value1' Error.");131 return testCaseStepActionExecution;132 }133 } catch (CerberusEventException cex) {134 testCaseStepActionExecution.setActionResultMessage(cex.getMessageError());135 testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(cex.getMessageError().getMessage()));136 testCaseStepActionExecution.setEnd(new Date().getTime());137 return testCaseStepActionExecution;138 }139 try {140 // When starting a new action, we reset the property list that was already calculated.141 tCExecution.setRecursiveAlreadyCalculatedPropertiesList(new ArrayList());142 answerDecode = variableService.decodeStringCompletly(testCaseStepActionExecution.getValue2(),143 tCExecution, testCaseStepActionExecution, false);144 testCaseStepActionExecution.setValue2((String) answerDecode.getItem());145 if (!(answerDecode.isCodeStringEquals("OK"))) {146 // If anything wrong with the decode --> we stop here with decode message in the action result.147 testCaseStepActionExecution.setActionResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Action Value2"));148 testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));149 testCaseStepActionExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());150 testCaseStepActionExecution.setEnd(new Date().getTime());151 LOG.debug("Action interupted due to decode 'Action Value2' Error.");152 return testCaseStepActionExecution;153 }154 } catch (CerberusEventException cex) {155 testCaseStepActionExecution.setActionResultMessage(cex.getMessageError());156 testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(cex.getMessageError().getMessage()));157 testCaseStepActionExecution.setEnd(new Date().getTime());158 return testCaseStepActionExecution;159 }160 /**161 * Timestamp starts after the decode. TODO protect when property is162 * null.163 */164 testCaseStepActionExecution.setStart(new Date().getTime());165 String value1 = testCaseStepActionExecution.getValue1();166 String value2 = testCaseStepActionExecution.getValue2();167 String propertyName = testCaseStepActionExecution.getPropertyName();168 LOG.debug("Doing Action : " + testCaseStepActionExecution.getAction() + " with value1 : " + value1 + " and value2 : " + value2);169 // When starting a new action, we reset the property list that was already calculated.170 tCExecution.setRecursiveAlreadyCalculatedPropertiesList(new ArrayList());171 try {172 switch (testCaseStepActionExecution.getAction()) {173 case TestCaseStepAction.ACTION_CLICK:174 res = this.doActionClick(tCExecution, value1, value2);175 break;176 case TestCaseStepAction.ACTION_MOUSELEFTBUTTONPRESS:177 res = this.doActionMouseLeftButtonPress(tCExecution, value1, value2);178 break;179 case TestCaseStepAction.ACTION_MOUSELEFTBUTTONRELEASE:180 res = this.doActionMouseLeftButtonRelease(tCExecution, value1, value2);181 break;182 case TestCaseStepAction.ACTION_DOUBLECLICK:183 res = this.doActionDoubleClick(tCExecution, value1, value2);184 break;185 case TestCaseStepAction.ACTION_RIGHTCLICK:186 res = this.doActionRightClick(tCExecution, value1, value2);187 break;188 case TestCaseStepAction.ACTION_MOUSEOVER:189 res = this.doActionMouseOver(tCExecution, value1, value2);190 break;191 case TestCaseStepAction.ACTION_FOCUSTOIFRAME:192 res = this.doActionFocusToIframe(tCExecution, value1, value2);193 break;194 case TestCaseStepAction.ACTION_FOCUSDEFAULTIFRAME:195 res = this.doActionFocusDefaultIframe(tCExecution);196 break;197 case TestCaseStepAction.ACTION_SWITCHTOWINDOW:198 res = this.doActionSwitchToWindow(tCExecution, value1, value2);199 break;200 case TestCaseStepAction.ACTION_MANAGEDIALOG:201 res = this.doActionManageDialog(tCExecution, value1, value2);202 break;203 case TestCaseStepAction.ACTION_OPENURLWITHBASE:204 res = this.doActionOpenURL(tCExecution, value1, value2, true);205 break;206 case TestCaseStepAction.ACTION_OPENURLLOGIN:207 testCaseStepActionExecution.setValue1(testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getCountryEnvironmentParameters().getUrlLogin());208 res = this.doActionUrlLogin(tCExecution);209 break;210 case TestCaseStepAction.ACTION_OPENURL:211 res = this.doActionOpenURL(tCExecution, value1, value2, false);212 break;213 case TestCaseStepAction.ACTION_EXECUTEJS:214 res = this.doActionExecuteJS(tCExecution, value1, value2);215 break;216 case TestCaseStepAction.ACTION_OPENAPP:217 res = this.doActionOpenApp(tCExecution, value1);218 break;219 case TestCaseStepAction.ACTION_CLOSEAPP:220 res = this.doActionCloseApp(tCExecution, value1);221 break;222 case TestCaseStepAction.ACTION_SELECT:223 res = this.doActionSelect(tCExecution, value1, value2);224 break;225 case TestCaseStepAction.ACTION_KEYPRESS:226 res = this.doActionKeyPress(tCExecution, value1, value2);227 break;228 case TestCaseStepAction.ACTION_TYPE:229 res = this.doActionType(tCExecution, value1, value2, propertyName);230 break;231 case TestCaseStepAction.ACTION_HIDEKEYBOARD:232 res = this.doActionHideKeyboard(tCExecution);233 break;234 case TestCaseStepAction.ACTION_SWIPE:235 res = this.doActionSwipe(tCExecution, value1, value2);236 break;237 case TestCaseStepAction.ACTION_WAIT:238 res = this.doActionWait(tCExecution, value1, value2);239 break;240 case TestCaseStepAction.ACTION_WAITVANISH:241 res = this.doActionWaitVanish(tCExecution, value1);242 break;243 case TestCaseStepAction.ACTION_CALLSERVICE:244 res = this.doActionCallService(testCaseStepActionExecution, value1);245 break;246 case TestCaseStepAction.ACTION_EXECUTESQLUPDATE:247 res = this.doActionExecuteSQLUpdate(tCExecution, value1, value2);248 break;249 case TestCaseStepAction.ACTION_EXECUTESQLSTOREPROCEDURE:250 res = this.doActionExecuteSQLStoredProcedure(tCExecution, value1, value2);251 break;252 case TestCaseStepAction.ACTION_CALCULATEPROPERTY:253 res = this.doActionCalculateProperty(testCaseStepActionExecution, value1, value2);254 break;255 case TestCaseStepAction.ACTION_DONOTHING:256 res = new MessageEvent(MessageEventEnum.ACTION_SUCCESS);257 break;258 // DEPRECATED ACTIONS FROM HERE.259 case TestCaseStepAction.ACTION_MOUSEOVERANDWAIT:260 res = this.doActionMouseOverAndWait(tCExecution, value1, value2);261 res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());262 logEventService.createForPrivateCalls("ENGINE", "mouseOverAndWait", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");263 LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action mouseOverAndWait triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");264 break;265 case TestCaseStepAction.ACTION_REMOVEDIFFERENCE:266 res = this.doActionRemoveDifference(testCaseStepActionExecution, value1, value2);267 res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());268 logEventService.createForPrivateCalls("ENGINE", "removeDifference", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");269 LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action removeDifference triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");270 break;271 case TestCaseStepAction.ACTION_GETPAGESOURCE:272 res = this.doActionGetPageSource(testCaseStepActionExecution);273 res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());274 logEventService.createForPrivateCalls("ENGINE", "getPageSource", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");275 LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action getPageSource triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");276 break;277 case TestCaseStepAction.ACTION_TAKESCREENSHOT:278 res = this.doActionTakeScreenshot(testCaseStepActionExecution);279 res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());280 logEventService.createForPrivateCalls("ENGINE", "takeScreenshot", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");281 LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action takeScreenshot triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");282 break;283 case TestCaseStepAction.ACTION_CLICKANDWAIT:284 res = this.doActionClickWait(tCExecution, value1, value2);285 res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());286 logEventService.createForPrivateCalls("ENGINE", "clickAndWait", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");287 LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action clickAndWait triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");288 break;289 case TestCaseStepAction.ACTION_ENTER:290 res = this.doActionKeyPress(tCExecution, value1, "RETURN");291 res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());292 logEventService.createForPrivateCalls("ENGINE", "enter", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");293 LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action enter triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");294 break;295 case TestCaseStepAction.ACTION_SELECTANDWAIT:296 res = this.doActionSelect(tCExecution, value1, value2);297 this.doActionWait(tCExecution, StringUtil.NULL, StringUtil.NULL);298 res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());299 logEventService.createForPrivateCalls("ENGINE", "selectAndWait", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");300 LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action selectAndWait triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");301 break;302 default:303 res = new MessageEvent(MessageEventEnum.ACTION_FAILED_UNKNOWNACTION);304 res.setDescription(res.getDescription().replace("%ACTION%", testCaseStepActionExecution.getAction()));305 }306 } catch (final Exception unexpected) {307 LOG.error("Unexpected exception: " + unexpected.getMessage(), unexpected);308 res = new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC).resolveDescription("DETAIL", unexpected.getMessage());309 }310 LOG.debug("Result of the action : " + res.getCodeString() + " " + res.getDescription());311 /**312 * In case 1/ the action is flaged as being Forced with a specific313 * return code = PE and 2/ the return of the action is stoping the test314 * --> whatever the return of the action is, we force the return to move315 * forward the test with no screenshot, pagesource.316 */317 if (testCaseStepActionExecution.getForceExeStatus().equals("PE") && res.isStopTest()) {318 res.setDescription(res.getDescription() + " -- Execution forced to continue.");319 res.setDoScreenshot(false);320 res.setGetPageSource(false);321 res.setStopTest(false);322 res.setMessage(MessageGeneralEnum.EXECUTION_PE_TESTEXECUTING);323 }324 testCaseStepActionExecution.setActionResultMessage(res);325 /**326 * Determine here the impact of the Action on the full test return code327 * from the ResultMessage of the Action.328 */329 testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(res.getMessage()));330 /**331 * Determine here if we stop the test from the ResultMessage of the332 * Action.333 */334 testCaseStepActionExecution.setStopExecution(res.isStopTest());335 testCaseStepActionExecution.setEnd(new Date().getTime());336 return testCaseStepActionExecution;337 }338 private MessageEvent doActionClick(TestCaseExecution tCExecution, String value1, String value2) {339 String element;340 try {341 /**342 * Get element to use String object if not empty, String property if343 * object empty, throws Exception if both empty)344 */345 element = getElementToUse(value1, value2, TestCaseStepAction.ACTION_CLICK, tCExecution);346 /**347 * Get Identifier (identifier, locator) and check it's valid348 */349 Identifier identifier = identifierService.convertStringToIdentifier(element);350 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {351 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {352 return sikuliService.doSikuliActionClick(tCExecution.getSession(), identifier.getLocator(), "");353 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {354 return sikuliService.doSikuliActionClick(tCExecution.getSession(), "", identifier.getLocator());355 } else {356 identifierService.checkWebElementIdentifier(identifier.getIdentifier());357 return webdriverService.doSeleniumActionClick(tCExecution.getSession(), identifier, true, true);358 }359 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {360 identifierService.checkWebElementIdentifier(identifier.getIdentifier());361 return androidAppiumService.click(tCExecution.getSession(), identifier);362 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {363 identifierService.checkWebElementIdentifier(identifier.getIdentifier());364 return iosAppiumService.click(tCExecution.getSession(), identifier);365 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {366 identifierService.checkSikuliIdentifier(identifier.getIdentifier());367 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {368 return sikuliService.doSikuliActionClick(tCExecution.getSession(), identifier.getLocator(), "");369 } else {370 return sikuliService.doSikuliActionClick(tCExecution.getSession(), "", identifier.getLocator());371 }372 } else {373 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION)374 .resolveDescription("ACTION", "Click")375 .resolveDescription("APPLICATIONTYPE", tCExecution.getApplicationObj().getType());376 }377 } catch (CerberusEventException ex) {378 LOG.fatal("Error doing Action Click :" + ex);379 return ex.getMessageError();380 }381 }382 private MessageEvent doActionExecuteJS(TestCaseExecution tCExecution, String value1, String value2) {383 MessageEvent message;384 String script = value1;385 String valueFromJS;386 try {387 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {388 valueFromJS = this.webdriverService.getValueFromJS(tCExecution.getSession(), script);389 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_EXECUTEJS);390 message.setDescription(message.getDescription().replace("%SCRIPT%", script));391 message.setDescription(message.getDescription().replace("%VALUE%", valueFromJS));392 return message;393 }394 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);395 message.setDescription(message.getDescription().replace("%ACTION%", "executeJS"));396 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));397 return message;398 } catch (Exception e) {399 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_EXECUTEJS);400 String messageString = e.getMessage().split("\n")[0];401 message.setDescription(message.getDescription().replace("%EXCEPTION%", messageString));402 LOG.debug("Exception Running JS Script :" + messageString);403 return message;404 }405 }406 private MessageEvent doActionMouseLeftButtonPress(TestCaseExecution tCExecution, String object, String property) {407 MessageEvent message;408 String element;409 try {410 /**411 * Get element to use String object if not empty, String property if412 * object empty, throws Exception if both empty)413 */414 element = getElementToUse(object, property, "mouseLeftButtonPress", tCExecution);415 /**416 * Get Identifier (identifier, locator)417 */418 Identifier identifier = identifierService.convertStringToIdentifier(element);419 identifierService.checkWebElementIdentifier(identifier.getIdentifier());420 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {421 return webdriverService.doSeleniumActionMouseDown(tCExecution.getSession(), identifier);422 }423 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);424 message.setDescription(message.getDescription().replace("%ACTION%", "MouseDown"));425 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));426 return message;427 } catch (CerberusEventException ex) {428 LOG.fatal("Error doing Action MouseDown :" + ex);429 return ex.getMessageError();430 }431 }432 private MessageEvent doActionRightClick(TestCaseExecution tCExecution, String object, String property) {433 MessageEvent message;434 String element;435 try {436 /**437 * Get element to use String object if not empty, String property if438 * object empty, throws Exception if both empty)439 */440 element = getElementToUse(object, property, "rightClick", tCExecution);441 /**442 * Get Identifier (identifier, locator)443 */444 Identifier identifier = identifierService.convertStringToIdentifier(element);445 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {446 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {447 return sikuliService.doSikuliActionRightClick(tCExecution.getSession(), identifier.getLocator(), "");448 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {449 return sikuliService.doSikuliActionRightClick(tCExecution.getSession(), "", identifier.getLocator());450 } else {451 identifierService.checkWebElementIdentifier(identifier.getIdentifier());452 return webdriverService.doSeleniumActionRightClick(tCExecution.getSession(), identifier);453 }454 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {455 identifierService.checkSikuliIdentifier(identifier.getIdentifier());456 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {457 return sikuliService.doSikuliActionRightClick(tCExecution.getSession(), identifier.getLocator(), "");458 } else {459 return sikuliService.doSikuliActionRightClick(tCExecution.getSession(), "", identifier.getLocator());460 }461 }462 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);463 message.setDescription(message.getDescription().replace("%ACTION%", "rightClick"));464 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));465 return message;466 } catch (CerberusEventException ex) {467 LOG.fatal("Error doing Action RightClick :" + ex);468 return ex.getMessageError();469 }470 }471 private MessageEvent doActionMouseLeftButtonRelease(TestCaseExecution tCExecution, String object, String property) {472 MessageEvent message;473 String element;474 try {475 /**476 * Get element to use String object if not empty, String property if477 * object empty, throws Exception if both empty)478 */479 element = getElementToUse(object, property, "mouseLeftButtonRelease", tCExecution);480 /**481 * Get Identifier (identifier, locator)482 */483 Identifier identifier = identifierService.convertStringToIdentifier(element);484 identifierService.checkWebElementIdentifier(identifier.getIdentifier());485 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {486 return webdriverService.doSeleniumActionMouseUp(tCExecution.getSession(), identifier);487 }488 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);489 message.setDescription(message.getDescription().replace("%ACTION%", "MouseUp"));490 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));491 return message;492 } catch (CerberusEventException ex) {493 LOG.fatal("Error doing Action MouseUp :" + ex);494 return ex.getMessageError();495 }496 }497 private MessageEvent doActionSwitchToWindow(TestCaseExecution tCExecution, String object, String property) {498 String element;499 try {500 /**501 * Get element to use String object if not empty, String property if502 * object empty, throws Exception if both empty)503 */504 element = getElementToUse(object, property, "switchToWindow", tCExecution);505 /**506 * Get Identifier (identifier, locator)507 */508 Identifier identifier = identifierService.convertStringToIdentifier(element);509 //identifierService.checkWebElementIdentifier(identifier.getIdentifier());510 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {511 return webdriverService.doSeleniumActionSwitchToWindow(tCExecution.getSession(), identifier);512 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {513 return androidAppiumService.switchToContext(tCExecution.getSession(), identifier);514 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {515 return iosAppiumService.switchToContext(tCExecution.getSession(), identifier);516 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {517 return sikuliService.doSikuliActionSwitchApp(tCExecution.getSession(), identifier.getLocator());518 } else {519 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION)520 .resolveDescription("ACTION", "SwitchToWindow")521 .resolveDescription("APPLICATIONTYPE", tCExecution.getApplicationObj().getType());522 }523 } catch (CerberusEventException ex) {524 LOG.fatal("Error doing Action SwitchToWindow :" + ex);525 return ex.getMessageError();526 }527 }528 private MessageEvent doActionManageDialog(TestCaseExecution tCExecution, String object, String property) {529 MessageEvent message;530 String element;531 try {532 /**533 * Get element to use String object if not empty, String property if534 * object empty, throws Exception if both empty)535 */536 element = getElementToUse(object, property, "manageDialog", tCExecution);537 /**538 * Get Identifier (identifier, locator)539 */540 Identifier identifier = identifierService.convertStringToIdentifier(element);541 identifierService.checkWebElementIdentifier(identifier.getIdentifier());542 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {543 return webdriverService.doSeleniumActionManageDialog(tCExecution.getSession(), identifier);544 }545 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);546 message.setDescription(message.getDescription().replace("%ACTION%", "ManageDialog"));547 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));548 return message;549 } catch (CerberusEventException ex) {550 LOG.fatal("Error doing Action ManageDialog :" + ex);551 return ex.getMessageError();552 }553 }554 private MessageEvent doActionClickWait(TestCaseExecution tCExecution, String string1, String string2) {555 MessageEvent message;556 try {557 Identifier identifier = identifierService.convertStringToIdentifier(string1);558 identifierService.checkWebElementIdentifier(identifier.getIdentifier());559 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {560 message = webdriverService.doSeleniumActionClick(tCExecution.getSession(), identifier, true, true);561 if (message.getCodeString().equals("OK")) {562 message = this.doActionWait(tCExecution, string2, null);563 }564 return message;565 }566 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);567 message.setDescription(message.getDescription().replace("%ACTION%", "ClickAndWait"));568 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", string1));569 return message;570 } catch (CerberusEventException ex) {571 LOG.fatal("Error doing Action ClickAndWait :" + ex);572 return ex.getMessageError();573 }574 }575 private MessageEvent doActionDoubleClick(TestCaseExecution tCExecution, String object, String property) {576 MessageEvent message;577 String element;578 try {579 /**580 * Get element to use String object if not empty, String property if581 * object empty, throws Exception if both empty)582 */583 element = getElementToUse(object, property, "doubleClick", tCExecution);584 /**585 * Get Identifier (identifier, locator)586 */587 Identifier identifier = identifierService.convertStringToIdentifier(element);588 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {589 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {590 return sikuliService.doSikuliActionDoubleClick(tCExecution.getSession(), identifier.getLocator(), "");591 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {592 return sikuliService.doSikuliActionDoubleClick(tCExecution.getSession(), "", identifier.getLocator());593 } else {594 identifierService.checkWebElementIdentifier(identifier.getIdentifier());595 return webdriverService.doSeleniumActionDoubleClick(tCExecution.getSession(), identifier, true, true);596 }597 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)598 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {599 identifierService.checkWebElementIdentifier(identifier.getIdentifier());600 return webdriverService.doSeleniumActionDoubleClick(tCExecution.getSession(), identifier, true, false);601 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {602 identifierService.checkSikuliIdentifier(identifier.getIdentifier());603 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {604 return sikuliService.doSikuliActionDoubleClick(tCExecution.getSession(), identifier.getLocator(), "");605 } else {606 return sikuliService.doSikuliActionDoubleClick(tCExecution.getSession(), "", identifier.getLocator());607 }608 }609 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);610 message.setDescription(message.getDescription().replace("%ACTION%", "doubleClick"));611 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));612 return message;613 } catch (CerberusEventException ex) {614 LOG.fatal("Error doing Action DoubleClick :" + ex);615 return ex.getMessageError();616 }617 }618 private MessageEvent doActionType(TestCaseExecution tCExecution, String object, String property, String propertyName) {619 try {620 /**621 * Check object and property are not null for GUI/APK/IPA Check622 * property is not null for FAT Application623 */624 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)625 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)626 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {627 if (object == null || property == null) {628 return new MessageEvent(MessageEventEnum.ACTION_FAILED_TYPE);629 }630 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {631 if (property == null) {632 return new MessageEvent(MessageEventEnum.ACTION_FAILED_TYPE);633 }634 }635 /**636 * Get Identifier (identifier, locator) if object not null637 */638 Identifier identifier = new Identifier();639 if (object != null) {640 identifier = identifierService.convertStringToIdentifier(object);641 }642 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {643 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {644 return sikuliService.doSikuliActionType(tCExecution.getSession(), identifier.getLocator(), property);645 } else {646 identifierService.checkWebElementIdentifier(identifier.getIdentifier());647 return webdriverService.doSeleniumActionType(tCExecution.getSession(), identifier, property, propertyName);648 }649 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {650 return androidAppiumService.type(tCExecution.getSession(), identifier, property, propertyName);651 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {652 return iosAppiumService.type(tCExecution.getSession(), identifier, property, propertyName);653 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {654 String locator = "";655 if (!StringUtil.isNullOrEmpty(object)) {656 identifierService.checkSikuliIdentifier(identifier.getIdentifier());657 locator = identifier.getLocator();658 }659 return sikuliService.doSikuliActionType(tCExecution.getSession(), locator, property);660 } else {661 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION)662 .resolveDescription("ACTION", "Type")663 .resolveDescription("APPLICATIONTYPE", tCExecution.getApplicationObj().getType());664 }665 } catch (CerberusEventException ex) {666 LOG.fatal("Error doing Action Type : " + ex);667 return ex.getMessageError();668 }669 }670 private MessageEvent doActionMouseOver(TestCaseExecution tCExecution, String object, String property) {671 MessageEvent message;672 String element;673 try {674 /**675 * Get element to use String object if not empty, String property if676 * object empty, throws Exception if both empty)677 */678 element = getElementToUse(object, property, "mouseOver", tCExecution);679 /**680 * Get Identifier (identifier, locator)681 */682 Identifier identifier = identifierService.convertStringToIdentifier(element);683 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {684 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {685 return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "");686 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {687 return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator());688 } else {689 identifierService.checkWebElementIdentifier(identifier.getIdentifier());690 return webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier);691 }692 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {693 identifierService.checkSikuliIdentifier(identifier.getIdentifier());694 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {695 return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "");696 } else {697 return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator());698 }699 }700 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);701 message.setDescription(message.getDescription().replace("%ACTION%", "mouseOver"));702 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));703 return message;704 } catch (CerberusEventException ex) {705 LOG.fatal("Error doing Action MouseOver :" + ex);706 return ex.getMessageError();707 }708 }709 private MessageEvent doActionMouseOverAndWait(TestCaseExecution tCExecution, String object, String property) {710 MessageEvent message;711 try {712 /**713 * Check object is not null714 */715 if (object == null) {716 return new MessageEvent(MessageEventEnum.ACTION_FAILED_MOUSEOVERANDWAIT_GENERIC);717 }718 /**719 * Get Identifier (identifier, locator)720 */721 Identifier identifier = identifierService.convertStringToIdentifier(object);722 identifierService.checkWebElementIdentifier(identifier.getIdentifier());723 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {724 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {725 message = sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "");726 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {727 message = sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator());728 } else {729 message = webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier);730 }731 if (message.getCodeString().equals("OK")) {732 message = this.doActionWait(tCExecution, property, null);733 }734 return message;735 }736 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);737 message.setDescription(message.getDescription().replace("%ACTION%", "mouseOverAndWait"));738 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));739 return message;740 } catch (CerberusEventException ex) {741 LOG.fatal("Error doing Action MouseOverAndWait :" + ex);742 return ex.getMessageError();743 }744 }745 private MessageEvent doActionWait(TestCaseExecution tCExecution, String object, String property) {746 MessageEvent message;747 String element;748 long timeToWaitInMs = 0;749 Identifier identifier = null;750 try {751 /**752 * Get element to use String object if not empty, String property if753 * object empty, null if both are empty754 */755 element = getElementToUse(object, property, "wait", tCExecution);756 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)757 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)758 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)759 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) { // If application are Selenium or appium based, we have a session and can use it to wait.760 /**761 * if element is integer, set time to that value else Get762 * Identifier (identifier, locator)763 */764 if (StringUtil.isNullOrEmpty(element)) {765 timeToWaitInMs = tCExecution.getCerberus_action_wait_default();766 } else if (StringUtil.isInteger(element)) {767 timeToWaitInMs = Long.valueOf(element);768 } else {769 identifier = identifierService.convertStringToIdentifier(element);770 }771 if (identifier != null && identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {772 return sikuliService.doSikuliActionWait(tCExecution.getSession(), identifier.getLocator(), "");773 } else if (identifier != null && identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {774 return sikuliService.doSikuliActionWait(tCExecution.getSession(), "", identifier.getLocator());775 } else if (identifier != null) {776 identifierService.checkWebElementIdentifier(identifier.getIdentifier());777 return webdriverService.doSeleniumActionWait(tCExecution.getSession(), identifier);778 } else {779 return this.waitTime(timeToWaitInMs);780 }781 } else { // For any other application we wait for the integer value.782 if (StringUtil.isNullOrEmpty(element)) {783 // Get default wait from parameter784 timeToWaitInMs = tCExecution.getCerberus_action_wait_default();785 } else if (StringUtil.isInteger(element)) {786 timeToWaitInMs = Long.valueOf(element);787 }788 return this.waitTime(timeToWaitInMs);789 }790 } catch (CerberusEventException ex) {791 LOG.fatal("Error doing Action Wait :" + ex);792 return ex.getMessageError();793 }794 }795 private MessageEvent doActionKeyPress(TestCaseExecution tCExecution, String value1, String value2) {796 try {797 String appType = tCExecution.getApplicationObj().getType();798 /**799 * Check object and property are not null For IPA and APK, only800 * value2 (key to press) is mandatory For GUI and FAT, both801 * parameters are mandatory802 */803// if (appType.equalsIgnoreCase(Application.TYPE_APK) || appType.equalsIgnoreCase(Application.TYPE_IPA)) {804 if (StringUtil.isNullOrEmpty(value2)) {805 return new MessageEvent(MessageEventEnum.ACTION_FAILED_KEYPRESS_MISSINGKEY).resolveDescription("APPLICATIONTYPE", appType);806 }807// } else if (appType.equalsIgnoreCase(Application.TYPE_GUI) || appType.equalsIgnoreCase(Application.TYPE_FAT)) {808// if (StringUtil.isNullOrEmpty(value1) || StringUtil.isNullOrEmpty(value2)) {809// return new MessageEvent(MessageEventEnum.ACTION_FAILED_KEYPRESS);810// }811// }812 /**813 * Get Identifier (identifier, locator)814 */815 Identifier objectIdentifier = identifierService.convertStringToIdentifier(value1);816 if (appType.equalsIgnoreCase(Application.TYPE_GUI)) {817 if (objectIdentifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {818 return sikuliService.doSikuliActionKeyPress(tCExecution.getSession(), objectIdentifier.getLocator(), value2);819 } else {820 identifierService.checkWebElementIdentifier(objectIdentifier.getIdentifier());821 return webdriverService.doSeleniumActionKeyPress(tCExecution.getSession(), objectIdentifier, value2);822 }823 } else if (appType.equalsIgnoreCase(Application.TYPE_APK)) {824 return androidAppiumService.keyPress(tCExecution.getSession(), value2);825 } else if (appType.equalsIgnoreCase(Application.TYPE_IPA)) {826 return iosAppiumService.keyPress(tCExecution.getSession(), value2);827 } else if (appType.equalsIgnoreCase(Application.TYPE_FAT)) {828 return sikuliService.doSikuliActionKeyPress(tCExecution.getSession(), objectIdentifier.getLocator(), value2);829 } else {830 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION)831 .resolveDescription("ACTION", "KeyPress")832 .resolveDescription("APPLICATIONTYPE", appType);833 }834 } catch (CerberusEventException ex) {835 LOG.fatal("Error doing Action KeyPress :" + ex);836 return ex.getMessageError();837 }838 }839 private MessageEvent doActionOpenURL(TestCaseExecution tCExecution, String object, String property, boolean withBase) {840 MessageEvent message;841 String element;842 try {843 /**844 * Get element to use String object if not empty, String property if845 * object empty, throws Exception if both empty)846 */847 element = getElementToUse(object, property, "openUrl[WithBase]", tCExecution);848 /**849 * Get Identifier (identifier, locator)850 */851 Identifier identifier = new Identifier();852 identifier.setIdentifier("url");853 identifier.setLocator(element);854 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {855 return webdriverService.doSeleniumActionOpenURL(tCExecution.getSession(), tCExecution.getUrl(), identifier, withBase);856 }857 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);858 message.setDescription(message.getDescription().replace("%ACTION%", "OpenURL[WithBase]"));859 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));860 return message;861 } catch (CerberusEventException ex) {862 LOG.fatal("Error doing Action OpenUrl :" + ex);863 return ex.getMessageError();864 }865 }866 private MessageEvent doActionOpenApp(TestCaseExecution tCExecution, String value1) {867 MessageEvent message;868 /**869 * Check value1 is not null or empty870 */871 if (value1 == null || "".equals(value1)) {872 return new MessageEvent(MessageEventEnum.ACTION_FAILED_OPENAPP);873 }874 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)875 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {876 return sikuliService.doSikuliActionOpenApp(tCExecution.getSession(), value1);877 }878 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);879 message.setDescription(message.getDescription().replace("%ACTION%", "OpenApp"));880 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));881 return message;882 }883 private MessageEvent doActionCloseApp(TestCaseExecution tCExecution, String value1) {884 MessageEvent message;885 /**886 * Check value1 is not null or empty887 */888 if (value1 == null || "".equals(value1)) {889 return new MessageEvent(MessageEventEnum.ACTION_FAILED_CLOSEAPP);890 }891 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)892 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {893 return sikuliService.doSikuliActionCloseApp(tCExecution.getSession(), value1);894 }895 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);896 message.setDescription(message.getDescription().replace("%ACTION%", "CloseApp"));897 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));898 return message;899 }900 private MessageEvent doActionWaitVanish(TestCaseExecution tCExecution, String value1) {901 try {902 /**903 * Check value1 is not null or empty904 */905 if (value1 == null || "".equals(value1)) {906 return new MessageEvent(MessageEventEnum.ACTION_FAILED_CLOSEAPP);907 }908 /**909 * Get Identifier (identifier, locator)910 */911 Identifier identifier = identifierService.convertStringToIdentifier(value1);912 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {913 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {914 return sikuliService.doSikuliActionWaitVanish(tCExecution.getSession(), identifier.getLocator(), "");915 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {916 return sikuliService.doSikuliActionWaitVanish(tCExecution.getSession(), "", identifier.getLocator());917 } else {918 identifierService.checkWebElementIdentifier(identifier.getIdentifier());919 return webdriverService.doSeleniumActionWaitVanish(tCExecution.getSession(), identifier);920 }921 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)922 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {923 identifierService.checkWebElementIdentifier(identifier.getIdentifier());924 return webdriverService.doSeleniumActionWaitVanish(tCExecution.getSession(), identifier);925 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {926 identifierService.checkSikuliIdentifier(identifier.getIdentifier());927 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {928 return sikuliService.doSikuliActionWaitVanish(tCExecution.getSession(), identifier.getLocator(), "");929 } else {930 return sikuliService.doSikuliActionWaitVanish(tCExecution.getSession(), "", identifier.getLocator());931 }932 } else {933 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION)934 .resolveDescription("ACTION", "WaitVanish")935 .resolveDescription("APPLICATIONTYPE", tCExecution.getApplicationObj().getType());936 }937 } catch (CerberusEventException ex) {938 LOG.fatal("Error doing Action KeyPress :" + ex);939 return ex.getMessageError();940 }941 }942 private MessageEvent doActionSelect(TestCaseExecution tCExecution, String value1, String value2) {943 MessageEvent message;944 try {945 /**946 * Check object and property are not null947 */948 if (StringUtil.isNullOrEmpty(value1) || StringUtil.isNullOrEmpty(value2)) {949 return new MessageEvent(MessageEventEnum.ACTION_FAILED_SELECT);950 }951 /**952 * Get Identifier (identifier, locator)953 */954 Identifier identifierObject = identifierService.convertStringToIdentifier(value1);955 Identifier identifierValue = identifierService.convertStringToSelectIdentifier(value2);956 identifierService.checkWebElementIdentifier(identifierObject.getIdentifier());957 identifierService.checkSelectOptionsIdentifier(identifierValue.getIdentifier());958 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)959 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)960 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {961 return webdriverService.doSeleniumActionSelect(tCExecution.getSession(), identifierObject, identifierValue);962 }963 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);964 message.setDescription(message.getDescription().replace("%ACTION%", "Select"));965 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));966 return message;967 } catch (CerberusEventException ex) {968 LOG.fatal("Error doing Action Select :" + ex);969 return ex.getMessageError();970 }971 }972 private MessageEvent doActionUrlLogin(TestCaseExecution tCExecution) {973 MessageEvent message;974 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {975 return webdriverService.doSeleniumActionUrlLogin(tCExecution.getSession(), tCExecution.getUrl(), tCExecution.getCountryEnvironmentParameters().getUrlLogin());976 }977 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);978 message.setDescription(message.getDescription().replace("%ACTION%", "UrlLogin"));979 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));980 return message;981 }982 private MessageEvent doActionFocusToIframe(TestCaseExecution tCExecution, String object, String property) {983 MessageEvent message;984 String element;985 try {986 /**987 * Get element to use String object if not empty, String property if988 * object empty, throws Exception if both empty)989 */990 element = getElementToUse(object, property, "focusToIframe", tCExecution);991 /**992 * Get Identifier (identifier, locator)993 */994 Identifier identifier = identifierService.convertStringToIdentifier(element);995 identifierService.checkWebElementIdentifier(identifier.getIdentifier());996 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {997 return webdriverService.doSeleniumActionFocusToIframe(tCExecution.getSession(), identifier);998 }999 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1000 message.setDescription(message.getDescription().replace("%ACTION%", "FocusToIframe"));1001 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1002 return message;1003 } catch (CerberusEventException ex) {1004 LOG.fatal("Error doing Action FocusToIframe :" + ex);1005 return ex.getMessageError();1006 }1007 }1008 private MessageEvent doActionFocusDefaultIframe(TestCaseExecution tCExecution) {1009 MessageEvent message;1010 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {1011 return webdriverService.doSeleniumActionFocusDefaultIframe(tCExecution.getSession());1012 }1013 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1014 message.setDescription(message.getDescription().replace("%ACTION%", "FocusDefaultIframe"));1015 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1016 return message;1017 }1018 private MessageEvent doActionCallService(TestCaseStepActionExecution testCaseStepActionExecution, String value1) {1019 MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE);1020 TestCaseExecution tCExecution = testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution();1021 AnswerItem lastServiceCalledAnswer;1022 lastServiceCalledAnswer = serviceService.callService(value1, null, null, null, null, tCExecution);1023 message = lastServiceCalledAnswer.getResultMessage();1024 if (lastServiceCalledAnswer.getItem() != null) {1025 AppService lastServiceCalled = (AppService) lastServiceCalledAnswer.getItem();1026 tCExecution.setLastServiceCalled(lastServiceCalled);1027 /**1028 * Record the Request and Response in filesystem.1029 */1030 testCaseStepActionExecution.addFileList(recorderService.recordServiceCall(tCExecution, testCaseStepActionExecution, 0, null, lastServiceCalled));1031 }1032 return message;1033 }1034 private MessageEvent doActionTakeScreenshot(TestCaseStepActionExecution testCaseStepActionExecution) {1035 MessageEvent message;1036 if (testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)1037 || testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)1038 || testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {1039 recorderService.recordScreenshot(testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution(),1040 testCaseStepActionExecution, 0);1041 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_TAKESCREENSHOT);1042 return message;1043 } else if (testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {1044 /**1045 * TODO Implement screenshot for FAT client application1046 */1047 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1048 }1049 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1050 message.setDescription(message.getDescription().replace("%ACTION%", "TakeScreenShot"));1051 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getApplicationObj().getType()));1052 return message;1053 }1054 private MessageEvent doActionGetPageSource(TestCaseStepActionExecution testCaseStepActionExecution) {1055 MessageEvent message;1056 if (testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)1057 || testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)1058 || testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {1059 recorderService.recordPageSource(testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution(), testCaseStepActionExecution, 0);1060 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_GETPAGESOURCE);1061 return message;1062 }1063 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1064 message.setDescription(message.getDescription().replace("%ACTION%", "getPageSource"));1065 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getApplicationObj().getType()));1066 return message;1067 }1068 private MessageEvent doActionRemoveDifference(TestCaseStepActionExecution testCaseStepActionExecution, String object, String property) {1069 // Filters differences from the given object pattern1070 String filteredDifferences = xmlUnitService.removeDifference(object, property);1071 // If filtered differences are null then service has returned with errors1072 if (filteredDifferences == null) {1073 MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_FAILED_REMOVEDIFFERENCE);1074 message.setDescription(message.getDescription().replace("%DIFFERENCE%", object));1075 message.setDescription(message.getDescription().replace("%DIFFERENCES%", property));1076 return message;1077 }1078 // Sets the property value to the new filtered one1079 for (TestCaseExecutionData data : testCaseStepActionExecution.getTestCaseExecutionDataList()) {1080 if (data.getProperty().equals(testCaseStepActionExecution.getPropertyName())) {1081 data.setValue(filteredDifferences);1082 break;1083 }1084 }1085 // Sends success1086 MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_REMOVEDIFFERENCE);1087 message.setDescription(message.getDescription().replace("%DIFFERENCE%", object));1088 message.setDescription(message.getDescription().replace("%DIFFERENCES%", property));1089 return message;1090 }1091 private MessageEvent doActionCalculateProperty(TestCaseStepActionExecution testCaseStepActionExecution, String value1, String value2) {1092 MessageEvent message;1093 AnswerItem<String> answerDecode = new AnswerItem();1094 if (StringUtil.isNullOrEmpty(value1)) {1095 // Value1 is a mandatory parameter.1096 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALCULATEPROPERTY_MISSINGPROPERTY);1097 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY));1098 } else {1099 try {1100 TestCaseExecution tCExecution = testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution();1101 // Getting the Country property definition.1102 TestCaseCountryProperties tccp = null;1103 boolean propertyExistOnAnyCountry = false;1104 for (TestCaseCountryProperties object : tCExecution.getTestCaseCountryPropertyList()) {1105 if ((object.getProperty().equalsIgnoreCase(value1)) && (object.getCountry().equalsIgnoreCase(tCExecution.getCountry()))) {1106 tccp = object;1107 }1108 if ((object.getProperty().equalsIgnoreCase(value1))) {1109 propertyExistOnAnyCountry = true;1110 }1111 }1112 if (tccp == null) { // Could not find a country property inside the existing execution.1113 if (propertyExistOnAnyCountry) {1114 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NO_PROPERTY_DEFINITION);...

Full Screen

Full Screen

Source:RecorderService.java Github

copy

Full Screen

...85 String applicationType;86 String returnCode;87 Integer controlNumber = 0;88 if (testCaseStepActionControlExecution == null) {89 myExecution = testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution();90 doScreenshot = testCaseStepActionExecution.getActionResultMessage().isDoScreenshot();91 getPageSource = testCaseStepActionExecution.getActionResultMessage().isGetPageSource();92 applicationType = testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getApplicationObj().getType();93 returnCode = testCaseStepActionExecution.getReturnCode();94 } else {95 myExecution = testCaseStepActionControlExecution.getTestCaseStepActionExecution().getTestCaseStepExecution().gettCExecution();96 doScreenshot = testCaseStepActionControlExecution.getControlResultMessage().isDoScreenshot();97 getPageSource = testCaseStepActionControlExecution.getControlResultMessage().isGetPageSource();98 applicationType = testCaseStepActionControlExecution.getTestCaseStepActionExecution().getTestCaseStepExecution().gettCExecution().getApplicationObj().getType();99 returnCode = testCaseStepActionControlExecution.getReturnCode();100 controlNumber = testCaseStepActionControlExecution.getControlSequence();101 }102 /**103 * SCREENSHOT Management. Screenshot only done when : screenshot104 * parameter is eq to 2 or screenshot parameter is eq to 1 with the105 * correct doScreenshot flag on the last action MessageEvent.106 */107 if ((myExecution.getScreenshot() == 2) || ((myExecution.getScreenshot() == 1) && (doScreenshot))) {108 if (applicationType.equals(Application.TYPE_GUI)109 || applicationType.equals(Application.TYPE_APK)110 || applicationType.equals(Application.TYPE_IPA)111 || applicationType.equals(Application.TYPE_FAT)) {112 /**113 * Only if the return code is not equal to Cancel, meaning lost114 * connectivity with selenium.115 */116 if (!returnCode.equals("CA")) {117 objectFile = this.recordScreenshot(myExecution, testCaseStepActionExecution, controlNumber);118 if (objectFile != null) {119 objectFileList.add(objectFile);120 }121 } else {122 LOG.debug(logPrefix + "Not Doing screenshot because connectivity with selenium server lost.");123 }124 }125 } else {126 LOG.debug(logPrefix + "Not Doing screenshot because of the screenshot parameter or flag on the last Action result.");127 }128 /**129 * PAGESOURCE management. Get PageSource if requested by the last Action130 * MessageEvent.131 *132 */133 if ((myExecution.getPageSource() == 2) || ((myExecution.getPageSource() == 1) && (getPageSource))) {134 if (applicationType.equals(Application.TYPE_GUI)135 || applicationType.equals(Application.TYPE_APK)136 || applicationType.equals(Application.TYPE_IPA)) {137 /**138 * Only if the return code is not equal to Cancel, meaning lost139 * connectivity with selenium.140 */141 if (!returnCode.equals("CA")) {142 objectFile = this.recordPageSource(myExecution, testCaseStepActionExecution, controlNumber);143 if (objectFile != null) {144 objectFileList.add(objectFile);145 }146 } else {147 LOG.debug(logPrefix + "Not Doing screenshot because connectivity with selenium server lost.");148 }149 }150 } else {151 LOG.debug(logPrefix + "Not getting page source because of the pageSource parameter or flag on the last Action result.");152 }153 /**154 * Last call XML SOURCE management. Get Source of the XML if requested155 * by the last Action or control MessageEvent.156 *157 */158 if (applicationType.equals(Application.TYPE_SRV)159 && ((myExecution.getPageSource() == 2) || ((myExecution.getPageSource() == 1) && (getPageSource))160 || (myExecution.getScreenshot() == 2) || ((myExecution.getScreenshot() == 1) && (doScreenshot)))) {161 //Record the Request and Response.162 AppService se = (AppService) testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getLastServiceCalled();163 if (se != null) { // No Calls were performed previously164 List<TestCaseExecutionFile> objectFileSOAPList = new ArrayList<TestCaseExecutionFile>();165 objectFileSOAPList = this.recordServiceCall(myExecution, testCaseStepActionExecution, controlNumber, null, se);166 if (objectFileSOAPList.isEmpty() != true) {167 for (TestCaseExecutionFile testCaseExecutionFile : objectFileSOAPList) {168 objectFileList.add(testCaseExecutionFile);169 }170 }171 }172 }173 return objectFileList;174 }175 @Override176 public AnswerItem recordManuallyFile(TestCaseStepActionExecution testCaseStepActionExecution, TestCaseStepActionControlExecution testCaseStepActionControlExecution, String extension, String desc, FileItem file, Integer id, String fileName, Integer fileID) {177 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION",178 "Can't upload file");179 AnswerItem a = new AnswerItem();180 TestCaseExecutionFile object = null;181 String returnCode;182 Integer controlNumber = 0;183 String test = "";184 String testCase = "";185 String step = "";186 String index = "";187 String sequence = "";188 String controlString = "";189 Integer myExecution = id;190 if (testCaseStepActionControlExecution == null) {191 test = testCaseStepActionExecution.getTest();192 testCase = testCaseStepActionExecution.getTestCase();193 step = String.valueOf(testCaseStepActionExecution.getStep());194 index = String.valueOf(testCaseStepActionExecution.getIndex());195 sequence = String.valueOf(testCaseStepActionExecution.getSequence());196 controlString = controlNumber.equals(0) ? null : String.valueOf(controlNumber);197 returnCode = testCaseStepActionExecution.getReturnCode();198 } else {199 returnCode = testCaseStepActionControlExecution.getReturnCode();200 controlNumber = testCaseStepActionControlExecution.getControlSequence();201 test = testCaseStepActionControlExecution.getTest();202 testCase = testCaseStepActionControlExecution.getTestCase();203 step = String.valueOf(testCaseStepActionControlExecution.getStep());204 index = String.valueOf(testCaseStepActionControlExecution.getIndex());205 sequence = String.valueOf(testCaseStepActionControlExecution.getSequence());206 controlString = controlNumber.equals(0) ? null : String.valueOf(controlNumber);207 }208 // Used for logging purposes209 String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - [" + test + " - " + testCase + " - step: " + step + " action: " + sequence + "] ";210 try {211 Recorder recorder = new Recorder();212 String name = "";213 File dir = null;214 if (file != null) {215 name = file.getName();216 extension = name.substring(name.lastIndexOf('.') + 1, name.length());217 extension = extension.toUpperCase();218 extension = testCaseExecutionFileService.checkExtension(name, extension);219 recorder = this.initFilenames(myExecution, test, testCase, step, index, sequence, controlString, null, 0, name.substring(0, name.lastIndexOf('.')), extension, true);220 dir = new File(recorder.getFullPath());221 } else {222 name = fileName;223 extension = testCaseExecutionFileService.checkExtension(name, extension);224 if (name.contains(".")) {225 recorder = this.initFilenames(myExecution, test, testCase, step, index, sequence, controlString, null, 0, name.substring(0, name.lastIndexOf('.')), extension, true);226 dir = new File(recorder.getFullPath());227 } else {228 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);229 msg.setDescription(msg.getDescription().replace("%ITEM%", "manual testcase execution file")230 .replace("%OPERATION%", "Create")231 .replace("%REASON%", "file is missing!"));232 a.setResultMessage(msg);233 return a;234 }235 }236 if (!dir.exists()) {237 try {238 boolean isCreated = dir.mkdirs();239 if (!isCreated) {240 throw new SecurityException();241 }242 } catch (SecurityException se) {243 LOG.warn("Unable to create manual execution file dir: " + se.getMessage());244 msg = new MessageEvent(MessageEventEnum.FILE_ERROR).resolveDescription("DESCRIPTION",245 se.toString()).resolveDescription("MORE", "Please check the parameter cerberus_exemanualmedia_path");246 a.setResultMessage(msg);247 return a;248 }249 }250 if (file != null) {251 AnswerItem<TestCaseExecutionFile> current = testCaseExecutionFileService.readByKey(myExecution, recorder.getLevel(), desc);252 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);253 if (current.getItem() != null) {254 try {255 File temp = new File(recorder.getRootFolder() + current.getItem().getFileName());256 temp.delete();257 } catch (SecurityException se) {258 LOG.warn("Unable to create manual execution file dir: " + se.getMessage());259 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION",260 se.toString());261 }262 }263 try {264 file.write(new File(recorder.getFullFilename()));265 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK).resolveDescription("DESCRIPTION",266 "Manual Execution File uploaded");267 msg.setDescription(msg.getDescription().replace("%ITEM%", "Manual Execution File").replace("%OPERATION%", "Upload"));268 LOG.debug(logPrefix + "Copy file finished with success - source: " + file.getName() + " destination: " + recorder.getRelativeFilenameURL());269 object = testCaseExecutionFileFactory.create(fileID, myExecution, recorder.getLevel(), desc, recorder.getRelativeFilenameURL(), extension, "", null, "", null);270 } catch (Exception e) {271 LOG.warn("Unable to upload Manual Execution File: " + e.getMessage());272 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION",273 e.toString());274 }275 } else {276 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK).resolveDescription("DESCRIPTION",277 "Manual Execution File updated");278 msg.setDescription(msg.getDescription().replace("%ITEM%", "Manual Execution File").replace("%OPERATION%", "updated"));279 LOG.debug(logPrefix + "Updated test case manual file finished with success");280 object = testCaseExecutionFileFactory.create(fileID, myExecution, recorder.getLevel(), desc, name, extension, "", null, "", null);281 }282 testCaseExecutionFileService.saveManual(object);283 } catch (CerberusException e) {284 LOG.error(logPrefix + e.toString());285 }286 a.setResultMessage(msg);287 a.setItem(object);288 return a;289 }290 @Override291 public TestCaseExecutionFile recordScreenshot(TestCaseExecution testCaseExecution, TestCaseStepActionExecution testCaseStepActionExecution, Integer control) {292 TestCaseExecutionFile object = null;293 String test = testCaseStepActionExecution.getTest();294 String testCase = testCaseStepActionExecution.getTestCase();295 String step = String.valueOf(testCaseStepActionExecution.getStep());296 String index = String.valueOf(testCaseStepActionExecution.getIndex());297 String sequence = String.valueOf(testCaseStepActionExecution.getSequence());298 String controlString = control.equals(0) ? null : String.valueOf(control);299 long runId = testCaseExecution.getId();300 String applicationType = testCaseExecution.getApplicationObj().getType();301 // Used for logging purposes302 String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - [" + test + " - " + testCase + " - step: " + step + " action: " + sequence + "] ";303 LOG.debug(logPrefix + "Doing screenshot.");304 /**305 * Take Screenshot and write it306 */307 File newImage = null;308 if (applicationType.equals(Application.TYPE_GUI)309 || applicationType.equals(Application.TYPE_APK)310 || applicationType.equals(Application.TYPE_IPA)) {311 newImage = this.webdriverService.takeScreenShotFile(testCaseExecution.getSession());312 } else if (applicationType.equals(Application.TYPE_FAT)) {313 newImage = this.sikuliService.takeScreenShotFile(testCaseExecution.getSession());314 }315 if (newImage != null) {316 try {317 Recorder recorder = this.initFilenames(runId, test, testCase, step, index, sequence, controlString, null, 0, "screenshot", "png", false);318 LOG.debug(logPrefix + "FullPath " + recorder.getFullPath());319 File dir = new File(recorder.getFullPath());320 if (!dir.exists()) {321 LOG.debug(logPrefix + "Create directory for execution " + recorder.getFullPath());322 dir.mkdirs();323 }324 // Getting the max size of the screenshot.325 long maxSizeParam = parameterService.getParameterIntegerByKey("cerberus_screenshot_max_size", "", 1048576);326 if (maxSizeParam < newImage.length()) {327 LOG.warn(logPrefix + "Screen-shot size exceeds the maximum defined in configurations " + newImage.getName() + " destination: " + recorder.getRelativeFilenameURL());328 }329 //copies the temp file to the execution file330 FileUtils.copyFile(newImage, new File(recorder.getFullFilename()));331 LOG.debug(logPrefix + "Copy file finished with success - source: " + newImage.getName() + " destination: " + recorder.getRelativeFilenameURL());332 // Index file created to database.333 object = testCaseExecutionFileFactory.create(0, testCaseExecution.getId(), recorder.getLevel(), "Screenshot", recorder.getRelativeFilenameURL(), "PNG", "", null, "", null);334 testCaseExecutionFileService.save(object);335 //deletes the temporary file336 FileUtils.forceDelete(newImage);337 LOG.debug(logPrefix + "Temp file deleted with success " + newImage.getName());338 LOG.debug(logPrefix + "Screenshot done in : " + recorder.getRelativeFilenameURL());339 } catch (IOException ex) {340 LOG.error(logPrefix + ex.toString());341 } catch (CerberusException ex) {342 LOG.error(logPrefix + ex.toString());343 }344 } else {345 LOG.warn(logPrefix + "Screenshot returned null.");346 }347 return object;348 }349 @Override350 public TestCaseExecutionFile recordPageSource(TestCaseExecution testCaseExecution, TestCaseStepActionExecution testCaseStepActionExecution, Integer control) {351 // Used for logging purposes352 String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - ";353 LOG.debug(logPrefix + "Starting to save Page Source File.");354 TestCaseExecutionFile object = null;355 String test = testCaseExecution.getTest();356 String testCase = testCaseExecution.getTestCase();357 String step = String.valueOf(testCaseStepActionExecution.getStep());358 String index = String.valueOf(testCaseStepActionExecution.getIndex());359 String sequence = String.valueOf(testCaseStepActionExecution.getSequence());360 String controlString = control.equals(0) ? null : String.valueOf(control);361 try {362 Recorder recorder = this.initFilenames(testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getId(), test, testCase, step, index, sequence, controlString, null, 0, "pagesource", "html", false);363 File dir = new File(recorder.getFullPath());364 dir.mkdirs();365 File file = new File(recorder.getFullFilename());366 try(FileOutputStream fileOutputStream = new FileOutputStream(file);) {367 fileOutputStream.write(this.webdriverService.getPageSource(testCaseExecution.getSession()).getBytes());368 fileOutputStream.close();369 // Index file created to database.370 object = testCaseExecutionFileFactory.create(0, testCaseExecution.getId(), recorder.getLevel(), "Page Source", recorder.getRelativeFilenameURL(), "HTML", "", null, "", null);371 testCaseExecutionFileService.save(object);372 } catch (FileNotFoundException ex) {373 LOG.error(logPrefix + ex.toString());374 } catch (IOException ex) {375 LOG.error(logPrefix + ex.toString());376 }...

Full Screen

Full Screen

getTestCaseStepExecution

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.factory.impl;2import java.util.ArrayList;3import java.util.List;4import org.cerberus.crud.entity.TestCaseStepActionExecution;5import org.cerberus.crud.factory.IFactoryTestCaseStepActionExecution;6import org.springframework.stereotype.Service;7public class FactoryTestCaseStepActionExecution implements IFactoryTestCaseStepActionExecution {8 public TestCaseStepActionExecution create(long id, long idTestCaseStep, String test, String testCase, int step, String action, String object, String property, String description, String fatal, String conditionOperator, String conditionVal1, String conditionVal2, String conditionVal3, String conditionOptions, String screenshotFilename, String pageSourceFilename, String seleniumLogFilename, String returnCode, String returnMessage, String controlStatus, String controlMessage, String start, String end, String fullStart, String fullEnd, String retryNb, String manualURL, String manualExecution, String usrCreated, String dateCreated, String usrModif, String dateModif) {9 TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();10 testCaseStepActionExecution.setId(id);11 testCaseStepActionExecution.setIdTestCaseStep(idTestCaseStep);12 testCaseStepActionExecution.setTest(test);13 testCaseStepActionExecution.setTestCase(testCase);14 testCaseStepActionExecution.setStep(step);15 testCaseStepActionExecution.setAction(action);16 testCaseStepActionExecution.setObject(object);17 testCaseStepActionExecution.setProperty(property);18 testCaseStepActionExecution.setDescription(description);19 testCaseStepActionExecution.setFatal(fatal);20 testCaseStepActionExecution.setConditionOperator(conditionOperator);21 testCaseStepActionExecution.setConditionVal1(conditionVal1);22 testCaseStepActionExecution.setConditionVal2(conditionVal2);23 testCaseStepActionExecution.setConditionVal3(conditionVal3);24 testCaseStepActionExecution.setConditionOptions(conditionOptions);25 testCaseStepActionExecution.setScreenshotFilename(screenshotFilename);26 testCaseStepActionExecution.setPageSourceFilename(pageSourceFilename);27 testCaseStepActionExecution.setSeleniumLogFilename(seleniumLogFilename);28 testCaseStepActionExecution.setReturnCode(returnCode);29 testCaseStepActionExecution.setReturnMessage(returnMessage);30 testCaseStepActionExecution.setControlStatus(controlStatus);31 testCaseStepActionExecution.setControlMessage(controlMessage);32 testCaseStepActionExecution.setStart(start);33 testCaseStepActionExecution.setEnd(end);

Full Screen

Full Screen

getTestCaseStepExecution

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import org.cerberus.crud.entity.TestCaseStepExecution;3import org.cerberus.crud.entity.TestCaseStepActionExecution;4import org.cerberus.crud.entity.TestCaseStepActionControlExecution;5import java.util.ArrayList;6import java.util.List;7public class TestCaseStepExecution {8 private int id;9 private int test;10 private int testCase;11 private int step;12 private int index;13 private String loop;14 private String conditionOperator;15 private String conditionVal1;16 private String conditionVal2;17 private String conditionVal3;18 private String conditionOptions;19 private String returnCode;20 private String returnMessage;21 private String description;22 private String fatal;23 private String screenshotFilename;24 private String pageSourceFilename;25 private String seleniumLogFilename;26 private String timeout;27 private String retries;28 private String manualExecution;29 private String usrCreated;30 private String dateCreated;31 private String usrModif;32 private String dateModif;33 private List<TestCaseStepActionExecution> testCaseStepActionExecutionList;34 private List<TestCaseStepActionControlExecution> testCaseStepActionControlExecutionList;35 public TestCaseStepExecution() {36 this.testCaseStepActionExecutionList = new ArrayList<TestCaseStepActionExecution>();37 this.testCaseStepActionControlExecutionList = new ArrayList<TestCaseStepActionControlExecution>();38 }39 public TestCaseStepExecution(int id, int test, int testCase, int step, int index, String loop, String conditionOperator, String conditionVal1, String conditionVal2, String conditionVal3, String conditionOptions, String returnCode, String returnMessage, String description, String fatal, String screenshotFilename, String pageSourceFilename, String seleniumLogFilename, String timeout, String retries, String manualExecution, String usrCreated, String dateCreated, String usrModif, String dateModif, List<TestCaseStepActionExecution> testCaseStepActionExecutionList, List<TestCaseStepActionControlExecution> testCaseStepActionControlExecutionList) {40 this.id = id;41 this.test = test;42 this.testCase = testCase;43 this.step = step;44 this.index = index;45 this.loop = loop;46 this.conditionOperator = conditionOperator;47 this.conditionVal1 = conditionVal1;48 this.conditionVal2 = conditionVal2;49 this.conditionVal3 = conditionVal3;

Full Screen

Full Screen

getTestCaseStepExecution

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import org.cerberus.crud.entity.TestCaseStep;3import org.cerberus.crud.entity.TestCaseStepAction;4import org.cerberus.crud.entity.TestCaseStepExecution;5import org.cerberus.crud.entity.TestCaseStepActionExecution;6import org.cerberus.crud.entity.TestCaseExecution;7import org.cerberus.crud.entity.TestCaseStepActionControlExecution;8public class TestCaseStepActionExecution {9 private long id;10 private String test;11 private String testCase;12 private int step;13 private int index;14 private String returnCode;15 private String returnMessage;16 private String description;17 private String fullDesc;18 private String screenshotFileName;19 private String pageSourceFileName;20 private String verbose;21 private String verboseThumbnail;22 private String controlStatus;23 private String controlMessage;24 private String start;25 private String end;26 private String startLong;27 private String endLong;28 private int sort;29 private int retryNb;30 private int timeElapsed;31 private int timeElapsedInWaiting;32 private String returnCodeConditionOperator;33 private String returnCodeConditionControlValue;34 private String returnCodeConditionControlOptions;35 private String returnCodeConditionControlProperty;36 private String returnCodeConditionControlValue2;37 private String returnCodeConditionControlOptions2;38 private String returnCodeConditionControlProperty2;39 private String returnCodeConditionControlValue3;40 private String returnCodeConditionControlOptions3;41 private String returnCodeConditionControlProperty3;42 private String returnCodeConditionControlValue4;43 private String returnCodeConditionControlOptions4;44 private String returnCodeConditionControlProperty4;45 private String returnCodeConditionControlValue5;46 private String returnCodeConditionControlOptions5;47 private String returnCodeConditionControlProperty5;48 private String returnCodeConditionControlValue6;49 private String returnCodeConditionControlOptions6;50 private String returnCodeConditionControlProperty6;51 private String returnCodeConditionControlValue7;52 private String returnCodeConditionControlOptions7;53 private String returnCodeConditionControlProperty7;54 private String returnCodeConditionControlValue8;55 private String returnCodeConditionControlOptions8;56 private String returnCodeConditionControlProperty8;57 private String returnCodeConditionControlValue9;58 private String returnCodeConditionControlOptions9;

Full Screen

Full Screen

getTestCaseStepExecution

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.List;3import org.cerberus.engine.entity.MessageEvent;4import org.cerberus.engine.entity.MessageGeneral;5import org.cerberus.engine.entity.MessageGeneralEnum;6import org.cerberus.engine.entity.MessageEventEnum;7import org.cerberus.engine.entity.MessageEventFactory;8import org.cerberus.engine.entity.MessageGeneralFactory;9import org.cerberus.engine.execution.IExecution;10import org.cerberus.engine.execution.impl.*;11import org.cerberus.crud.entity.*;12import org.cerberus.crud.factory.*;13import org.cerberus.crud.service.*;14import org.cerberus.crud.service.impl.*;15import org.cerberus.util.answer.*;16import org.cerberus.crud.entity.*;17import org.cerberus.crud.factory.*;18import org.cerberus.crud.service.*;19import org.cerberus.crud.service.impl.*;20import org.cerberus.util.answer.*;21import org.cerberus.crud.entity.*;22import org.cerberus.crud.factory.*;23import org.cerberus.crud.service.*;24import org.cerberus.crud.service.impl.*;25import org.cerberus.util.answer.*;26import org.cerberus.crud.entity.*;27import org.cerberus.crud.factory.*;28import org.cerberus.crud.service.*;29import org.cerberus.crud.service.impl.*;30import org.cerberus.util.answer.*;31import org.cerberus.crud.entity.*;32import org.cerberus.crud.factory.*;33import org.cerberus.crud.service.*;34import org.cerberus.crud.service.impl.*;35import org.cerberus.util.answer.*;36import org.cerberus.crud.entity.*;37import org.cerberus.crud.factory.*;38import org.cerberus.crud.service.*;39import org.cerberus.crud.service.impl.*;40import org.cerberus.util.answer.*;41import org.cerberus.crud.entity.*;42import org.cerberus.crud.factory.*;43import org.cerberus.crud.service.*;44import org.cerberus.crud.service.impl.*;45import org.cerberus.util.answer.*;46import org.cerberus.crud.entity.*;47import org.cerberus.crud.factory.*;48import org.cerberus.crud.service.*;49import org.cerberus.crud.service.impl.*;50import

Full Screen

Full Screen

getTestCaseStepExecution

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.Date;3import java.util.List;4public class TestCaseStepExecution {5 private int id;6 private int test;7 private int testCase;8 private int step;9 private String description;10 private String useStep;11 private String useStepTest;12 private String useStepTestCase;13 private int useStepStep;14 private String inLibrary;15 private String loop;16 private String conditionOper;17 private String conditionVal1;18 private String conditionVal2;19 private String conditionVal3;20 private String conditionOptions;21 private String fatal;22 private String status;23 private String returnCode;24 private String returnMessage;25 private String screenshotFilename;26 private String pageSourceFilename;27 private String seleniumLogFilename;28 private String verbose;29 private String timeout;30 private String retries;31 private String manualExecution;32 private Date start;33 private Date end;34 private String controlled;35 private String controlledStatus;36 private String application;37 private String country;38 private String environment;39 private String browser;40 private String browserFullVersion;41 private String browserVersion;42 private String platform;43 private String screenSize;44 private String robotDecli;45 private String robotHost;46 private String robotPort;47 private String robotPlatform;48 private String robotBrowser;49 private String robotBrowserVersion;50 private String myHost;51 private String myContextRoot;52 private String myLoginRelativeURL;53 private String myEnvData;54 private String myCerberusUrl;55 private String myCerberusLogin;56 private String myCerberusPassword;57 private String seleniumIP;58 private String seleniumPort;59 private String seleniumBrowser;60 private String seleniumBrowserVersion;61 private String seleniumPlatform;62 private String seleniumCapabilities;63 private String usrCreated;64 private Date dateCreated;65 private String usrModif;66 private Date dateModif;67 private String robotExecutor;68 private String robotExecutorIP;69 private String robotExecutorPort;70 private String robotExecutorBrowser;71 private String robotExecutorBrowserVersion;72 private String robotExecutorPlatform;73 private String robotExecutorCapabilities;74 private String robotExecutorResponseTime;75 private String robotExecutorScreenshotURL;76 private String robotExecutorPageSourceURL;

Full Screen

Full Screen

getTestCaseStepExecution

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.factory;2import org.cerberus.crud.entity.TestCaseStepActionExecution;3import org.cerberus.crud.factory.IFactoryTestCaseStepActionExecution;4import org.springframework.stereotype.Service;5public class FactoryTestCaseStepActionExecution implements IFactoryTestCaseStepActionExecution {6 public TestCaseStepActionExecution create(long id, String test, String testCase, int step, int sequence, String conditionOperator, String conditionValue1, String conditionValue2, String conditionValue3, String description, String action, String value1, String value2, String value3, String fatal, String screenshotFilename, String pageSourceFilename, String timeout, String retries, String verbose, String seleniumLog, String robot, String robotDecli, String robotHost, String robotPort, String robotPlatform, String robotBrowser, String robotBrowserVersion, String robotUrl, String robotUrlService, String robotContextRoot, String robotTimeout, String robotRetryNb, String robotRetryPeriod, String robotOutputDirectory, String robotScreenshotURL, String robotScreenshotURLHost, String robotScreenshotURLPort, String robotScreenshotURLContextRoot, String robotPageSourceURL, String robotPageSourceURLHost, String robotPageSourceURLPort, String robotPageSourceURLContextRoot, String robotOutputURL, String robotOutputURLHost, String robotOutputURLPort, String robotOutputURLContextRoot, String robotProxyHost, String robotProxyPort, String robotProxyUser, String robotProxyPassword, String robotProxyCerberus, String robotProxyCerberusHost, String robotProxyCerberusPort, String robotProxyCerberusContextRoot, String robotCapabilities, String robotCapabilitiesToExclude, String robotExecutor, String robotIndex, String robotHubHost, String robotHubPort, String robotOptions, String robotOptionsToExclude, String robotOptionsBrowser, String robotOptionsBrowserToExclude, String robotOptionsPlatform, String robotOptionsPlatformToExclude, String robotOptionsVersion, String robotOptionsVersionToExclude, String robotOptionsRemoteURL, String robotOptionsRemoteURLToExclude, String robotOptionsSeleniumIP, String robotOptionsSeleniumIPToExclude, String robotOptionsSeleniumPort, String robotOptionsSeleniumPortToExclude, String robotOptionsTimeout,

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful