How to use doActionSetServiceCallContent method of org.cerberus.engine.gwt.impl.ActionService class

Best Cerberus-source code snippet using org.cerberus.engine.gwt.impl.ActionService.doActionSetServiceCallContent

Source:ActionService.java Github

copy

Full Screen

...327 case TestCaseStepAction.ACTION_SETNETWORKTRAFFICCONTENT:328 res = this.doActionSetNetworkTrafficContent(tCExecution, testCaseStepActionExecution, value1, value2);329 break;330 case TestCaseStepAction.ACTION_SETSERVICECALLCONTENT:331 res = this.doActionSetServiceCallContent(tCExecution, testCaseStepActionExecution);332 break;333 case TestCaseStepAction.ACTION_DONOTHING:334 res = new MessageEvent(MessageEventEnum.ACTION_SUCCESS);335 break;336 /**337 * DEPRECATED ACTIONS FROM HERE.338 */339 case TestCaseStepAction.ACTION_MOUSEOVERANDWAIT:340 res = this.doActionMouseOverAndWait(tCExecution, value1, value2);341 res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());342 logEventService.createForPrivateCalls("ENGINE", "mouseOverAndWait", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");343 LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action mouseOverAndWait triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");344 break;345 case TestCaseStepAction.ACTION_REMOVEDIFFERENCE:346 res = this.doActionRemoveDifference(testCaseStepActionExecution, value1, value2);347 res.setDescription(MESSAGE_DEPRECATED + " " + res.getDescription());348 logEventService.createForPrivateCalls("ENGINE", "removeDifference", MESSAGE_DEPRECATED + " Deprecated Action triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "|" + testCaseStepActionExecution.getTestCase() + "']");349 LOG.warn(MESSAGE_DEPRECATED + " Deprecated Action removeDifference triggered by TestCase : ['" + testCaseStepActionExecution.getTest() + "'|'" + testCaseStepActionExecution.getTestCase() + "']");350 break;351 default:352 res = new MessageEvent(MessageEventEnum.ACTION_FAILED_UNKNOWNACTION);353 res.setDescription(res.getDescription().replace("%ACTION%", testCaseStepActionExecution.getAction()));354 }355 } catch (final Exception unexpected) {356 LOG.error("Unexpected exception: " + unexpected.getMessage(), unexpected);357 res = new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC).resolveDescription("DETAIL", unexpected.getMessage());358 }359 LOG.debug("Result of the action : " + res.getCodeString() + " " + res.getDescription());360 /**361 * In case 1/ the action is flaged as being Forced with a specific362 * return code = PE and 2/ the return of the action is stoping the test363 * --> whatever the return of the action is, we force the return to move364 * forward the test with no screenshot, pagesource.365 */366 if (testCaseStepActionExecution.getForceExeStatus().equals("PE") && res.isStopTest()) {367 res.setDescription(res.getDescription() + " -- Execution forced to continue.");368 res.setDoScreenshot(false);369 res.setGetPageSource(false);370 res.setStopTest(false);371 res.setMessage(MessageGeneralEnum.EXECUTION_PE_TESTEXECUTING);372 }373 testCaseStepActionExecution.setActionResultMessage(res);374 /**375 * Determine here the impact of the Action on the full test return code376 * from the ResultMessage of the Action.377 */378 testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(res.getMessage()));379 /**380 * Determine here if we stop the test from the ResultMessage of the381 * Action.382 */383 testCaseStepActionExecution.setStopExecution(res.isStopTest());384 testCaseStepActionExecution.setEnd(new Date().getTime());385 return testCaseStepActionExecution;386 }387 private MessageEvent doActionInstallApp(TestCaseExecution tCExecution, String appPath) {388 MessageEvent message;389 try {390 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {391 return androidAppiumService.installApp(tCExecution.getSession(), appPath);392 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {393 return iosAppiumService.installApp(tCExecution.getSession(), appPath);394 }395 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);396 message.setDescription(message.getDescription().replace("%ACTION%", "scrollTo"));397 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));398 return message;399 } catch (Exception e) {400 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC);401 String messageString = e.getMessage().split("\n")[0];402 message.setDescription(message.getDescription().replace("%DETAIL%", messageString));403 LOG.debug("Exception Running install app :" + messageString, e);404 return message;405 }406 }407 private MessageEvent doActionRemoveApp(TestCaseExecution tCExecution, String appPackage) {408 MessageEvent message;409 try {410 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {411 return androidAppiumService.removeApp(tCExecution.getSession(), appPackage);412 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {413 return iosAppiumService.removeApp(tCExecution.getSession(), appPackage);414 }415 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);416 message.setDescription(message.getDescription().replace("%ACTION%", "scrollTo"));417 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));418 return message;419 } catch (Exception e) {420 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC);421 String messageString = e.getMessage().split("\n")[0];422 message.setDescription(message.getDescription().replace("%DETAIL%", messageString));423 LOG.debug("Exception Running remove app :" + messageString, e);424 return message;425 }426 }427 private MessageEvent doActionScrollTo(TestCaseExecution tCExecution, String element, String text) {428 MessageEvent message;429 try {430 Identifier identifier = null;431 if (!StringUtil.isNullOrEmpty(element)) {432 identifier = identifierService.convertStringToIdentifier(element);433 }434 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {435 return androidAppiumService.scrollTo(tCExecution.getSession(), identifier, text);436 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {437 return iosAppiumService.scrollTo(tCExecution.getSession(), identifier, text);438 439 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {440 return webdriverService.scrollTo(tCExecution.getSession(), identifier, text);441 }442 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);443 message.setDescription(message.getDescription().replace("%ACTION%", "scrollTo"));444 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));445 return message;446 } catch (Exception e) {447 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC);448 String messageString = e.getMessage().split("\n")[0];449 message.setDescription(message.getDescription().replace("%DETAIL%", messageString));450 LOG.debug("Exception Running scroll to :" + messageString, e);451 return message;452 }453 }454 private MessageEvent doActionExecuteCommand(TestCaseExecution tCExecution, String command, String args) {455 MessageEvent message;456 try {457 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK) || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {458 return androidAppiumService.executeCommand(tCExecution.getSession(), command, args);459 }460 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);461 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_EXECUTECOMMAND));462 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));463 return message;464 } catch (Exception e) {465 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_EXECUTECOMMAND);466 String messageString = e.getMessage().split("\n")[0];467 message.setDescription(message.getDescription().replace("%EXCEPTION%", messageString));468 LOG.debug("Exception Running Shell :" + messageString, e);469 return message;470 }471 }472 private MessageEvent doActionExecuteCerberusCommand(TestCaseExecution tCExecution, String command) {473 MessageEvent message;474 try {475 return cerberusCommand.executeCerberusCommand(command);476 } catch (CerberusEventException e) {477 message = e.getMessageError();478 LOG.debug("Exception Running Shell :" + message.getMessage().getDescription());479 return message;480 }481 }482 private MessageEvent doActionClick(TestCaseExecution tCExecution, String value1, String value2) {483 String element;484 try {485 /**486 * Get element to use String object if not empty, String property if487 * object empty, throws Exception if both empty)488 */489 element = getElementToUse(value1, value2, TestCaseStepAction.ACTION_CLICK, tCExecution);490 /**491 * Get Identifier (identifier, locator) and check it's valid492 */493 Identifier identifier = identifierService.convertStringToIdentifier(element);494 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {495 if (tCExecution.getRobotObj().getPlatform().equalsIgnoreCase(Platform.ANDROID.toString())) {496 identifierService.checkWebElementIdentifier(identifier.getIdentifier());497 return webdriverService.doSeleniumActionClick(tCExecution.getSession(), identifier, false, false);498 } else {499 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {500 return sikuliService.doSikuliActionClick(tCExecution.getSession(), identifier.getLocator(), "");501 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {502 return sikuliService.doSikuliActionClick(tCExecution.getSession(), "", identifier.getLocator());503 } else {504 identifierService.checkWebElementIdentifier(identifier.getIdentifier());505 return webdriverService.doSeleniumActionClick(tCExecution.getSession(), identifier, true, true);506 }507 }508 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {509 identifierService.checkWebElementIdentifier(identifier.getIdentifier());510 return androidAppiumService.click(tCExecution.getSession(), identifier);511 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {512 identifierService.checkWebElementIdentifier(identifier.getIdentifier());513 return iosAppiumService.click(tCExecution.getSession(), identifier);514 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {515 identifierService.checkSikuliIdentifier(identifier.getIdentifier());516 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {517 return sikuliService.doSikuliActionClick(tCExecution.getSession(), identifier.getLocator(), "");518 } else {519 return sikuliService.doSikuliActionClick(tCExecution.getSession(), "", identifier.getLocator());520 }521 } else {522 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION)523 .resolveDescription("ACTION", "Click")524 .resolveDescription("APPLICATIONTYPE", tCExecution.getApplicationObj().getType());525 }526 } catch (CerberusEventException ex) {527 LOG.fatal("Error doing Action Click :" + ex, ex);528 return ex.getMessageError();529 }530 }531 private MessageEvent doActionExecuteJS(TestCaseExecution tCExecution, String value1, String value2) {532 MessageEvent message;533 String script = value1;534 String valueFromJS;535 try {536 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {537 valueFromJS = this.webdriverService.getValueFromJS(tCExecution.getSession(), script);538 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_EXECUTEJS);539 message.setDescription(message.getDescription().replace("%SCRIPT%", script));540 message.setDescription(message.getDescription().replace("%VALUE%", valueFromJS));541 return message;542 }543 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);544 message.setDescription(message.getDescription().replace("%ACTION%", "executeJS"));545 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));546 return message;547 } catch (Exception e) {548 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_EXECUTEJS);549 String messageString = e.getMessage().split("\n")[0];550 message.setDescription(message.getDescription().replace("%EXCEPTION%", messageString));551 LOG.debug("Exception Running JS Script :" + messageString);552 return message;553 }554 }555 private MessageEvent doActionMouseLeftButtonPress(TestCaseExecution tCExecution, String object, String property) {556 MessageEvent message;557 String element;558 try {559 /**560 * Get element to use String object if not empty, String property if561 * object empty, throws Exception if both empty)562 */563 element = getElementToUse(object, property, "mouseLeftButtonPress", tCExecution);564 /**565 * Get Identifier (identifier, locator)566 */567 Identifier identifier = identifierService.convertStringToIdentifier(element);568 identifierService.checkWebElementIdentifier(identifier.getIdentifier());569 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {570 return webdriverService.doSeleniumActionMouseDown(tCExecution.getSession(), identifier, true, true);571 }572 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);573 message.setDescription(message.getDescription().replace("%ACTION%", "MouseDown"));574 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));575 return message;576 } catch (CerberusEventException ex) {577 LOG.fatal("Error doing Action MouseDown :" + ex);578 return ex.getMessageError();579 }580 }581 private MessageEvent doActionRightClick(TestCaseExecution tCExecution, String object, String property) {582 MessageEvent message;583 String element;584 try {585 /**586 * Get element to use String object if not empty, String property if587 * object empty, throws Exception if both empty)588 */589 element = getElementToUse(object, property, "rightClick", tCExecution);590 /**591 * Get Identifier (identifier, locator)592 */593 Identifier identifier = identifierService.convertStringToIdentifier(element);594 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {595 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {596 return sikuliService.doSikuliActionRightClick(tCExecution.getSession(), identifier.getLocator(), "");597 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {598 return sikuliService.doSikuliActionRightClick(tCExecution.getSession(), "", identifier.getLocator());599 } else {600 identifierService.checkWebElementIdentifier(identifier.getIdentifier());601 return webdriverService.doSeleniumActionRightClick(tCExecution.getSession(), identifier);602 }603 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {604 identifierService.checkSikuliIdentifier(identifier.getIdentifier());605 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {606 return sikuliService.doSikuliActionRightClick(tCExecution.getSession(), identifier.getLocator(), "");607 } else {608 return sikuliService.doSikuliActionRightClick(tCExecution.getSession(), "", identifier.getLocator());609 }610 }611 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);612 message.setDescription(message.getDescription().replace("%ACTION%", "rightClick"));613 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));614 return message;615 } catch (CerberusEventException ex) {616 LOG.fatal("Error doing Action RightClick :" + ex);617 return ex.getMessageError();618 }619 }620 private MessageEvent doActionMouseLeftButtonRelease(TestCaseExecution tCExecution, String object, String property) {621 MessageEvent message;622 String element;623 try {624 /**625 * Get element to use String object if not empty, String property if626 * object empty, throws Exception if both empty)627 */628 element = getElementToUse(object, property, "mouseLeftButtonRelease", tCExecution);629 /**630 * Get Identifier (identifier, locator)631 */632 Identifier identifier = identifierService.convertStringToIdentifier(element);633 identifierService.checkWebElementIdentifier(identifier.getIdentifier());634 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {635 return webdriverService.doSeleniumActionMouseUp(tCExecution.getSession(), identifier, true, true);636 }637 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);638 message.setDescription(message.getDescription().replace("%ACTION%", "MouseUp"));639 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));640 return message;641 } catch (CerberusEventException ex) {642 LOG.fatal("Error doing Action MouseUp :" + ex);643 return ex.getMessageError();644 }645 }646 private MessageEvent doActionSwitchToWindow(TestCaseExecution tCExecution, String object, String property) {647 String element;648 try {649 /**650 * Get element to use String object if not empty, String property if651 * object empty, throws Exception if both empty)652 */653 element = getElementToUse(object, property, "switchToWindow", tCExecution);654 /**655 * Get Identifier (identifier, locator)656 */657 Identifier identifier = identifierService.convertStringToIdentifier(element);658 //identifierService.checkWebElementIdentifier(identifier.getIdentifier());659 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {660 return webdriverService.doSeleniumActionSwitchToWindow(tCExecution.getSession(), identifier);661 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {662 return androidAppiumService.switchToContext(tCExecution.getSession(), identifier);663 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {664 return iosAppiumService.switchToContext(tCExecution.getSession(), identifier);665 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {666 return sikuliService.doSikuliActionSwitchApp(tCExecution.getSession(), identifier.getLocator());667 } else {668 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION)669 .resolveDescription("ACTION", "SwitchToWindow")670 .resolveDescription("APPLICATIONTYPE", tCExecution.getApplicationObj().getType());671 }672 } catch (CerberusEventException ex) {673 LOG.fatal("Error doing Action SwitchToWindow :" + ex);674 return ex.getMessageError();675 }676 }677 private MessageEvent doActionManageDialog(TestCaseExecution tCExecution, String value1, String value2) {678 MessageEvent message;679 String element;680 try {681 /**682 * Get element to use String object if not empty, String property if683 * object empty, throws Exception if both empty)684 */685 element = getElementToUse(value1, value2, "manageDialog", tCExecution);686 /**687 * Get Identifier (identifier, locator)688 */689 Identifier identifier = identifierService.convertStringToIdentifier(element);690 identifierService.checkWebElementIdentifier(identifier.getIdentifier());691 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {692 return webdriverService.doSeleniumActionManageDialog(tCExecution.getSession(), identifier);693 }694 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);695 message.setDescription(message.getDescription().replace("%ACTION%", "ManageDialog"));696 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));697 return message;698 } catch (CerberusEventException ex) {699 LOG.fatal("Error doing Action ManageDialog :" + ex);700 return ex.getMessageError();701 }702 }703 private MessageEvent doActionManageDialogKeyPress(TestCaseExecution tCExecution, String value1) {704 MessageEvent message;705 String element;706 try {707 /**708 * Get element to use String object if not empty, String property if709 * object empty, throws Exception if both empty)710 */711 element = getElementToUse(value1, "", "manageDialogKeyPress", tCExecution);712 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {713 return webdriverService.doSeleniumActionManageDialogKeyPress(tCExecution.getSession(), element);714 }715 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);716 message.setDescription(message.getDescription().replace("%ACTION%", "ManageDialogKeypress"));717 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));718 return message;719 } catch (CerberusEventException ex) {720 LOG.fatal("Error doing Action ManageDialogKeypress :" + ex);721 return ex.getMessageError();722 }723 }724 private MessageEvent doActionDoubleClick(TestCaseExecution tCExecution, String object, String property) {725 MessageEvent message;726 String element;727 try {728 /**729 * Get element to use String object if not empty, String property if730 * object empty, throws Exception if both empty)731 */732 element = getElementToUse(object, property, "doubleClick", tCExecution);733 /**734 * Get Identifier (identifier, locator)735 */736 Identifier identifier = identifierService.convertStringToIdentifier(element);737 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {738 if (tCExecution.getRobotObj().getPlatform().equalsIgnoreCase(Platform.ANDROID.toString())) {739 identifierService.checkWebElementIdentifier(identifier.getIdentifier());740 return webdriverService.doSeleniumActionDoubleClick(tCExecution.getSession(), identifier, false, false);741 } else {742 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {743 return sikuliService.doSikuliActionDoubleClick(tCExecution.getSession(), identifier.getLocator(), "");744 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {745 return sikuliService.doSikuliActionDoubleClick(tCExecution.getSession(), "", identifier.getLocator());746 } else {747 identifierService.checkWebElementIdentifier(identifier.getIdentifier());748 return webdriverService.doSeleniumActionDoubleClick(tCExecution.getSession(), identifier, true, true);749 }750 }751 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)752 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {753 identifierService.checkWebElementIdentifier(identifier.getIdentifier());754 return webdriverService.doSeleniumActionDoubleClick(tCExecution.getSession(), identifier, true, false);755 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {756 identifierService.checkSikuliIdentifier(identifier.getIdentifier());757 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {758 return sikuliService.doSikuliActionDoubleClick(tCExecution.getSession(), identifier.getLocator(), "");759 } else {760 return sikuliService.doSikuliActionDoubleClick(tCExecution.getSession(), "", identifier.getLocator());761 }762 }763 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);764 message.setDescription(message.getDescription().replace("%ACTION%", "doubleClick"));765 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));766 return message;767 } catch (CerberusEventException ex) {768 LOG.fatal("Error doing Action DoubleClick :" + ex);769 return ex.getMessageError();770 }771 }772 private MessageEvent doActionType(TestCaseExecution tCExecution, String value1, String value2, String propertyName) {773 try {774 /**775 * Check object and property are not null for GUI/APK/IPA Check776 * property is not null for FAT Application777 */778 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)779 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)780 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {781 if (value1 == null || value2 == null) {782 return new MessageEvent(MessageEventEnum.ACTION_FAILED_TYPE);783 }784 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {785 if (value2 == null) {786 return new MessageEvent(MessageEventEnum.ACTION_FAILED_TYPE);787 }788 }789 /**790 * Get Identifier (identifier, locator) if object not null791 */792 Identifier identifier = new Identifier();793 if (value1 != null) {794 identifier = identifierService.convertStringToIdentifier(value1);795 }796 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {797 if (tCExecution.getRobotObj().getPlatform().equalsIgnoreCase(Platform.ANDROID.toString())) {798 identifierService.checkWebElementIdentifier(identifier.getIdentifier());799 return webdriverService.doSeleniumActionType(tCExecution.getSession(), identifier, value2, propertyName, false, false);800 } else {801 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {802 return sikuliService.doSikuliActionType(tCExecution.getSession(), identifier.getLocator(), value2);803 } else {804 identifierService.checkWebElementIdentifier(identifier.getIdentifier());805 return webdriverService.doSeleniumActionType(tCExecution.getSession(), identifier, value2, propertyName, true, true);806 }807 }808 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {809 return androidAppiumService.type(tCExecution.getSession(), identifier, value2, propertyName);810 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {811 return iosAppiumService.type(tCExecution.getSession(), identifier, value2, propertyName);812 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {813 String locator = "";814 if (!StringUtil.isNullOrEmpty(value1)) {815 identifierService.checkSikuliIdentifier(identifier.getIdentifier());816 locator = identifier.getLocator();817 }818 return sikuliService.doSikuliActionType(tCExecution.getSession(), locator, value2);819 } else {820 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION)821 .resolveDescription("ACTION", "Type")822 .resolveDescription("APPLICATIONTYPE", tCExecution.getApplicationObj().getType());823 }824 } catch (CerberusEventException ex) {825 LOG.fatal("Error doing Action Type : " + ex);826 return ex.getMessageError();827 }828 }829 private MessageEvent doActionMouseOver(TestCaseExecution tCExecution, String object, String property) {830 MessageEvent message;831 String element;832 try {833 /**834 * Get element to use String object if not empty, String property if835 * object empty, throws Exception if both empty)836 */837 element = getElementToUse(object, property, "mouseOver", tCExecution);838 /**839 * Get Identifier (identifier, locator)840 */841 Identifier identifier = identifierService.convertStringToIdentifier(element);842 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {843 if (tCExecution.getRobotObj().getPlatform().equalsIgnoreCase(Platform.ANDROID.toString())) {844 identifierService.checkWebElementIdentifier(identifier.getIdentifier());845 return webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier, false, false);846 } else {847 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {848 return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "");849 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {850 return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator());851 } else {852 identifierService.checkWebElementIdentifier(identifier.getIdentifier());853 return webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier, true, true);854 }855 }856 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {857 identifierService.checkSikuliIdentifier(identifier.getIdentifier());858 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {859 return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "");860 } else {861 return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator());862 }863 }864 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);865 message.setDescription(message.getDescription().replace("%ACTION%", "mouseOver"));866 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));867 return message;868 } catch (CerberusEventException ex) {869 LOG.fatal("Error doing Action MouseOver :" + ex);870 return ex.getMessageError();871 }872 }873 private MessageEvent doActionMouseOverAndWait(TestCaseExecution tCExecution, String object, String property) {874 MessageEvent message;875 try {876 /**877 * Check object is not null878 */879 if (object == null) {880 return new MessageEvent(MessageEventEnum.ACTION_FAILED_MOUSEOVERANDWAIT_GENERIC);881 }882 /**883 * Get Identifier (identifier, locator)884 */885 Identifier identifier = identifierService.convertStringToIdentifier(object);886 identifierService.checkWebElementIdentifier(identifier.getIdentifier());887 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {888 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {889 message = sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "");890 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {891 message = sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator());892 } else {893 message = webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier, true, true);894 }895 if (message.getCodeString().equals("OK")) {896 message = this.doActionWait(tCExecution, property, null);897 }898 return message;899 }900 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);901 message.setDescription(message.getDescription().replace("%ACTION%", "mouseOverAndWait"));902 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));903 return message;904 } catch (CerberusEventException ex) {905 LOG.fatal("Error doing Action MouseOverAndWait :" + ex);906 return ex.getMessageError();907 }908 }909 private MessageEvent doActionWait(TestCaseExecution tCExecution, String value1, String value2) {910 MessageEvent message;911 String element;912 long timeToWaitInMs = 0;913 Identifier identifier = null;914 try {915 /**916 * Get element to use String object if not empty, String property if917 * object empty, null if both are empty918 */919 element = getElementToUse(value1, value2, "wait", tCExecution);920 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)921 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)922 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)923 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) { // If application are Selenium or appium based, we have a session and can use it to wait.924 /**925 * if element is integer, set time to that value else Get926 * Identifier (identifier, locator)927 */928 if (StringUtil.isNullOrEmpty(element)) {929 timeToWaitInMs = tCExecution.getCerberus_action_wait_default();930 } else if (StringUtil.isInteger(element)) {931 timeToWaitInMs = Long.valueOf(element);932 } else {933 identifier = identifierService.convertStringToIdentifier(element);934 }935 if (identifier != null && identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {936 return sikuliService.doSikuliActionWait(tCExecution.getSession(), identifier.getLocator(), "");937 } else if (identifier != null && identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {938 return sikuliService.doSikuliActionWait(tCExecution.getSession(), "", identifier.getLocator());939 } else if (identifier != null) {940 identifierService.checkWebElementIdentifier(identifier.getIdentifier());941 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {942 return androidAppiumService.wait(tCExecution.getSession(), identifier);943 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {944 return iosAppiumService.wait(tCExecution.getSession(), identifier);945 } else {946 return webdriverService.doSeleniumActionWait(tCExecution.getSession(), identifier);947 }948 } else {949 return this.waitTime(timeToWaitInMs);950 }951 } else { // For any other application we wait for the integer value.952 if (StringUtil.isNullOrEmpty(element)) {953 // Get default wait from parameter954 timeToWaitInMs = tCExecution.getCerberus_action_wait_default();955 } else if (StringUtil.isInteger(element)) {956 timeToWaitInMs = Long.valueOf(element);957 }958 return this.waitTime(timeToWaitInMs);959 }960 } catch (CerberusEventException ex) {961 LOG.fatal("Error doing Action Wait :" + ex);962 return ex.getMessageError();963 }964 }965 private MessageEvent doActionKeyPress(TestCaseExecution tCExecution, String value1, String value2) {966 try {967 String appType = tCExecution.getApplicationObj().getType();968 /**969 * Check value1 and value2 are not null For IPA and APK, only value2970 * (key to press) is mandatory For GUI and FAT, both parameters are971 * mandatory972 */973 if (StringUtil.isNullOrEmpty(value2)) {974 return new MessageEvent(MessageEventEnum.ACTION_FAILED_KEYPRESS_MISSINGKEY).resolveDescription("APPLICATIONTYPE", appType);975 }976 /**977 * Get Identifier (identifier, locator)978 */979 if (StringUtil.isNullOrEmpty(value1) && appType.equalsIgnoreCase(Application.TYPE_GUI)) {980 value1 = "xpath=//body";981 }982 Identifier objectIdentifier = identifierService.convertStringToIdentifier(value1);983 if (appType.equalsIgnoreCase(Application.TYPE_GUI)) {984 if (tCExecution.getRobotObj().getPlatform().equalsIgnoreCase(Platform.MAC.toString())985 || tCExecution.getRobotObj().getPlatform().equalsIgnoreCase(Platform.IOS.toString())) {986 return iosAppiumService.keyPress(tCExecution.getSession(), value2);987 } else if (tCExecution.getRobotObj().getPlatform().equalsIgnoreCase(Platform.ANDROID.toString())) {988 return webdriverService.doSeleniumActionKeyPress(tCExecution.getSession(), objectIdentifier, value2, false, false);989 }990 if (objectIdentifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {991 return sikuliService.doSikuliActionKeyPress(tCExecution.getSession(), objectIdentifier.getLocator(), value2);992 } else {993 identifierService.checkWebElementIdentifier(objectIdentifier.getIdentifier());994 return webdriverService.doSeleniumActionKeyPress(tCExecution.getSession(), objectIdentifier, value2, true, true);995 }996 } else if (appType.equalsIgnoreCase(Application.TYPE_APK)) {997 return androidAppiumService.keyPress(tCExecution.getSession(), value2);998 } else if (appType.equalsIgnoreCase(Application.TYPE_IPA)) {999 return iosAppiumService.keyPress(tCExecution.getSession(), value2);1000 } else if (appType.equalsIgnoreCase(Application.TYPE_FAT)) {1001 return sikuliService.doSikuliActionKeyPress(tCExecution.getSession(), objectIdentifier.getLocator(), value2);1002 } else {1003 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION)1004 .resolveDescription("ACTION", "KeyPress")1005 .resolveDescription("APPLICATIONTYPE", appType);1006 }1007 } catch (CerberusEventException ex) {1008 LOG.debug("Error doing Action KeyPress :" + ex);1009 return ex.getMessageError();1010 } catch (Exception ex) {1011 LOG.debug("Error doing Action KeyPress :" + ex);1012 return new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC)1013 .resolveDescription("DETAIL", ex.toString());1014 }1015 }1016 private MessageEvent doActionOpenURL(TestCaseExecution tCExecution, String object, String property, boolean withBase) {1017 MessageEvent message;1018 String element;1019 try {1020 /**1021 * Get element to use String object if not empty, String property if1022 * object empty, throws Exception if both empty)1023 */1024 element = getElementToUse(object, property, "openUrl[WithBase]", tCExecution);1025 /**1026 * Get Identifier (identifier, locator)1027 */1028 Identifier identifier = new Identifier();1029 identifier.setIdentifier("url");1030 identifier.setLocator(element);1031 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {1032 return webdriverService.doSeleniumActionOpenURL(tCExecution.getSession(), tCExecution.getUrl(), identifier, withBase);1033 }1034 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1035 message.setDescription(message.getDescription().replace("%ACTION%", "OpenURL[WithBase]"));1036 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1037 return message;1038 } catch (CerberusEventException ex) {1039 LOG.fatal("Error doing Action OpenUrl :" + ex);1040 return ex.getMessageError();1041 }1042 }1043 private MessageEvent doActionOpenApp(TestCaseExecution tCExecution, String value1, String value2) {1044 MessageEvent message;1045 /**1046 * Check value1 is not null or empty1047 */1048 if (value1 == null || "".equals(value1)) {1049 return new MessageEvent(MessageEventEnum.ACTION_FAILED_OPENAPP);1050 }1051 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)1052 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {1053 return sikuliService.doSikuliActionOpenApp(tCExecution.getSession(), value1);1054 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {1055 return androidAppiumService.openApp(tCExecution.getSession(), value1, value2);1056 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {1057 return iosAppiumService.openApp(tCExecution.getSession(), value1, value2);1058 }1059 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1060 message.setDescription(message.getDescription().replace("%ACTION%", "OpenApp"));1061 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1062 return message;1063 }1064 private MessageEvent doActionCloseApp(TestCaseExecution tCExecution, String value1) {1065 MessageEvent message;1066 /**1067 * Check value1 is not null or empty1068 */1069 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)1070 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {1071 if (value1 == null || "".equals(value1)) {1072 return new MessageEvent(MessageEventEnum.ACTION_FAILED_CLOSEAPP);1073 }1074 return sikuliService.doSikuliActionCloseApp(tCExecution.getSession(), value1);1075 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {1076 return androidAppiumService.closeApp(tCExecution.getSession());1077 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {1078 return iosAppiumService.closeApp(tCExecution.getSession());1079 }1080 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1081 message.setDescription(message.getDescription().replace("%ACTION%", "CloseApp"));1082 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1083 return message;1084 }1085 private MessageEvent doActionWaitVanish(TestCaseExecution tCExecution, String value1) {1086 try {1087 /**1088 * Check value1 is not null or empty1089 */1090 if (value1 == null || "".equals(value1)) {1091 return new MessageEvent(MessageEventEnum.ACTION_FAILED_CLOSEAPP);1092 }1093 /**1094 * Get Identifier (identifier, locator)1095 */1096 Identifier identifier = identifierService.convertStringToIdentifier(value1);1097 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {1098 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {1099 return sikuliService.doSikuliActionWaitVanish(tCExecution.getSession(), identifier.getLocator(), "");1100 } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {1101 return sikuliService.doSikuliActionWaitVanish(tCExecution.getSession(), "", identifier.getLocator());1102 } else {1103 identifierService.checkWebElementIdentifier(identifier.getIdentifier());1104 return webdriverService.doSeleniumActionWaitVanish(tCExecution.getSession(), identifier);1105 }1106 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)1107 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {1108 identifierService.checkWebElementIdentifier(identifier.getIdentifier());1109 return webdriverService.doSeleniumActionWaitVanish(tCExecution.getSession(), identifier);1110 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {1111 identifierService.checkSikuliIdentifier(identifier.getIdentifier());1112 if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {1113 return sikuliService.doSikuliActionWaitVanish(tCExecution.getSession(), identifier.getLocator(), "");1114 } else {1115 return sikuliService.doSikuliActionWaitVanish(tCExecution.getSession(), "", identifier.getLocator());1116 }1117 } else {1118 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION)1119 .resolveDescription("ACTION", "WaitVanish")1120 .resolveDescription("APPLICATIONTYPE", tCExecution.getApplicationObj().getType());1121 }1122 } catch (CerberusEventException ex) {1123 LOG.fatal("Error doing Action KeyPress :" + ex);1124 return ex.getMessageError();1125 }1126 }1127 private MessageEvent doActionWaitNetworkTrafficIdle(TestCaseExecution tCExecution) {1128 try {1129 return executorService.waitForIdleNetwork(tCExecution.getRobotExecutorObj().getExecutorExtensionHost(), tCExecution.getRobotExecutorObj().getExecutorExtensionPort(),1130 tCExecution.getRemoteProxyUUID(), tCExecution.getSystem());1131 } catch (CerberusEventException ex) {1132 LOG.fatal("Error doing Action WaitNetworkTrafficIdle :" + ex);1133 return ex.getMessageError();1134 }1135 }1136 private MessageEvent doActionSelect(TestCaseExecution tCExecution, String value1, String value2) {1137 MessageEvent message;1138 try {1139 /**1140 * Check object and property are not null1141 */1142 if (StringUtil.isNullOrEmpty(value1) || StringUtil.isNullOrEmpty(value2)) {1143 return new MessageEvent(MessageEventEnum.ACTION_FAILED_SELECT);1144 }1145 /**1146 * Get Identifier (identifier, locator)1147 */1148 Identifier identifierObject = identifierService.convertStringToIdentifier(value1);1149 Identifier identifierValue = identifierService.convertStringToSelectIdentifier(value2);1150 identifierService.checkWebElementIdentifier(identifierObject.getIdentifier());1151 identifierService.checkSelectOptionsIdentifier(identifierValue.getIdentifier());1152 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)1153 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)1154 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {1155 if (tCExecution.getRobotObj().getPlatform().equalsIgnoreCase(Platform.ANDROID.toString())) {1156 return webdriverService.doSeleniumActionSelect(tCExecution.getSession(), identifierObject, identifierValue, false, false);1157 }1158 return webdriverService.doSeleniumActionSelect(tCExecution.getSession(), identifierObject, identifierValue, true, true);1159 }1160 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1161 message.setDescription(message.getDescription().replace("%ACTION%", "Select"));1162 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1163 return message;1164 } catch (CerberusEventException ex) {1165 LOG.fatal("Error doing Action Select :" + ex);1166 return ex.getMessageError();1167 }1168 }1169 private MessageEvent doActionUrlLogin(TestCaseExecution tCExecution) {1170 MessageEvent message;1171 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {1172 return webdriverService.doSeleniumActionUrlLogin(tCExecution.getSession(), tCExecution.getUrl(), tCExecution.getCountryEnvironmentParameters().getUrlLogin());1173 }1174 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1175 message.setDescription(message.getDescription().replace("%ACTION%", "UrlLogin"));1176 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1177 return message;1178 }1179 private MessageEvent doActionFocusToIframe(TestCaseExecution tCExecution, String object, String property) {1180 MessageEvent message;1181 String element;1182 try {1183 /**1184 * Get element to use String object if not empty, String property if1185 * object empty, throws Exception if both empty)1186 */1187 element = getElementToUse(object, property, "focusToIframe", tCExecution);1188 /**1189 * Get Identifier (identifier, locator)1190 */1191 Identifier identifier = identifierService.convertStringToIdentifier(element);1192 identifierService.checkWebElementIdentifier(identifier.getIdentifier());1193 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {1194 return webdriverService.doSeleniumActionFocusToIframe(tCExecution.getSession(), identifier);1195 }1196 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1197 message.setDescription(message.getDescription().replace("%ACTION%", "FocusToIframe"));1198 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1199 return message;1200 } catch (CerberusEventException ex) {1201 LOG.fatal("Error doing Action FocusToIframe :" + ex);1202 return ex.getMessageError();1203 }1204 }1205 private MessageEvent doActionFocusDefaultIframe(TestCaseExecution tCExecution) {1206 MessageEvent message;1207 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {1208 return webdriverService.doSeleniumActionFocusDefaultIframe(tCExecution.getSession());1209 }1210 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1211 message.setDescription(message.getDescription().replace("%ACTION%", "FocusDefaultIframe"));1212 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1213 return message;1214 }1215 public MessageEvent doActionDragAndDrop(TestCaseExecution tCExecution, String value1, String value2) throws IOException {1216 MessageEvent message;1217 try {1218 /**1219 * Check source and target are not null1220 */1221 if (StringUtil.isNullOrEmpty(value1)) {1222 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_DRAGANDDROP);1223 message.setDescription(message.getDescription().replace("%ELEMENT%", value1));1224 return message;1225 } else if (StringUtil.isNullOrEmpty(value2)) {1226 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_DRAGANDDROP);1227 message.setDescription(message.getDescription().replace("%ELEMENT%", value2));1228 return message;1229 }1230 Identifier identifierDrag = identifierService.convertStringToIdentifier(value1);1231 Identifier identifierDrop = identifierService.convertStringToIdentifier(value2);1232 identifierService.checkWebElementIdentifier(identifierDrag.getIdentifier());1233 identifierService.checkWebElementIdentifier(identifierDrop.getIdentifier());1234 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {1235 return webdriverService.doSeleniumActionDragAndDrop(tCExecution.getSession(), identifierDrag, identifierDrop, true, true);1236 }1237 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1238 message.setDescription(message.getDescription().replace("%ACTION%", "Select"));1239 message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1240 return message;1241 } catch (CerberusEventException ex) {1242 LOG.fatal("Error doing Action DragAndDrop :" + ex);1243 return ex.getMessageError();1244 }1245 }1246 private MessageEvent doActionCallService(TestCaseStepActionExecution testCaseStepActionExecution, String value1, String value2, String value3) {1247 MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE);1248 TestCaseExecution tCExecution = testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution();1249 AnswerItem lastServiceCalledAnswer;1250 lastServiceCalledAnswer = serviceService.callService(value1, value2, value3, null, null, null, null, tCExecution);1251 message = lastServiceCalledAnswer.getResultMessage();1252 if (lastServiceCalledAnswer.getItem() != null) {1253 AppService lastServiceCalled = (AppService) lastServiceCalledAnswer.getItem();1254 tCExecution.setLastServiceCalled(lastServiceCalled);1255 tCExecution.setOriginalLastServiceCalled(lastServiceCalled.getResponseHTTPBody());1256 tCExecution.setOriginalLastServiceCalledContent(lastServiceCalled.getResponseHTTPBodyContentType());1257 /**1258 * Record the Request and Response in file system.1259 */1260 testCaseStepActionExecution.addFileList(recorderService.recordServiceCall(tCExecution, testCaseStepActionExecution, 0, null, lastServiceCalled));1261 }1262 return message;1263 }1264 private MessageEvent doActionRemoveDifference(TestCaseStepActionExecution testCaseStepActionExecution, String object, String property) {1265 // Filters differences from the given object pattern1266 String filteredDifferences = xmlUnitService.removeDifference(object, property);1267 // If filtered differences are null then service has returned with errors1268 if (filteredDifferences == null) {1269 MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_FAILED_REMOVEDIFFERENCE);1270 message.setDescription(message.getDescription().replace("%DIFFERENCE%", object));1271 message.setDescription(message.getDescription().replace("%DIFFERENCES%", property));1272 return message;1273 }1274 // Sets the property value to the new filtered one1275 for (TestCaseExecutionData data : testCaseStepActionExecution.getTestCaseExecutionDataList()) {1276 if (data.getProperty().equals(testCaseStepActionExecution.getPropertyName())) {1277 data.setValue(filteredDifferences);1278 break;1279 }1280 }1281 // Sends success1282 MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_REMOVEDIFFERENCE);1283 message.setDescription(message.getDescription().replace("%DIFFERENCE%", object));1284 message.setDescription(message.getDescription().replace("%DIFFERENCES%", property));1285 return message;1286 }1287 private MessageEvent doActionCalculateProperty(TestCaseStepActionExecution testCaseStepActionExecution, String value1, String value2) {1288 MessageEvent message;1289 AnswerItem<String> answerDecode = new AnswerItem<>();1290 if (StringUtil.isNullOrEmpty(value1)) {1291 // Value1 is a mandatory parameter.1292 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALCULATEPROPERTY_MISSINGPROPERTY);1293 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY));1294 } else {1295 try {1296 TestCaseExecution tCExecution = testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution();1297 // Getting the Country property definition.1298 TestCaseCountryProperties tccp = null;1299 boolean propertyExistOnAnyCountry = false;1300 for (TestCaseCountryProperties object : tCExecution.getTestCaseCountryPropertyList()) {1301 if ((object.getProperty().equalsIgnoreCase(value1)) && (object.getCountry().equalsIgnoreCase(tCExecution.getCountry()))) {1302 tccp = object;1303 }1304 if ((object.getProperty().equalsIgnoreCase(value1))) {1305 propertyExistOnAnyCountry = true;1306 }1307 }1308 if (tccp == null) { // Could not find a country property inside the existing execution.1309 if (propertyExistOnAnyCountry) {1310 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NO_PROPERTY_DEFINITION);1311 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1312 .replace("%PROP%", value1)1313 .replace("%COUNTRY%", tCExecution.getCountry()));1314 return message;1315 } else {1316 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALCULATEPROPERTY_PROPERTYNOTFOUND);1317 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1318 .replace("%PROP%", value1)1319 .replace("%COUNTRY%", tCExecution.getCountry()));1320 return message;1321 }1322 } else {1323 if (!(StringUtil.isNullOrEmpty(value2))) {1324 // If value2 is fed with something, we control here that value is a valid property name and gets its defintion.1325 tccp = null;1326 propertyExistOnAnyCountry = false;1327 for (TestCaseCountryProperties object : tCExecution.getTestCaseCountryPropertyList()) {1328 if ((object.getProperty().equalsIgnoreCase(value2)) && (object.getCountry().equalsIgnoreCase(tCExecution.getCountry()))) {1329 tccp = object;1330 }1331 if ((object.getProperty().equalsIgnoreCase(value2))) {1332 propertyExistOnAnyCountry = true;1333 }1334 }1335 if (tccp == null) { // Could not find a country property inside the existing execution.1336 if (propertyExistOnAnyCountry) {1337 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NO_PROPERTY_DEFINITION);1338 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1339 .replace("%PROP%", value2)1340 .replace("%COUNTRY%", tCExecution.getCountry()));1341 return message;1342 } else {1343 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALCULATEPROPERTY_PROPERTYNOTFOUND);1344 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1345 .replace("%PROP%", value2)1346 .replace("%COUNTRY%", tCExecution.getCountry()));1347 return message;1348 }1349 }1350 }1351 // We calculate the property here.1352 long now = new Date().getTime();1353 TestCaseExecutionData tcExeData;1354 tcExeData = factoryTestCaseExecutionData.create(tCExecution.getId(), tccp.getProperty(), 1, tccp.getDescription(), null, tccp.getType(),1355 tccp.getRank(), tccp.getValue1(), tccp.getValue2(), null, null, now, now, now, now, new MessageEvent(MessageEventEnum.PROPERTY_PENDING),1356 tccp.getRetryNb(), tccp.getRetryPeriod(), tccp.getDatabase(), tccp.getValue1(), tccp.getValue2(), tccp.getLength(), tccp.getLength(),1357 tccp.getRowLimit(), tccp.getNature(), "", "", "", "", "", "N");1358 tcExeData.setTestCaseCountryProperties(tccp);1359 propertyService.calculateProperty(tcExeData, tCExecution, testCaseStepActionExecution, tccp, true);1360 // Property message goes to Action message.1361 message = tcExeData.getPropertyResultMessage();1362 if (message.getCodeString().equals("OK")) {1363 // If Property calculated successfully we summarize the message to a shorter version.1364 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_CALCULATEPROPERTY);1365 message.setDescription(message.getDescription()1366 .replace("%PROP%", value1)1367 .replace("%VALUE%", tcExeData.getValue()));1368 if (tcExeData.getDataLibRawData() != null) {1369 message.setDescription(message.getDescription() + " %NBROWS% row(s) with %NBSUBDATA% Subdata(s) calculated."1370 .replace("%NBROWS%", String.valueOf(tcExeData.getDataLibRawData().size()))1371 .replace("%NBSUBDATA%", String.valueOf(tcExeData.getDataLibRawData().get(0).size())));1372 }1373 }1374 if (!(StringUtil.isNullOrEmpty(value2))) {1375 // If value2 is fed we force the result to value1.1376 tcExeData.setProperty(value1);1377 }1378 //saves the result1379 try {1380 testCaseExecutionDataService.save(tcExeData);1381 LOG.debug("Adding into Execution data list. Property : '" + tcExeData.getProperty() + "' Index : '" + tcExeData.getIndex() + "' Value : '" + tcExeData.getValue() + "'");1382 tCExecution.getTestCaseExecutionDataMap().put(tcExeData.getProperty(), tcExeData);1383 if (tcExeData.getDataLibRawData() != null) { // If the property is a TestDataLib, we same all rows retreived in order to support nature such as NOTINUSe or RANDOMNEW.1384 for (int i = 1; i < (tcExeData.getDataLibRawData().size()); i++) {1385 now = new Date().getTime();1386 TestCaseExecutionData tcedS = factoryTestCaseExecutionData.create(tcExeData.getId(), tcExeData.getProperty(), (i + 1),1387 tcExeData.getDescription(), tcExeData.getDataLibRawData().get(i).get(""), tcExeData.getType(), tcExeData.getRank(), "", "",1388 tcExeData.getRC(), "", now, now, now, now, null, 0, 0, "", "", "", "", "", 0, "", "", "", "", "", "", "N");1389 testCaseExecutionDataService.save(tcedS);1390 }1391 }1392 } catch (CerberusException cex) {1393 LOG.error(cex.getMessage(), cex);1394 }1395 }1396 } catch (Exception ex) {1397 LOG.error(ex.toString(), ex);1398 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC).resolveDescription("DETAIL", ex.toString());1399 }1400 }1401 return message;1402 }1403 public MessageEvent doActionSetNetworkTrafficContent(TestCaseExecution exe, TestCaseStepActionExecution actionexe, String urlToFilter, String withResponseContent) throws IOException {1404 MessageEvent message;1405 try {1406 // Check that robot has executor activated1407 if (!"Y".equalsIgnoreCase(exe.getRobotExecutorObj().getExecutorProxyActive()) || StringUtil.isNullOrEmpty(exe.getRobotExecutorObj().getExecutorProxyHost())) {1408 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SETNETWORKTRAFFICCONTENT_ROBOTEXECUTORPROXYNOTACTIVATED);1409 message.setDescription(message.getDescription().replace("%ROBOT%", exe.getRobotExecutorObj().getRobot()).replace("%EXECUTOR%", exe.getRobotExecutorObj().getExecutor()));1410 return message;1411 }1412 /**1413 * Building the url to get the Har file from cerberus-executor1414 */1415 String url = executorService.getExecutorURL(urlToFilter, ParameterParserUtil.parseBooleanParam(withResponseContent, false),1416 exe.getRobotExecutorObj().getExecutorExtensionHost(), exe.getRobotExecutorObj().getExecutorExtensionPort(), exe.getRemoteProxyUUID());1417 LOG.debug("Getting Network Traffic content from URL : " + url);1418 AnswerItem<AppService> result = new AnswerItem<>();1419 result = restService.callREST(url, "", AppService.METHOD_HTTPGET, new ArrayList<>(), new ArrayList<>(), null, 10000, "", true, exe);1420 AppService appSrv = result.getItem();1421 JSONObject har = new JSONObject(appSrv.getResponseHTTPBody());1422 har = harService.enrichWithStats(har, exe.getCountryEnvironmentParameters().getDomain(), exe.getSystem());1423 appSrv.setResponseHTTPBody(har.toString());1424 appSrv.setResponseHTTPBodyContentType(AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON);1425 appSrv.setRecordTraceFile(false);1426 exe.setLastServiceCalled(appSrv);1427 /**1428 * Record the Request and Response in file system.1429 */1430 actionexe.addFileList(recorderService.recordNetworkTrafficContent(exe, actionexe, 0, null, result.getItem(), true));1431 // Forcing the apptype to SRV in order to allow all controls to plug to the json context of the har.1432 exe.setAppTypeEngine(Application.TYPE_SRV);1433 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_SETNETWORKTRAFFICCONTENT);1434 return message;1435 } catch (Exception ex) {1436 LOG.error("Error doing Action setNetworkTrafficContent :" + ex);1437 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SETNETWORKTRAFFICCONTENT);1438 message.setDescription(message.getDescription().replace("%DETAIL%", ex.toString()));1439 return message;1440 }1441 }1442 public MessageEvent doActionSetServiceCallContent(TestCaseExecution exe, TestCaseStepActionExecution actionexe) throws IOException {1443 MessageEvent message;1444 try {1445 1446 // Check that robot has executor activated1447 if (exe.getLastServiceCalled() == null) {1448 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SETSERVICECALLCONTENT_NOLASTCALLDONE);1449 return message;1450 }1451 1452 // Force last service call content to JSON Service Call Structure & disable file save.1453 exe.getLastServiceCalled().setResponseHTTPBody(exe.getLastServiceCalled().toJSONOnExecution().toString());1454 exe.getLastServiceCalled().setResponseHTTPBodyContentType(AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON);1455 exe.getLastServiceCalled().setRecordTraceFile(false);1456 /**...

Full Screen

Full Screen

doActionSetServiceCallContent

Using AI Code Generation

copy

Full Screen

1actionService = new org.cerberus.engine.gwt.impl.ActionService();2serviceCall = actionService.getServiceCallFromAction(actionService.getActionFromTestTestCaseStep(test, testCase, step));3content = serviceCall.getContent();4contentJSON = serviceCall.getContentJSON();5actionService.doActionSetServiceCallContent(serviceCall, "content");6content = serviceCall.getContent();7contentJSON = serviceCall.getContentJSON();8actionService.doActionSetServiceCallContent(serviceCall, "content", "JSON");9content = serviceCall.getContent();10contentJSON = serviceCall.getContentJSON();11actionService.doActionSetServiceCallContent(serviceCall, "content", "XML");12content = serviceCall.getContent();13contentJSON = serviceCall.getContentJSON();14actionService.doActionSetServiceCallContent(serviceCall, "content", "JSON", "JSON");15content = serviceCall.getContent();16contentJSON = serviceCall.getContentJSON();17actionService.doActionSetServiceCallContent(serviceCall, "content", "JSON", "XML");18content = serviceCall.getContent();19contentJSON = serviceCall.getContentJSON();20actionService.doActionSetServiceCallContent(serviceCall, "content", "XML", "JSON");21content = serviceCall.getContent();

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful