How to use verifyStringArrayContains method of org.cerberus.engine.gwt.impl.ControlService class

Best Cerberus-source code snippet using org.cerberus.engine.gwt.impl.ControlService.verifyStringArrayContains

Source:ControlService.java Github

copy

Full Screen

...308 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTMATCHREGEX:309 res = this.verifyElementTextMatchRegex(execution, value1, controlExecution.getValue2());310 break;311 case TestCaseStepActionControl.CONTROL_VERIFYSTRINGARRAYCONTAINS:312 res = this.verifyStringArrayContains(value1, value2, value3);313 break;314 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICARRAYCONTAINS:315 res = this.verifyNumericArrayContains(value1, value2);316 break;317 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTARRAYCONTAINS:318 res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTARRAYCONTAINS, execution, value1, value2, value3);319 break;320 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICARRAYCONTAINS:321 res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICARRAYCONTAINS, execution, value1, value2, value3);322 break;323 case TestCaseStepActionControl.CONTROL_VERIFYTEXTINPAGE:324 res = this.verifyTextInPage(execution, value1);325 break;326 case TestCaseStepActionControl.CONTROL_VERIFYTEXTNOTINPAGE:327 res = this.verifyTextNotInPage(execution, value1);328 break;329 case TestCaseStepActionControl.CONTROL_VERIFYTITLE:330 res = this.verifyTitle(execution, value1, controlExecution.getValue3());331 break;332 case TestCaseStepActionControl.CONTROL_VERIFYURL:333 res = this.verifyUrl(execution, value1);334 break;335 case TestCaseStepActionControl.CONTROL_VERIFYTEXTINDIALOG:336 res = this.verifyTextInDialog(execution, value1, controlExecution.getValue2());337 break;338 case TestCaseStepActionControl.CONTROL_VERIFYXMLTREESTRUCTURE:339 res = this.verifyXmlTreeStructure(execution, value1, controlExecution.getValue2());340 break;341 case TestCaseStepActionControl.CONTROL_TAKESCREENSHOT:342 res = this.takeScreenshot(execution, controlExecution.getTestCaseStepActionExecution(), controlExecution, value1);343 break;344 case TestCaseStepActionControl.CONTROL_GETPAGESOURCE:345 res = this.getPageSource(execution, controlExecution.getTestCaseStepActionExecution(), controlExecution);346 break;347 default:348 res = new MessageEvent(MessageEventEnum.CONTROL_FAILED_UNKNOWNCONTROL);349 res.resolveDescription("CONTROL", controlExecution.getControl());350 }351 } catch (final CerberusEventException exception) {352 res = exception.getMessageError();353 } catch (final Exception unexpected) {354 LOG.debug("Unexpected exception on control!", unexpected);355 res = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC).resolveDescription("ERROR", unexpected.getMessage());356 }357 // Reset Timeout to default358 robotServerService.setOptionsToDefault(execution.getSession());359 controlExecution.setControlResultMessage(res);360 /*361 * Updating Control result message only if control is not successful.362 * This is to keep the last KO information and preventing KO to be363 * transformed to OK.364 */365 if (!(res.equals(new MessageEvent(MessageEventEnum.CONTROL_SUCCESS)))) {366 controlExecution.setExecutionResultMessage(new MessageGeneral(res.getMessage()));367 }368 /*369 * We only stop the test if Control Event message is in stop status AND370 * the control is FATAL. If control is not fatal, we continue the test371 * but refresh the Execution status.372 */373 if (res.isStopTest() && controlExecution.getFatal().equals("Y")) {374 controlExecution.setStopExecution(true);375 }376 controlExecution.setEnd(new Date().getTime());377 return controlExecution;378 }379 private MessageEvent verifyStringDifferent(String value1, String value2, String isCaseSensitive) {380 MessageEvent mes;381 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? !value1.equals(value2) : !value1.equalsIgnoreCase(value2)) {382 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_STRINGDIFFERENT);383 } else {384 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_STRINGDIFFERENT);385 }386 mes.resolveDescription("STRING1", value1);387 mes.resolveDescription("STRING2", value2);388 mes.resolveDescription("STRING3", caseSensitiveMessageValue(isCaseSensitive));389 return mes;390 }391 private MessageEvent verifyStringEqual(String value1, String value2, String isCaseSensitive) {392 MessageEvent mes;393 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? value1.equals(value2) : value1.equalsIgnoreCase(value2)) {394 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_STRINGEQUAL);395 } else {396 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_STRINGEQUAL);397 }398 mes.resolveDescription("STRING1", value1);399 mes.resolveDescription("STRING2", value2);400 mes.resolveDescription("STRING3", caseSensitiveMessageValue(isCaseSensitive));401 return mes;402 }403 private MessageEvent verifyStringContains(String value1, String value2, String isCaseSensitive) {404 MessageEvent mes;405 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? value1.contains(value2) : value1.toLowerCase().contains(value2.toLowerCase())) {406 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_CONTAINS);407 } else {408 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_CONTAINS);409 }410 mes.resolveDescription("STRING1", value1);411 mes.resolveDescription("STRING2", value2);412 mes.resolveDescription("STRING3", caseSensitiveMessageValue(isCaseSensitive));413 return mes;414 }415 private MessageEvent verifyStringNotContains(String value1, String value2, String isCaseSensitive) {416 MessageEvent mes;417 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? value1.contains(value2) : value1.toLowerCase().contains(value2.toLowerCase())) {418 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTCONTAINS);419 } else {420 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTCONTAINS);421 }422 mes.resolveDescription("STRING1", value1);423 mes.resolveDescription("STRING2", value2);424 mes.resolveDescription("STRING3", caseSensitiveMessageValue(isCaseSensitive));425 return mes;426 }427 private MessageEvent verifyStringGreater(String value1, String value2) {428 MessageEvent mes;429 if (value1.compareToIgnoreCase(value2) > 0) {430 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_GREATER);431 } else {432 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GREATER);433 }434 mes.resolveDescription("STRING1", value1);435 mes.resolveDescription("STRING2", value2);436 return mes;437 }438 private MessageEvent verifyStringMinor(String value1, String value2) {439 MessageEvent mes;440 if (value1.compareToIgnoreCase(value2) < 0) {441 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_MINOR);442 } else {443 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_MINOR);444 }445 mes.resolveDescription("STRING1", value1);446 mes.resolveDescription("STRING2", value2);447 return mes;448 }449 private MessageEvent evaluateControlIfNumericXXX(String control, String controlValue1, String controlValue2) {450 if (LOG.isDebugEnabled()) {451 LOG.debug("Checking if Numeric Equals");452 }453 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_PENDING);454 // We first prepare the string for numeric conversion to replace , by .455 String newControlValue1 = StringUtil.prepareToNumeric(controlValue1);456 String newControlValue2 = StringUtil.prepareToNumeric(controlValue2);457 // We try to convert the strings value1 to numeric.458 Double value1;459 try {460 value1 = Double.valueOf(newControlValue1);461 } catch (NumberFormatException nfe) {462 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VALUES_NOTNUMERIC);463 mes.resolveDescription("COND", control);464 mes.resolveDescription("STRINGVALUE", newControlValue1);465 return mes;466 }467 // We try to convert the strings value2 to numeric.468 Double value2;469 try {470 value2 = Double.valueOf(newControlValue2);471 } catch (NumberFormatException nfe) {472 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VALUES_NOTNUMERIC);473 mes.resolveDescription("COND", control);474 mes.resolveDescription("STRINGVALUE", newControlValue2);475 return mes;476 }477 // Now that both values are converted to double we check the operator here.478 switch (control) {479 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICEQUALS:480 if (Objects.equals(value1, value2)) {481 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_EQUAL);482 } else {483 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_EQUAL);484 }485 break;486 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICDIFFERENT:487 if (!(Objects.equals(value1, value2))) {488 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_DIFFERENT);489 } else {490 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_DIFFERENT);491 }492 break;493 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICGREATER:494 if (value1 > value2) {495 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_GREATER);496 } else {497 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GREATER);498 }499 break;500 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICGREATEROREQUAL:501 if (value1 >= value2) {502 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_GREATEROREQUAL);503 } else {504 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GREATEROREQUAL);505 }506 break;507 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICMINOR:508 if (value1 < value2) {509 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_MINOR);510 } else {511 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_MINOR);512 }513 break;514 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICMINOROREQUAL:515 if (value1 <= value2) {516 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_MINOROREQUAL);517 } else {518 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_MINOROREQUAL);519 }520 break;521 default:522 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED);523 }524 mes.resolveDescription("COND", control);525 mes.resolveDescription("STRING1", value1.toString());526 mes.resolveDescription("STRING2", value2.toString());527 return mes;528 }529 private MessageEvent verifyElementPresent(TestCaseExecution tCExecution, String elementPath) {530 LOG.debug("Control: verifyElementPresent on: {}", elementPath);531 MessageEvent mes;532 if (!StringUtil.isNull(elementPath)) {533 Identifier identifier = identifierService.convertStringToIdentifier(elementPath);534 if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)535 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)536 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_IPA)) {537 try {538 if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {539 return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator(), "");540 } else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {541 return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), "", identifier.getLocator());542 } else if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {543 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT);544 mes.resolveDescription("STRING1", elementPath);545 return mes;546 } else {547 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);548 mes.resolveDescription("STRING1", elementPath);549 return mes;550 }551 } catch (WebDriverException exception) {552 return parseWebDriverException(exception);553 }554 } else if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_SRV)) {555 if (tCExecution.getLastServiceCalled() != null) {556 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();557 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {558 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:559 if (xmlUnitService.isElementPresent(responseBody, elementPath)) {560 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT);561 } else {562 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);563 }564 mes.resolveDescription("STRING1", elementPath);565 return mes;566 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {567 try {568 //Return of getFromJson can be "[]" in case when the path has this pattern "$..ex" and no elements found. Two dots after $ return a list.569 if (!jsonService.getFromJson(responseBody, null, elementPath).equals("[]")) {570 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT);571 mes.resolveDescription("STRING1", elementPath);572 return mes;573 } else {574 throw new PathNotFoundException();575 }576 } catch (PathNotFoundException ex) {577 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);578 mes.resolveDescription("STRING1", elementPath);579 return mes;580 } catch (Exception ex) {581 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);582 mes.resolveDescription("ERROR", ex.toString());583 return mes;584 }585 }586 default:587 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);588 mes.resolveDescription("TYPE", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType());589 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTPRESENT);590 return mes;591 }592 } else {593 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);594 return mes;595 }596 } else if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_FAT)) {597 if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {598 return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator(), "");599 } else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {600 return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), "", identifier.getLocator());601 } else {602 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION_AND_IDENTIFIER);603 mes.resolveDescription("IDENTIFIER", identifier.getIdentifier());604 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTPRESENT);605 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());606 return mes;607 }608 } else {609 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);610 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTPRESENT);611 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());612 return mes;613 }614 } else {615 return new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT_NULL);616 }617 }618 private MessageEvent verifyElementNotPresent(TestCaseExecution execution, String elementPath) {619 LOG.debug("Control: verifyElementNotPresent on: {}", elementPath);620 MessageEvent mes;621 if (!StringUtil.isNull(elementPath)) {622 Identifier identifier = identifierService.convertStringToIdentifier(elementPath);623 if (execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)624 || execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)625 || execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_IPA)) {626 try {627 if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {628 return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), identifier.getLocator(), "");629 } else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {630 return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), "", identifier.getLocator());631 } else if (!this.webdriverService.isElementPresent(execution.getSession(), identifier)) {632 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);633 } else {634 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);635 }636 mes.resolveDescription("STRING1", elementPath);637 return mes;638 } catch (WebDriverException exception) {639 return parseWebDriverException(exception);640 }641 } else if (execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_FAT)) {642 if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {643 return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), identifier.getLocator(), "");644 } else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {645 return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), "", identifier.getLocator());646 } else {647 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION_AND_IDENTIFIER);648 mes.resolveDescription("IDENTIFIER", identifier.getIdentifier());649 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTNOTPRESENT);650 mes.resolveDescription("APPLICATIONTYPE", execution.getAppTypeEngine());651 return mes;652 }653 } else if (execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_SRV)) {654 if (execution.getLastServiceCalled() != null) {655 String responseBody = execution.getLastServiceCalled().getResponseHTTPBody();656 switch (execution.getLastServiceCalled().getResponseHTTPBodyContentType()) {657 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:658 if (!(xmlUnitService.isElementPresent(responseBody, elementPath))) {659 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);660 } else {661 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);662 }663 mes.resolveDescription("STRING1", elementPath);664 return mes;665 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {666 try {667 //Return of getFromJson can be "[]" in case when the path has this pattern "$..ex" and no elements found. Two dots after $ return a list.668 if (!jsonService.getFromJson(responseBody, null, elementPath).equals("[]")) {669 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);670 mes.resolveDescription("STRING1", elementPath);671 return mes;672 } else {673 throw new PathNotFoundException();674 }675 } catch (PathNotFoundException ex) {676 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);677 mes.resolveDescription("STRING1", elementPath);678 return mes;679 } catch (Exception ex) {680 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);681 mes.resolveDescription("ERROR", ex.toString());682 return mes;683 }684 }685 default:686 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);687 mes.resolveDescription("TYPE", execution.getLastServiceCalled().getResponseHTTPBodyContentType());688 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTNOTPRESENT);689 return mes;690 }691 } else {692 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);693 return mes;694 }695 } else {696 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);697 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTNOTPRESENT);698 mes.resolveDescription("APPLICATIONTYPE", execution.getAppTypeEngine());699 return mes;700 }701 } else {702 return new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT_NULL);703 }704 }705 private MessageEvent verifyElementInElement(TestCaseExecution tCExecution, String element, String childElement) {706 LOG.debug("Control: verifyElementInElement on: '{}' is child of '{}'", element, childElement);707 MessageEvent mes;708 if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)709 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)) {710 if (!StringUtil.isNull(element) && !StringUtil.isNull(childElement)) {711 try {712 Identifier identifier = identifierService.convertStringToIdentifier(element);713 Identifier childIdentifier = identifierService.convertStringToIdentifier(childElement);714 if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {715 if (this.webdriverService.isElementInElement(tCExecution.getSession(), identifier, childIdentifier)) {716 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTINELEMENT);717 } else {718 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTINELEMENT);719 }720 mes.resolveDescription("STRING2", element);721 mes.resolveDescription("STRING1", childElement);722 } else {723 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NO_SUCH_ELEMENT);724 mes.resolveDescription("SELEX", new NoSuchElementException("").toString());725 mes.resolveDescription("ELEMENT", element);726 }727 } catch (WebDriverException exception) {728 return parseWebDriverException(exception);729 }730 } else {731 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTINELEMENT);732 mes.resolveDescription("STRING2", element);733 mes.resolveDescription("STRING1", childElement);734 }735 } else {736 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);737 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTINELEMENT);738 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());739 }740 return mes;741 }742 private MessageEvent verifyElementVisible(TestCaseExecution tCExecution, String html) {743 LOG.debug("Control: verifyElementVisible on: {}", html);744 MessageEvent mes;745 if (!StringUtil.isNull(html)) {746 if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)747 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)748 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_IPA)) {749 try {750 Identifier identifier = identifierService.convertStringToIdentifier(html);751 if (this.webdriverService.isElementVisible(tCExecution.getSession(), identifier)) {752 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_VISIBLE);753 } else {754 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VISIBLE);755 }756 mes.resolveDescription("STRING1", html);757 } catch (WebDriverException exception) {758 return parseWebDriverException(exception);759 }760 } else {761 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);762 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTVISIBLE);763 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());764 }765 } else {766 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VISIBLE_NULL);767 }768 return mes;769 }770 private MessageEvent verifyElementNotVisible(TestCaseExecution tCExecution, String html) {771 LOG.debug("Control: verifyElementNotVisible on: {}", html);772 MessageEvent mes;773 if (!StringUtil.isNull(html)) {774 if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)775 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)776 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_IPA)) {777 try {778 Identifier identifier = identifierService.convertStringToIdentifier(html);779 if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {780 if (this.webdriverService.isElementNotVisible(tCExecution.getSession(), identifier)) {781 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTVISIBLE);782 } else {783 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTVISIBLE);784 }785 mes.resolveDescription("STRING1", html);786 } else {787 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);788 }789 mes.resolveDescription("STRING1", html);790 } catch (WebDriverException exception) {791 return parseWebDriverException(exception);792 }793 } else {794 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);795 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTNOTVISIBLE);796 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());797 }798 } else {799 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTVISIBLE_NULL);800 }801 return mes;802 }803 private MessageEvent verifyElementEquals(TestCaseExecution tCExecution, String xpath, String expectedElement) {804 LOG.debug("Control: verifyElementEquals on: {} expected Element: {}", xpath, expectedElement);805 MessageEvent mes;806 // If case of not compatible application then exit with error807 if (!tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_SRV)) {808 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);809 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTEQUALS);810 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());811 } else if (tCExecution.getLastServiceCalled() != null) {812 // Check if element on the given xpath is equal to the given expected element813 String xmlResponse = tCExecution.getLastServiceCalled().getResponseHTTPBody();814 if (AppService.RESPONSEHTTPBODYCONTENTTYPE_XML.equals(tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType())) {815 mes = xmlUnitService.isElementEquals(xmlResponse, xpath, expectedElement) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTEQUALS) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTEQUALS);816 mes.resolveDescription("XPATH", xpath);817 mes.resolveDescription("EXPECTED_ELEMENT", expectedElement);818 } else {819 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);820 mes.resolveDescription("TYPE", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType());821 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTEQUALS);822 }823 } else {824 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);825 }826 return mes;827 }828 private MessageEvent verifyElementDifferent(TestCaseExecution tCExecution, String xpath, String differentElement) {829 LOG.debug("Control: verifyElementDifferent on: {} expected Element: {}", xpath, differentElement);830 MessageEvent mes = null;831 // If case of not compatible application then exit with error832 if (!tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_SRV)) {833 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);834 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTDIFFERENT);835 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());836 } else if (tCExecution.getLastServiceCalled() != null) {837 //Check if element on the given xpath is different from the given different element838 if (AppService.RESPONSEHTTPBODYCONTENTTYPE_XML.equals(tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType())) {839 String xmlResponse = tCExecution.getLastServiceCalled().getResponseHTTPBody();840 mes = xmlUnitService.isElementEquals(xmlResponse, xpath, differentElement) ? new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTDIFFERENT) : new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTDIFFERENT);841 mes.resolveDescription("XPATH", xpath);842 mes.resolveDescription("DIFFERENT_ELEMENT", differentElement);843 } else {844 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);845 mes.resolveDescription("TYPE", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType());846 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTDIFFERENT);847 }848 } else {849 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);850 }851 return mes;852 }853 @Override854 public MessageEvent verifyElementXXX(String control, TestCaseExecution tCExecution, String path, String expected, String isCaseSensitive) {855 LOG.debug("Control: verifyElementXXX ({}) on {} element against value: {} AppType: {}", control, path, expected, tCExecution.getAppTypeEngine());856 MessageEvent mes;857 // Get value from the path element according to the application type858 String actual;859 try {860 Identifier identifier = identifierService.convertStringToIdentifier(path);861 String applicationType = tCExecution.getAppTypeEngine();862 switch (applicationType) {863 case Application.TYPE_GUI:864 case Application.TYPE_APK:865 case Application.TYPE_IPA:866 actual = webdriverService.getValueFromHTML(tCExecution.getSession(), identifier);867 // In case of null actual value then we alert user868 if (actual == null) {869 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENT_NULL);870 mes.resolveDescription("STRING1", path);871 return mes;872 }873 // Get the result depending on the control required.874 mes = switchControl(control, path, actual, expected, isCaseSensitive);875 return mes;876 case Application.TYPE_SRV:877 if (tCExecution.getLastServiceCalled() != null) {878 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();879 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {880 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:881 if (!xmlUnitService.isElementPresent(responseBody, path)) {882 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENT_NOSUCHELEMENT);883 mes.resolveDescription("ELEMENT", path);884 return mes;885 }886 String newPath = StringUtil.addSuffixIfNotAlready(path, "/text()");887 actual = xmlUnitService.getFromXml(responseBody, newPath);888 // In case of null actual value then we alert user889 if (actual == null) {890 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENT_NULL);891 mes.resolveDescription("ELEMENT", path);892 return mes;893 }894 // Get the result depending on the control required.895 mes = switchControl(control, path, actual, expected, isCaseSensitive);896 return mes;897 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {898 try {899 actual = jsonService.getFromJson(responseBody, null, path);900 } catch (Exception ex) {901 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);902 mes.resolveDescription("ERROR", ex.toString());903 return mes;904 }905 }906 // In case of null actual value then we alert user907 if (actual == null) {908 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENT_NOSUCHELEMENT);909 mes.resolveDescription("ELEMENT", path);910 return mes;911 }912 // Get the result depending on the control required.913 mes = switchControl(control, path, actual, expected, isCaseSensitive);914 return mes;915 default:916 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);917 mes.resolveDescription("TYPE", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType());918 mes.resolveDescription("CONTROL", control);919 return mes;920 }921 } else {922 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);923 return mes;924 }925 default:926 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);927 mes.resolveDescription("CONTROL", control);928 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());929 return mes;930 }931 } catch (NoSuchElementException exception) {932 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENT_NOSUCHELEMENT);933 mes.resolveDescription("ELEMENT", path);934 return mes;935 } catch (WebDriverException exception) {936 return parseWebDriverException(exception);937 }938 }939 private MessageEvent switchControl(String control, String path, String actual, String expected, String isCaseSensitive) {940 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);941 mes.resolveDescription("CONTROL", "switchControl-" + control);942 switch (control) {943 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTEQUAL:944 mes = verifyElementTextEqualCaseSensitiveCheck(actual, expected, isCaseSensitive);945 break;946 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTDIFFERENT:947 mes = verifyElementTextDifferentCaseSensitiveCheck(actual, expected, isCaseSensitive);948 break;949 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTCONTAINS:950 mes = verifyElementTextContainsCaseSensitiveCheck(actual, expected, isCaseSensitive);951 break;952 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTARRAYCONTAINS:953 //We use verifyStringArrayContains because it's the same behaviour. Difference is that here we retrieve array using json path or xpath954 mes = this.verifyElementTextArrayContains(actual, expected, isCaseSensitive);955 break;956 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICARRAYCONTAINS:957 //We use verifyStringArrayContains because it's the same behaviour. Difference is that here we retrieve array using json path or xpath958 mes = this.verifyElementNumericArrayContains(actual, expected);959 break;960 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICEQUAL:961 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICDIFFERENT:962 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICGREATER:963 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICGREATEROREQUAL:964 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICMINOR:965 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICMINOROREQUAL:966 double value1;967 try {968 value1 = Double.parseDouble(actual);969 } catch (NumberFormatException nfe) {970 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VALUES_NOTNUMERIC);971 mes.resolveDescription("COND", control);972 mes.resolveDescription("STRINGVALUE", actual);973 return mes;974 }975 // We try to convert the strings value2 to numeric.976 double value2;977 try {978 value2 = Double.parseDouble(expected);979 } catch (NumberFormatException nfe) {980 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VALUES_NOTNUMERIC);981 mes.resolveDescription("COND", control);982 mes.resolveDescription("STRINGVALUE", expected);983 return mes;984 }985 mes = checkNumericVerifyElement(control, value1, value2);986 break;987 }988 mes.resolveDescription("ELEMENT", path);989 mes.resolveDescription("ELEMENTVALUE", actual);990 mes.resolveDescription("VALUE", expected);991 mes.resolveDescription("CASESENSITIVE", caseSensitiveMessageValue(isCaseSensitive));992 return mes;993 }994 private MessageEvent verifyElementTextEqualCaseSensitiveCheck(String actual, String expected, String isCaseSensitive) {995 MessageEvent mes;996 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false)) {997 mes = actual.equals(expected) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTTEXTEQUAL) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTTEXTEQUAL);998 } else {999 mes = actual.equalsIgnoreCase(expected) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTTEXTEQUAL) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTTEXTEQUAL);1000 }1001 return mes;1002 }1003 private MessageEvent verifyElementTextDifferentCaseSensitiveCheck(String actual, String expected, String isCaseSensitive) {1004 MessageEvent mes;1005 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false)) {1006 mes = actual.equals(expected) ? new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTTEXTDIFFERENT) : new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTTEXTDIFFERENT);1007 } else {1008 mes = actual.equalsIgnoreCase(expected) ? new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTTEXTDIFFERENT) : new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTTEXTDIFFERENT);1009 }1010 return mes;1011 }1012 private MessageEvent verifyElementTextContainsCaseSensitiveCheck(String text, String textToSearch, String isCaseSensitive) {1013 MessageEvent mes;1014 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false)) {1015 mes = text.contains(textToSearch) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTTEXTCONTAINS) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTTEXTCONTAINS);1016 } else {1017 mes = text.toLowerCase().contains(textToSearch.toLowerCase()) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTTEXTCONTAINS) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTTEXTCONTAINS);1018 }1019 return mes;1020 }1021 private MessageEvent checkNumericVerifyElement(String control, Double actual, Double expected) {1022 switch (control) {1023 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICEQUAL:1024 return actual.equals(expected)1025 ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTNUMERICEQUAL)1026 : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTNUMERICEQUAL);1027 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICDIFFERENT:1028 return !actual.equals(expected)1029 ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTNUMERICDIFFERENT)1030 : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTNUMERICDIFFERENT);1031 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICGREATER:1032 return actual > expected1033 ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTNUMERICGREATER)1034 : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTNUMERICGREATER);1035 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICGREATEROREQUAL:1036 return actual >= expected1037 ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTNUMERICGREATEROREQUAL)1038 : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTNUMERICGREATEROREQUAL);1039 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICMINOR:1040 return actual < expected1041 ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTNUMERICMINOR)1042 : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTNUMERICMINOR);1043 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICMINOROREQUAL:1044 return actual <= expected1045 ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTNUMERICMINOROREQUAL)1046 : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTNUMERICMINOROREQUAL);1047 default:1048 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1049 return mes.resolveDescription("CONTROL", "checkNumericVerifyElement-" + control);1050 }1051 }1052 private MessageEvent verifyElementTextMatchRegex(TestCaseExecution tCExecution, String path, String regex) {1053 LOG.debug("Control: VerifyElementTextMatchRegex on: {} element against value: {}", path, regex);1054 MessageEvent mes;1055 String pathContent;1056 try {1057 Identifier identifier = identifierService.convertStringToIdentifier(path);1058 String applicationType = tCExecution.getAppTypeEngine();1059 // Get value from the path element according to the application type1060 if (Application.TYPE_GUI.equalsIgnoreCase(applicationType)1061 || Application.TYPE_APK.equalsIgnoreCase(applicationType)1062 || Application.TYPE_IPA.equalsIgnoreCase(applicationType)) {1063 pathContent = this.webdriverService.getValueFromHTML(tCExecution.getSession(), identifier);1064 } else if (Application.TYPE_SRV.equalsIgnoreCase(applicationType)) {1065 if (tCExecution.getLastServiceCalled() != null) {1066 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();1067 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {1068 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:1069 if (!xmlUnitService.isElementPresent(responseBody, path)) {1070 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENT_NOSUCHELEMENT);1071 mes.resolveDescription("ELEMENT", path);1072 return mes;1073 }1074 String newPath = StringUtil.addSuffixIfNotAlready(path, "/text()");1075 pathContent = xmlUnitService.getFromXml(responseBody, newPath);1076 break;1077 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON:1078 try {1079 pathContent = jsonService.getFromJson(responseBody, null, path);1080 } catch (Exception ex) {1081 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);1082 mes.resolveDescription("ERROR", ex.toString());1083 return mes;1084 }1085 break;1086 default:1087 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);1088 mes.resolveDescription("TYPE", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType());1089 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTMATCHREGEX);1090 return mes;1091 }1092 // TODO Give the actual element found into the description.1093 } else {1094 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);1095 return mes;1096 }1097 } else {1098 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1099 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTMATCHREGEX);1100 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());1101 return mes;1102 }1103 LOG.debug("Control: VerifyElementMatchRegex element: {} has value: {}", path, StringUtil.sanitize(pathContent));1104 if (path != null && pathContent != null) {1105 try {1106 Pattern pattern = Pattern.compile(regex);1107 Matcher matcher = pattern.matcher(pathContent);1108 if (matcher.find()) {1109 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_REGEXINELEMENT);1110 } else {1111 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_REGEXINELEMENT);1112 }1113 mes.resolveDescription("STRING1", path);1114 mes.resolveDescription("STRING2", StringUtil.sanitize(pathContent));1115 mes.resolveDescription("STRING3", regex);1116 } catch (PatternSyntaxException e) {1117 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_REGEXINELEMENT_INVALIDPATTERN);1118 mes.resolveDescription("PATTERN", regex);1119 mes.resolveDescription("ERROR", e.getMessage());1120 }1121 } else if (pathContent != null) {1122 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_REGEXINELEMENT_NULL);1123 } else {1124 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_REGEXINELEMENT_NO_SUCH_ELEMENT);1125 mes.resolveDescription("ELEMENT", path);1126 }1127 } catch (NoSuchElementException exception) {1128 LOG.debug(exception.toString());1129 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_REGEXINELEMENT_NO_SUCH_ELEMENT);1130 mes.resolveDescription("ELEMENT", path);1131 } catch (WebDriverException exception) {1132 return parseWebDriverException(exception);1133 }1134 return mes;1135 }1136 private MessageEvent verifyStringArrayContains(String array, String valueToSearch, String isCaseSensitive) {1137 MessageEvent mes;1138 try {1139 List<String> strings = StringUtil.convertStringToStringArray(array);1140 //When user choose case sensitive option1141 boolean isContained = ParameterParserUtil.parseBooleanParam(isCaseSensitive, false)1142 ? strings.stream().anyMatch(valueToSearch::equals)1143 : strings.stream().anyMatch(valueToSearch::equalsIgnoreCase);1144 mes = isContained1145 ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_STRINGARRAYCONTAINS)1146 : new MessageEvent(MessageEventEnum.CONTROL_FAILED_STRINGARRAYCONTAINS);1147 mes.resolveDescription("ELEMENT", array);1148 mes.resolveDescription("VALUE", valueToSearch);1149 mes.resolveDescription("CASESENSITIVE", caseSensitiveMessageValue(isCaseSensitive));1150 } catch (JsonProcessingException exception) {1151 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);1152 mes.resolveDescription("ERROR", "Incorrect array structure.");1153 }1154 return mes;1155 }1156 private MessageEvent verifyNumericArrayContains(String array, String numberToSearch) {1157 MessageEvent mes;1158 try {1159 List<Double> doubles = StringUtil.convertStringToDoubleArray(array);1160 Double number = Double.parseDouble(numberToSearch);1161 mes = doubles.stream().anyMatch(number::equals)1162 ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NUMERICARRAYCONTAINS)1163 : new MessageEvent(MessageEventEnum.CONTROL_FAILED_NUMERICARRAYCONTAINS);1164 mes.resolveDescription("ELEMENT", array);1165 mes.resolveDescription("VALUE", numberToSearch);1166 } catch (JsonProcessingException exception) {1167 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);1168 mes.resolveDescription("ERROR", "Incorrect array structure.");1169 } catch (NumberFormatException exception) {1170 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC)1171 .resolveDescription("ERROR", "Value to search must be a number and the array must be an array of numbers.");1172 }1173 return mes;1174 }1175 private MessageEvent verifyElementTextArrayContains(String array, String valueToSearch, String isCaseSensitive) {1176 //We use verifyStringArrayContains because it's the same behaviour. The difference is that here we have an array retrieved using json path or xpath.1177 MessageEvent mes = this.verifyStringArrayContains(array, valueToSearch, isCaseSensitive);1178 //Change the message event to adapt to this control.1179 if (!mes.getSource().equals(MessageEventEnum.CONTROL_FAILED_GENERIC)) {1180 if (mes.getCodeString().equals("OK")) {1181 mes.setDescription(MessageEventEnum.CONTROL_SUCCESS_ELEMENTTEXTARRAYCONTAINS.getDescription());1182 } else {1183 mes.setDescription(MessageEventEnum.CONTROL_FAILED_ELEMENTTEXTARRAYCONTAINS.getDescription());1184 }1185 }1186 return mes;1187 }1188 private MessageEvent verifyElementNumericArrayContains(String array, String numberToSearch) {1189 //We use verifyStringArrayContains because it's the same behaviour. The difference is that here we have an array retrieved using json path or xpath.1190 MessageEvent mes = this.verifyNumericArrayContains(array, numberToSearch);1191 //Change the message event to adapt to this control.1192 if (!mes.getSource().equals(MessageEventEnum.CONTROL_FAILED_GENERIC)) {1193 if (mes.getCodeString().equals("OK")) {1194 mes.setDescription(MessageEventEnum.CONTROL_SUCCESS_ELEMENTNUMERICARRAYCONTAINS.getDescription());1195 } else {1196 mes.setDescription(MessageEventEnum.CONTROL_FAILED_ELEMENTNUMERICARRAYCONTAINS.getDescription());1197 }1198 }1199 return mes;1200 }1201 private MessageEvent verifyTextInDialog(TestCaseExecution tCExecution, String property, String value) {1202 LOG.debug("Control: verifyTextInDialog against value: {}", value);1203 MessageEvent mes;...

Full Screen

Full Screen

verifyStringArrayContains

Using AI Code Generation

copy

Full Screen

1List<String> expected = new ArrayList<String>();2expected.add("a");3expected.add("b");4expected.add("c");5List<String> actual = new ArrayList<String>();6actual.add("a");7actual.add("b");8actual.add("c");9actual.add("d");10ControlService controlService = new ControlService();11controlService.verifyStringArrayContains(expected, actual);12List<String> expected = new ArrayList<String>();13expected.add("a");14expected.add("b");15expected.add("c");16List<String> actual = new ArrayList<String>();17actual.add("a");18actual.add("b");19actual.add("c");20actual.add("d");21ControlService controlService = new ControlService();22controlService.verifyStringArrayNotContains(expected, actual);23List<String> expected = new ArrayList<String>();24expected.add("a");25expected.add("b");26expected.add("c");27List<String> actual = new ArrayList<String>();28actual.add("a");29actual.add("b");30actual.add("c");31actual.add("d");32ControlService controlService = new ControlService();33controlService.verifyStringArrayContains(expected, actual);34List<String> expected = new ArrayList<String>();35expected.add("a");36expected.add("b");37expected.add("c");38List<String> actual = new ArrayList<String>();39actual.add("a");40actual.add("b");41actual.add("c");42actual.add("d");43ControlService controlService = new ControlService();44controlService.verifyStringArrayNotContains(expected, actual);

Full Screen

Full Screen

verifyStringArrayContains

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.gwt.impl.ControlService;2ControlService controlService = new ControlService();3String[] stringArray = { "a", "b", "c", "d" };4controlService.verifyStringArrayContains(stringArray, "a");5controlService.verifyStringArrayContains(stringArray, "a", "b");6controlService.verifyStringArrayContains(stringArray, "a", "b", "c");7controlService.verifyStringArrayContains(stringArray, "a", "b", "c", "d");8controlService.verifyStringArrayContains(stringArray, "a", "b", "c", "d", "e");9controlService.verifyStringArrayContains(stringArray, "a", "b", "c", "d", "e", "f");10controlService.verifyStringArrayContains(stringArray, "a", "b", "c", "d", "e", "f", "g");11controlService.verifyStringArrayContains(stringArray, "a", "b", "c", "d", "e", "f", "g", "h");12controlService.verifyStringArrayContains(stringArray, "a", "b", "c", "d", "e", "f", "g", "h", "i");13controlService.verifyStringArrayContains(stringArray, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j");14controlService.verifyStringArrayContains(stringArray, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k");15controlService.verifyStringArrayContains(stringArray, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l");16controlService.verifyStringArrayContains(stringArray, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m");17controlService.verifyStringArrayContains(stringArray, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n");18controlService.verifyStringArrayContains(stringArray, "a", "b", "c

Full Screen

Full Screen

verifyStringArrayContains

Using AI Code Generation

copy

Full Screen

1importClass(org.cerberus.engine.gwt.impl.ControlService);2var controlService = new ControlService();3var array = ["test1", "test2", "test3"];4controlService.verifyStringArrayContains(array, "test2");5controlService.verifyStringArrayNotContains(array, "test1");6controlService.verifyStringArrayNotContains(array, "test4");7controlService.verifyStringArrayNotContains(array, "test1");8controlService.verifyStringArrayNotContains(array, "test4");9controlService.verifyStringArrayNotContains(array, "test1");10controlService.verifyStringArrayNotContains(array, "test4");11controlService.verifyStringArrayNotContains(array, "test1");12controlService.verifyStringArrayNotContains(array, "test4");13controlService.verifyStringArrayNotContains(array, "test1");14controlService.verifyStringArrayNotContains(array, "test4");15controlService.verifyStringArrayNotContains(array,

Full Screen

Full Screen

verifyStringArrayContains

Using AI Code Generation

copy

Full Screen

1String[] array = new String[]{"a","b","c","d"};2verifyStringArrayContains(array,"a",",");3verifyStringArrayContains(array,"b",",");4verifyStringArrayContains(array,"c",",");5verifyStringArrayContains(array,"d",",");6verifyStringArrayContains(array,"e",",");7verifyStringArrayContains(array,"f",",");8verifyStringArrayContains(array,"g",",");9verifyStringArrayContains(array,"h",",");10verifyStringArrayContains(array,"i",",");11verifyStringArrayContains(array,"j",",");12verifyStringArrayContains(array,"k",",");13verifyStringArrayContains(array,"l",",");14verifyStringArrayContains(array,"m",",");15verifyStringArrayContains(array,"n",",");16verifyStringArrayContains(array,"o",",");17verifyStringArrayContains(array,"p",",");18verifyStringArrayContains(array,"q",",");19verifyStringArrayContains(array,"r",",");20verifyStringArrayContains(array,"s",",");21verifyStringArrayContains(array,"t",",");22verifyStringArrayContains(array,"u",",");23verifyStringArrayContains(array,"v",",");24verifyStringArrayContains(array,"w",",");

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