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

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

Source:ActionService.java Github

copy

Full Screen

...107 private ITestCaseExecutionDataService testCaseExecutionDataService;108 private static final Logger LOG = LogManager.getLogger(ActionService.class);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);1115 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1116 .replace("%PROP%", value1)1117 .replace("%COUNTRY%", tCExecution.getCountry()));1118 return message;1119 } else {1120 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALCULATEPROPERTY_PROPERTYNOTFOUND);1121 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1122 .replace("%PROP%", value1)1123 .replace("%COUNTRY%", tCExecution.getCountry()));1124 return message;1125 }1126 } else {1127 if (!(StringUtil.isNullOrEmpty(value2))) {1128 // If value2 is fed with something, we control here that value is a valid property name and gets its defintion.1129 tccp = null;1130 propertyExistOnAnyCountry = false;1131 for (TestCaseCountryProperties object : tCExecution.getTestCaseCountryPropertyList()) {1132 if ((object.getProperty().equalsIgnoreCase(value2)) && (object.getCountry().equalsIgnoreCase(tCExecution.getCountry()))) {1133 tccp = object;1134 }1135 if ((object.getProperty().equalsIgnoreCase(value2))) {1136 propertyExistOnAnyCountry = true;1137 }1138 }1139 if (tccp == null) { // Could not find a country property inside the existing execution.1140 if (propertyExistOnAnyCountry) {1141 message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NO_PROPERTY_DEFINITION);1142 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1143 .replace("%PROP%", value2)1144 .replace("%COUNTRY%", tCExecution.getCountry()));1145 return message;1146 } else {1147 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALCULATEPROPERTY_PROPERTYNOTFOUND);1148 message.setDescription(message.getDescription().replace("%ACTION%", TestCaseStepAction.ACTION_CALCULATEPROPERTY)1149 .replace("%PROP%", value2)1150 .replace("%COUNTRY%", tCExecution.getCountry()));1151 return message;1152 }1153 }1154 }1155 // We calculate the property here.1156 long now = new Date().getTime();1157 TestCaseExecutionData tcExeData;1158 tcExeData = factoryTestCaseExecutionData.create(tCExecution.getId(), tccp.getProperty(), 1, tccp.getDescription(), null, tccp.getType(),1159 tccp.getValue1(), tccp.getValue2(), null, null, now, now, now, now, new MessageEvent(MessageEventEnum.PROPERTY_PENDING),1160 tccp.getRetryNb(), tccp.getRetryPeriod(), tccp.getDatabase(), tccp.getValue1(), tccp.getValue2(), tccp.getLength(), tccp.getLength(),1161 tccp.getRowLimit(), tccp.getNature(), "", "", "", "", "", "N");1162 tcExeData.setTestCaseCountryProperties(tccp);1163 propertyService.calculateProperty(tcExeData, tCExecution, testCaseStepActionExecution, tccp, true);1164 // Property message goes to Action message.1165 message = tcExeData.getPropertyResultMessage();1166 if (message.getCodeString().equals("OK")) {1167 // If Property calculated successfully we summarize the message to a shorter version.1168 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_CALCULATEPROPERTY);1169 message.setDescription(message.getDescription()1170 .replace("%PROP%", value1)1171 .replace("%VALUE%", tcExeData.getValue()));1172 if (tcExeData.getDataLibRawData() != null) {1173 message.setDescription(message.getDescription() + " %NBROWS% row(s) with %NBSUBDATA% Subdata(s) calculated."1174 .replace("%NBROWS%", String.valueOf(tcExeData.getDataLibRawData().size()))1175 .replace("%NBSUBDATA%", String.valueOf(tcExeData.getDataLibRawData().get(0).size())));1176 }1177 }1178 if (!(StringUtil.isNullOrEmpty(value2))) {1179 // If value2 is fed we force the result to value1.1180 tcExeData.setProperty(value1);1181 }1182 //saves the result 1183 try {1184 testCaseExecutionDataService.convert(testCaseExecutionDataService.save(tcExeData));1185 LOG.debug("Adding into Execution data list. Property : '" + tcExeData.getProperty() + "' Index : '" + tcExeData.getIndex() + "' Value : '" + tcExeData.getValue() + "'");1186 tCExecution.getTestCaseExecutionDataMap().put(tcExeData.getProperty(), tcExeData);1187 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.1188 for (int i = 1; i < (tcExeData.getDataLibRawData().size()); i++) {1189 now = new Date().getTime();1190 TestCaseExecutionData tcedS = factoryTestCaseExecutionData.create(tcExeData.getId(), tcExeData.getProperty(), (i + 1),1191 tcExeData.getDescription(), tcExeData.getDataLibRawData().get(i).get(""), tcExeData.getType(), "", "",1192 tcExeData.getRC(), "", now, now, now, now, null, 0, 0, "", "", "", "", "", 0, "", "", "", "", "", "", "N");1193 testCaseExecutionDataService.convert(testCaseExecutionDataService.save(tcedS));1194 }1195 }1196 } catch (CerberusException cex) {1197 LOG.error(cex.getMessage(), cex);1198 }1199 }1200 } catch (Exception ex) {1201 LOG.error(ex.toString(), ex);1202 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_GENERIC).resolveDescription("DETAIL", ex.toString());1203 }1204 }1205 return message;1206 }1207 private String getElementToUse(String value1, String value2, String action, TestCaseExecution tCExecution) throws CerberusEventException {1208 if (!StringUtil.isNullOrEmpty(value1)) {1209 return value1;1210 } else if (!StringUtil.isNullOrEmpty(value2)) {1211 logEventService.createForPrivateCalls("ENGINE", action, MESSAGE_DEPRECATED + " Beware, in future release, it won't be allowed to use action without using field value1. Triggered by TestCase : ['" + tCExecution.getTest() + "'|'" + tCExecution.getTestCase() + "'] Property : " + value2);1212 LOG.warn(MESSAGE_DEPRECATED + " Action : " + action + ". Beware, in future release, it won't be allowed to use action without using field value1. Triggered by TestCase : ['" + tCExecution.getTest() + "'|'" + tCExecution.getTestCase() + "'] Property : " + value2);1213 return value2;1214 }1215 if (!(action.equals("wait"))) { // Wait is the only action can be excuted with no parameters. For all other actions we raize an exception as this should never happen.1216 MessageEvent message = new MessageEvent(MessageEventEnum.ACTION_FAILED_NO_ELEMENT_TO_PERFORM_ACTION);1217 message.setDescription(message.getDescription().replace("%ACTION%", action));1218 throw new CerberusEventException(message);1219 }1220 return null;1221 }1222 private MessageEvent waitTime(Long timeToWaitMs) {1223 MessageEvent message;1224 /**1225 * if timeToWait is null, throw CerberusException1226 */1227 if (timeToWaitMs == 0) {1228 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_WAIT_INVALID_FORMAT);1229 return message;1230 }1231 try {1232 LOG.debug("TIME TO WAIT = " + timeToWaitMs);1233 Thread.sleep(timeToWaitMs);1234 message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_WAIT_TIME);1235 message.setDescription(message.getDescription().replace("%TIME%", String.valueOf(timeToWaitMs)));1236 return message;1237 } catch (InterruptedException exception) {1238 LOG.info(exception.toString());1239 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_WAIT);1240 message.setDescription(message.getDescription()1241 .replace("%TIME%", String.valueOf(timeToWaitMs))1242 .replace("%MESSAGE%", exception.toString()));1243 return message;1244 }1245 }1246 private MessageEvent doActionExecuteSQLUpdate(TestCaseExecution tCExecution, String object, String property) {1247 return sqlService.executeUpdate(tCExecution.getApplicationObj().getSystem(),1248 tCExecution.getCountry(), tCExecution.getEnvironment(), object, property);1249 }1250 private MessageEvent doActionExecuteSQLStoredProcedure(TestCaseExecution tCExecution, String object, String property) {1251 return sqlService.executeCallableStatement(tCExecution.getApplicationObj().getSystem(),1252 tCExecution.getCountry(), tCExecution.getEnvironment(), object, property);1253 }1254 private MessageEvent doActionHideKeyboard(TestCaseExecution tCExecution) {1255 // Check argument1256 if (tCExecution == null) {1257 return new MessageEvent(MessageEventEnum.ACTION_FAILED_TYPE);1258 }1259 // Hide keyboard according to application type1260 String applicationType = tCExecution.getApplicationObj().getType();1261 if (Application.TYPE_APK.equals(applicationType)) {1262 return androidAppiumService.hideKeyboard(tCExecution.getSession());1263 }1264 if (Application.TYPE_IPA.equals(applicationType)) {1265 return iosAppiumService.hideKeyboard(tCExecution.getSession());1266 }1267 // Else we are faced with a non supported application1268 return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION)1269 .resolveDescription("ACTION", "Hide keyboard")1270 .resolveDescription("APPLICATIONTYPE", tCExecution.getApplicationObj().getType());1271 }1272 private MessageEvent doActionSwipe(TestCaseExecution tCExecution, String object, String property) {1273 // Check arguments1274 if (tCExecution == null || object == null) {1275 return new MessageEvent(MessageEventEnum.ACTION_FAILED_TYPE);1276 }1277 // Create the associated swipe action to the given arguments1278 SwipeAction action = null;1279 try {1280 action = SwipeAction.fromStrings(object, property);1281 } catch (Exception e) {1282 return new MessageEvent(MessageEventEnum.ACTION_FAILED_SWIPE)1283 .resolveDescription("DIRECTION", action == null ? "Unknown" : action.getActionType().name())1284 .resolveDescription("REASON", e.getMessage());1285 }1286 // Swipe screen according to the application type...

Full Screen

Full Screen

Source:ExecutionRunService.java Github

copy

Full Screen

...908 /**909 * If execution is not manual, do action and record files910 */911 if (!tcExecution.getManualExecution().equals("Y")) {912 testCaseStepActionExecution = this.actionService.doAction(testCaseStepActionExecution);913 /**914 * Record Screenshot, PageSource915 */916 try {917 testCaseStepActionExecution.addFileList(recorderService.recordExecutionInformationAfterStepActionandControl(testCaseStepActionExecution, null));918 } catch (Exception ex) {919 LOG.warn("Unable to record Screenshot/PageSource : " + ex.toString());920 }921 } else {922 /**923 * If execution manual, set Action result message as notExecuted924 */925 testCaseStepActionExecution.setActionResultMessage(new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED));926 testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_NE));...

Full Screen

Full Screen

Source:ActionServiceTest.java Github

copy

Full Screen

...88// TestCaseStepExecution tcse = new TestCaseStepExecution();89// tcse.settCExecution(tce);90// tcsae.setTestCaseStepExecution(tcse);91// 92// tcsae = this.actionService.doAction(tcsae);93//94// Assert.assertEquals(msg, tcsae.getActionResultMessage().getDescription());95// }96// @Test97// public void testDoActionClickObjectWhenSuccess() throws Exception {98// String object = "id=test";99// String property = "null";100// String msg = "Element '" + object + "' clicked.";101//102//// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();103//// tcsae.setAction("click");104//// tcsae.setObject(object);105//// tcsae.setProperty(property);106// ...

Full Screen

Full Screen

doAction

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.gwt.impl.ActionService;2import org.cerberus.engine.gwt.impl.ActionServiceAsync;3import com.google.gwt.core.client.EntryPoint;4import com.google.gwt.core.client.GWT;5import com.google.gwt.user.client.rpc.AsyncCallback;6import com.google.gwt.user.client.ui.RootPanel;7import com.google.gwt.user.client.ui.Label;8import com.google.gwt.user.client.ui.Button;9import com.google.gwt.user.client.ui.TextBox;10import com.google.gwt.user.client.ui.VerticalPanel;11import com.google.gwt.user.client.ui.HorizontalPanel;12import com.google.gwt.user.client.ui.FlexTable;13public class 3 implements EntryPoint {14 private final ActionServiceAsync actionService = GWT.create(ActionService.class);15 private VerticalPanel panel = new VerticalPanel();16 private Label label = new Label("Please enter the name of the country");17 private TextBox textBox = new TextBox();18 private Button button = new Button("Submit");19 private HorizontalPanel hPanel = new HorizontalPanel();20 private FlexTable table = new FlexTable();21 public void onModuleLoad() {22 hPanel.add(textBox);23 hPanel.add(button);24 panel.add(label);25 panel.add(hPanel);26 panel.add(table);27 RootPanel.get().add(panel);28 button.addClickHandler(new ClickHandler() {29 public void onClick(ClickEvent event) {30 actionService.doAction(textBox.getText(), new AsyncCallback() {31 public void onFailure(Throwable caught) {32 Window.alert("Error occured while processing the request");33 }34 public void onSuccess(Object result) {35 table.removeAllRows();36 table.setText(0, 0, "Name");37 table.setText(0, 1, "Capital");38 table.setText(0, 2, "Population");39 table.setText(0, 3, "Area");40 int i = 1;41 for (Iterator it = ((List) result).iterator(); it.hasNext();) {42 Country country = (Country) it.next();43 table.setText(i, 0, country.getName());44 table.setText(i, 1, country.getCapital());45 table.setText(i, 2, country.getPopulation());46 table.setText(i, 3, country.getArea());47 i++;48 }49 }50 });51 }52 });53 }54}55package org.cerberus.engine.gwt.impl;56import java.io.Serializable;57public class Country implements Serializable {58 private String name;

Full Screen

Full Screen

doAction

Using AI Code Generation

copy

Full Screen

1package com.cerberus.engine.gwt.impl;2import com.cerberus.engine.gwt.ActionService;3import com.cerberus.engine.gwt.ActionServiceAsync;4import com.google.gwt.core.client.EntryPoint;5import com.google.gwt.core.client.GWT;6import com.google.gwt.user.client.rpc.AsyncCallback;7import com.google.gwt.user.client.ui.Button;8import com.google.gwt.user.client.ui.RootPanel;9import com.google.gwt.user.client.ui.VerticalPanel;10import com.google.gwt.user.client.ui.Label;11import com.google.gwt.user.client.ui.TextBox;12import com.google.gwt.user.client.ui.FlexTable;13import com.google.gwt.user.client.ui.HasHorizontalAlignment;14import com.google.gwt.user.client.ui.HasVerticalAlignment;15import com.google.gwt.user.client.ui.HTMLTable;16import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;17import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;18import com.google.gwt.user.client.ui.Grid;19import com.google.gwt.user.client.ui.HTML;20import com.google.gwt.user.client.ui.Widget;21import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;22import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;23import com.google.gwt.user.client.ui.HasHorizontalAlignment;24import com.google.gwt.user.client.ui.HasVerticalAlignment;25import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;26import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;27import com.google.gwt.user.client.ui.HasHorizontalAlignment;28import com.google.gwt.user.client.ui.HasVerticalAlignment;29import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;30import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;31import com.google.gwt.user.client.ui.HasHorizontalAlignment;32import com.google.gwt.user.client.ui.HasVerticalAlignment;33import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;34import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;35import com.google.gwt.user.client.ui.HasHorizontalAlignment;36import com.google.gwt.user.client.ui.HasVerticalAlignment;37import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;38import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;39import com.google.gwt.user.client.ui.HasHorizontalAlignment;40import com.google.gwt.user.client.ui.HasVerticalAlignment;41import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;42import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;43import com.google.gwt.user.client.ui.HasHorizontalAlignment;44import com.google.gwt.user.client.ui.HasVerticalAlignment;45import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;46import

Full Screen

Full Screen

doAction

Using AI Code Generation

copy

Full Screen

1package com.cerberus.cerberusweb.client;2import com.google.gwt.core.client.EntryPoint;3import com.google.gwt.user.client.ui.Button;4import com.google.gwt.user.client.ui.RootPanel;5import com.google.gwt.user.client.ui.VerticalPanel;6import com.google.gwt.user.client.ui.Widget;7import com.google.gwt.user.client.ui.Label;8import com.google.gwt.user.client.ui.HasHorizontalAlignment;9import com.google.gwt.user.client.ui.HasVerticalAlignment;10import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;11import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;12import com.google.gwt.user.client.ui.HorizontalPanel;13import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;14import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;15import com.google.gwt.user.client.ui.HorizontalPanel;16import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;17import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;18import com.google.gwt.user.client.ui.HorizontalPanel;19import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;20import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;21import com.google.gwt.user.client.ui.HorizontalPanel;22import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;23import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;24import com.google.gwt.user.client.ui.HorizontalPanel;25import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;26import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;27import com.google.gwt.user.client.ui.HorizontalPanel;28import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;29import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;30import com.google.gwt.user.client.ui.HorizontalPanel;31import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;32import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;33import com.google.gwt.user.client.ui.HorizontalPanel;34import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;35import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;36import com.google.gwt.user.client.ui.HorizontalPanel;37import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;38import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;39import com.google.gwt.user.client.ui.HorizontalPanel;40import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;41import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;42import com.google.gwt.user.client.ui.HorizontalPanel;43import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;

Full Screen

Full Screen

doAction

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.gwt.impl.ActionService;2public class 3 {3 public static void main(String[] args) {4 ActionService actionService = new ActionService();5 actionService.doAction("test", "test");6 }7}8import org.cerberus.engine.gwt.impl.ActionService;9public class 4 {10 public static void main(String[] args) {11 ActionService actionService = new ActionService();12 actionService.doAction("test", "test");13 }14}15import org.cerberus.engine.gwt.impl.ActionService;16public class 5 {17 public static void main(String[] args) {18 ActionService actionService = new ActionService();19 actionService.doAction("test", "test");20 }21}22import org.cerberus.engine.gwt.impl.ActionService;23public class 6 {24 public static void main(String[] args) {25 ActionService actionService = new ActionService();26 actionService.doAction("test", "test");27 }28}29import org.cerberus.engine.gwt.impl.ActionService;30public class 7 {31 public static void main(String[] args) {32 ActionService actionService = new ActionService();33 actionService.doAction("test", "test");34 }35}36import org.cerberus.engine.gwt.impl.ActionService;37public class 8 {38 public static void main(String[] args) {39 ActionService actionService = new ActionService();40 actionService.doAction("test", "test");41 }42}

Full Screen

Full Screen

doAction

Using AI Code Generation

copy

Full Screen

1String actionName = "getActionName";2Map<String, String> actionParameters = new HashMap<String, String>();3actionParameters.put("param1", "value1");4actionParameters.put("param2", "value2");5ActionService actionService = new ActionService();6Action action = actionService.doAction(actionName, actionParameters);7String response = action.getResponse();8String responseType = action.getResponseType();9String responseCode = action.getResponseCode();10String responseMessage = action.getResponseMessage();11Map<String, String> responseHeaders = action.getResponseHeaders();12Map<String, String> responseCookies = action.getResponseCookies();13String responseBody = action.getResponseBody();14byte[] responseBodyAsByteArray = action.getResponseBodyAsByteArray();15File responseBodyAsFile = action.getResponseBodyAsFile();16InputStream responseBodyAsStream = action.getResponseBodyAsStream();

Full Screen

Full Screen

doAction

Using AI Code Generation

copy

Full Screen

1import java.util.HashMap;2import org.cerberus.engine.gwt.impl.ActionService;3import com.google.gwt.core.client.EntryPoint;4import com.google.gwt.core.client.GWT;5import com.google.gwt.user.client.Window;6import com.google.gwt.user.client.rpc.AsyncCallback;7import com.google.gwt.user.client.ui.Button;8import com.google.gwt.user.client.ui.RootPanel;9import com.google.gwt.user.client.ui.VerticalPanel;10public class 3 implements EntryPoint {11 private final ActionServiceAsync actionService = GWT.create(ActionService.class);12 public void onModuleLoad() {13 VerticalPanel vp = new VerticalPanel();14 RootPanel.get().add(vp);15 Button button = new Button("Click me");16 vp.add(button);17 button.addClickHandler(new ClickHandler() {18 public void onClick(ClickEvent event) {19 doAction();20 }21 });22 }23 private void doAction() {24 HashMap<String, String> parameters = new HashMap<String, String>();25 parameters.put("input1", "value1");26 parameters.put("input2", "value2");27 actionService.doAction("3", parameters, new AsyncCallback<HashMap<String, String>>() {28 public void onSuccess(HashMap<String, String> result) {29 Window.alert("Success: " + result.get("output"));30 }31 public void onFailure(Throwable caught) {32 Window.alert("Error: " + caught.getMessage());33 }34 });35 }36}

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