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

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

Source:ControlService.java Github

copy

Full Screen

...259 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTVISIBLE:260 res = this.verifyElementVisible(execution, value1);261 break;262 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNOTVISIBLE:263 res = this.verifyElementNotVisible(execution, value1);264 break;265 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTEQUALS:266 res = this.verifyElementEquals(execution, value1, controlExecution.getValue2());267 break;268 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTDIFFERENT:269 res = this.verifyElementDifferent(execution, value1, controlExecution.getValue2());270 break;271 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTINELEMENT:272 res = this.verifyElementInElement(execution, value1, controlExecution.getValue2());273 break;274 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTCLICKABLE:275 res = this.verifyElementClickable(execution, value1);276 break;277 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNOTCLICKABLE:278 res = this.verifyElementNotClickable(execution, value1);279 break;280 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTEQUAL:281 res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTEQUAL, execution, value1, controlExecution.getValue2(), controlExecution.getValue3());282 break;283 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTDIFFERENT:284 res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTDIFFERENT, execution, value1, controlExecution.getValue2(), controlExecution.getValue3());285 break;286 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTCONTAINS:287 res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTCONTAINS, execution, value1, controlExecution.getValue2(), controlExecution.getValue3());288 break;289 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICEQUAL:290 res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICEQUAL, execution, value1, controlExecution.getValue2(), controlExecution.getValue3());291 break;292 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICDIFFERENT:293 res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICDIFFERENT, execution, value1, controlExecution.getValue2(), controlExecution.getValue3());294 break;295 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICGREATER:296 res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICGREATER, execution, value1, controlExecution.getValue2(), controlExecution.getValue3());297 break;298 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICGREATEROREQUAL:299 res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICGREATEROREQUAL, execution, value1, controlExecution.getValue2(), controlExecution.getValue3());300 break;301 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICMINOR:302 res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICMINOR, execution, value1, controlExecution.getValue2(), controlExecution.getValue3());303 break;304 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICMINOROREQUAL:305 res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICMINOROREQUAL, execution, value1, controlExecution.getValue2(), controlExecution.getValue3());306 break;307 case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTMATCHREGEX:308 res = this.verifyElementTextMatchRegex(execution, value1, controlExecution.getValue2());309 break;310 case TestCaseStepActionControl.CONTROL_VERIFYTEXTINPAGE:311 res = this.verifyTextInPage(execution, value1);312 break;313 case TestCaseStepActionControl.CONTROL_VERIFYTEXTNOTINPAGE:314 res = this.verifyTextNotInPage(execution, value1);315 break;316 case TestCaseStepActionControl.CONTROL_VERIFYTITLE:317 res = this.verifyTitle(execution, value1, controlExecution.getValue3());318 break;319 case TestCaseStepActionControl.CONTROL_VERIFYURL:320 res = this.verifyUrl(execution, value1);321 break;322 case TestCaseStepActionControl.CONTROL_VERIFYTEXTINDIALOG:323 res = this.verifyTextInDialog(execution, value1, controlExecution.getValue2());324 break;325 case TestCaseStepActionControl.CONTROL_VERIFYXMLTREESTRUCTURE:326 res = this.verifyXmlTreeStructure(execution, value1, controlExecution.getValue2());327 break;328 case TestCaseStepActionControl.CONTROL_TAKESCREENSHOT:329 res = this.takeScreenshot(execution, controlExecution.getTestCaseStepActionExecution(), controlExecution, value1);330 break;331 case TestCaseStepActionControl.CONTROL_GETPAGESOURCE:332 res = this.getPageSource(execution, controlExecution.getTestCaseStepActionExecution(), controlExecution);333 break;334 default:335 res = new MessageEvent(MessageEventEnum.CONTROL_FAILED_UNKNOWNCONTROL);336 res.resolveDescription("CONTROL", controlExecution.getControl());337 }338 } catch (final CerberusEventException exception) {339 res = exception.getMessageError();340 } catch (final Exception unexpected) {341 LOG.debug("Unexpected exception on control!", unexpected);342 res = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC).resolveDescription("ERROR", unexpected.getMessage());343 }344 // Reset Timeout to default345 robotServerService.setOptionsToDefault(execution.getSession());346 controlExecution.setControlResultMessage(res);347 /*348 * Updating Control result message only if control is not successful.349 * This is to keep the last KO information and preventing KO to be350 * transformed to OK.351 */352 if (!(res.equals(new MessageEvent(MessageEventEnum.CONTROL_SUCCESS)))) {353 controlExecution.setExecutionResultMessage(new MessageGeneral(res.getMessage()));354 }355 /*356 * We only stop the test if Control Event message is in stop status AND357 * the control is FATAL. If control is not fatal, we continue the test358 * but refresh the Execution status.359 */360 if (res.isStopTest() && controlExecution.getFatal().equals("Y")) {361 controlExecution.setStopExecution(true);362 }363 controlExecution.setEnd(new Date().getTime());364 return controlExecution;365 }366 private MessageEvent verifyStringDifferent(String value1, String value2, String isCaseSensitive) {367 MessageEvent mes;368 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? !value1.equals(value2) : !value1.equalsIgnoreCase(value2)) {369 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_STRINGDIFFERENT);370 } else {371 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_STRINGDIFFERENT);372 }373 mes.resolveDescription("STRING1", value1);374 mes.resolveDescription("STRING2", value2);375 mes.resolveDescription("STRING3", caseSensitiveMessageValue(isCaseSensitive));376 return mes;377 }378 private MessageEvent verifyStringEqual(String value1, String value2, String isCaseSensitive) {379 MessageEvent mes;380 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? value1.equals(value2) : value1.equalsIgnoreCase(value2)) {381 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_STRINGEQUAL);382 } else {383 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_STRINGEQUAL);384 }385 mes.resolveDescription("STRING1", value1);386 mes.resolveDescription("STRING2", value2);387 mes.resolveDescription("STRING3", caseSensitiveMessageValue(isCaseSensitive));388 return mes;389 }390 private MessageEvent verifyStringContains(String value1, String value2, String isCaseSensitive) {391 MessageEvent mes;392 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? value1.contains(value2) : value1.toLowerCase().contains(value2.toLowerCase())) {393 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_CONTAINS);394 } else {395 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_CONTAINS);396 }397 mes.resolveDescription("STRING1", value1);398 mes.resolveDescription("STRING2", value2);399 mes.resolveDescription("STRING3", caseSensitiveMessageValue(isCaseSensitive));400 return mes;401 }402 private MessageEvent verifyStringNotContains(String value1, String value2, String isCaseSensitive) {403 MessageEvent mes;404 if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false) ? value1.contains(value2) : value1.toLowerCase().contains(value2.toLowerCase())) {405 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTCONTAINS);406 } else {407 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTCONTAINS);408 }409 mes.resolveDescription("STRING1", value1);410 mes.resolveDescription("STRING2", value2);411 mes.resolveDescription("STRING3", caseSensitiveMessageValue(isCaseSensitive));412 return mes;413 }414 private MessageEvent verifyStringGreater(String value1, String value2) {415 MessageEvent mes;416 if (value1.compareToIgnoreCase(value2) > 0) {417 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_GREATER);418 } else {419 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GREATER);420 }421 mes.resolveDescription("STRING1", value1);422 mes.resolveDescription("STRING2", value2);423 return mes;424 }425 private MessageEvent verifyStringMinor(String value1, String value2) {426 MessageEvent mes;427 if (value1.compareToIgnoreCase(value2) < 0) {428 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_MINOR);429 } else {430 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_MINOR);431 }432 mes.resolveDescription("STRING1", value1);433 mes.resolveDescription("STRING2", value2);434 return mes;435 }436 private MessageEvent evaluateControlIfNumericXXX(String control, String controlValue1, String controlValue2) {437 if (LOG.isDebugEnabled()) {438 LOG.debug("Checking if Numeric Equals");439 }440 MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_PENDING);441 // We first prepare the string for numeric conversion to replace , by .442 String newControlValue1 = StringUtil.prepareToNumeric(controlValue1);443 String newControlValue2 = StringUtil.prepareToNumeric(controlValue2);444 // We try to convert the strings value1 to numeric.445 Double value1;446 try {447 value1 = Double.valueOf(newControlValue1);448 } catch (NumberFormatException nfe) {449 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VALUES_NOTNUMERIC);450 mes.resolveDescription("COND", control);451 mes.resolveDescription("STRINGVALUE", newControlValue1);452 return mes;453 }454 // We try to convert the strings value2 to numeric.455 Double value2;456 try {457 value2 = Double.valueOf(newControlValue2);458 } catch (NumberFormatException nfe) {459 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VALUES_NOTNUMERIC);460 mes.resolveDescription("COND", control);461 mes.resolveDescription("STRINGVALUE", newControlValue2);462 return mes;463 }464 // Now that both values are converted to double we check the operator here.465 switch (control) {466 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICEQUALS:467 if (Objects.equals(value1, value2)) {468 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_EQUAL);469 } else {470 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_EQUAL);471 }472 break;473 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICDIFFERENT:474 if (!(Objects.equals(value1, value2))) {475 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_DIFFERENT);476 } else {477 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_DIFFERENT);478 }479 break;480 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICGREATER:481 if (value1 > value2) {482 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_GREATER);483 } else {484 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GREATER);485 }486 break;487 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICGREATEROREQUAL:488 if (value1 >= value2) {489 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_GREATEROREQUAL);490 } else {491 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GREATEROREQUAL);492 }493 break;494 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICMINOR:495 if (value1 < value2) {496 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_MINOR);497 } else {498 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_MINOR);499 }500 break;501 case TestCaseStepActionControl.CONTROL_VERIFYNUMERICMINOROREQUAL:502 if (value1 <= value2) {503 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_MINOROREQUAL);504 } else {505 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_MINOROREQUAL);506 }507 break;508 default:509 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED);510 }511 mes.resolveDescription("COND", control);512 mes.resolveDescription("STRING1", value1.toString());513 mes.resolveDescription("STRING2", value2.toString());514 return mes;515 }516 private MessageEvent verifyElementPresent(TestCaseExecution tCExecution, String elementPath) {517 LOG.debug("Control: verifyElementPresent on: {}", elementPath);518 MessageEvent mes;519 if (!StringUtil.isNull(elementPath)) {520 Identifier identifier = identifierService.convertStringToIdentifier(elementPath);521 if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)522 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)523 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_IPA)) {524 try {525 if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {526 return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator(), "");527 } else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {528 return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), "", identifier.getLocator());529 } else if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {530 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT);531 mes.resolveDescription("STRING1", elementPath);532 return mes;533 } else {534 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);535 mes.resolveDescription("STRING1", elementPath);536 return mes;537 }538 } catch (WebDriverException exception) {539 return parseWebDriverException(exception);540 }541 } else if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_SRV)) {542 if (tCExecution.getLastServiceCalled() != null) {543 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();544 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {545 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:546 if (xmlUnitService.isElementPresent(responseBody, elementPath)) {547 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT);548 } else {549 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);550 }551 mes.resolveDescription("STRING1", elementPath);552 return mes;553 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {554 try {555 //Return of getFromJson can be "[]" in case when the path has this pattern "$..ex" and no elements found. Two dots after $ return a list.556 if (!jsonService.getFromJson(responseBody, null, elementPath).equals("[]")) {557 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT);558 mes.resolveDescription("STRING1", elementPath);559 return mes;560 } else {561 throw new PathNotFoundException();562 }563 } catch (PathNotFoundException ex) {564 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);565 mes.resolveDescription("STRING1", elementPath);566 return mes;567 } catch (Exception ex) {568 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);569 mes.resolveDescription("ERROR", ex.toString());570 return mes;571 }572 }573 default:574 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);575 mes.resolveDescription("TYPE", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType());576 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTPRESENT);577 return mes;578 }579 } else {580 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);581 return mes;582 }583 } else if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_FAT)) {584 if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {585 return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator(), "");586 } else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {587 return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), "", identifier.getLocator());588 } else {589 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION_AND_IDENTIFIER);590 mes.resolveDescription("IDENTIFIER", identifier.getIdentifier());591 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTPRESENT);592 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());593 return mes;594 }595 } else {596 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);597 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTPRESENT);598 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());599 return mes;600 }601 } else {602 return new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT_NULL);603 }604 }605 private MessageEvent verifyElementNotPresent(TestCaseExecution execution, String elementPath) {606 LOG.debug("Control: verifyElementNotPresent on: {}", elementPath);607 MessageEvent mes;608 if (!StringUtil.isNull(elementPath)) {609 Identifier identifier = identifierService.convertStringToIdentifier(elementPath);610 if (execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)611 || execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)612 || execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_IPA)) {613 try {614 if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {615 return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), identifier.getLocator(), "");616 } else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {617 return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), "", identifier.getLocator());618 } else if (!this.webdriverService.isElementPresent(execution.getSession(), identifier)) {619 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);620 } else {621 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);622 }623 mes.resolveDescription("STRING1", elementPath);624 return mes;625 } catch (WebDriverException exception) {626 return parseWebDriverException(exception);627 }628 } else if (execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_FAT)) {629 if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {630 return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), identifier.getLocator(), "");631 } else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {632 return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), "", identifier.getLocator());633 } else {634 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION_AND_IDENTIFIER);635 mes.resolveDescription("IDENTIFIER", identifier.getIdentifier());636 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTNOTPRESENT);637 mes.resolveDescription("APPLICATIONTYPE", execution.getAppTypeEngine());638 return mes;639 }640 } else if (execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_SRV)) {641 if (execution.getLastServiceCalled() != null) {642 String responseBody = execution.getLastServiceCalled().getResponseHTTPBody();643 switch (execution.getLastServiceCalled().getResponseHTTPBodyContentType()) {644 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:645 if (!(xmlUnitService.isElementPresent(responseBody, elementPath))) {646 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);647 } else {648 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);649 }650 mes.resolveDescription("STRING1", elementPath);651 return mes;652 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {653 try {654 //Return of getFromJson can be "[]" in case when the path has this pattern "$..ex" and no elements found. Two dots after $ return a list.655 if (!jsonService.getFromJson(responseBody, null, elementPath).equals("[]")) {656 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);657 mes.resolveDescription("STRING1", elementPath);658 return mes;659 } else {660 throw new PathNotFoundException();661 }662 } catch (PathNotFoundException ex) {663 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);664 mes.resolveDescription("STRING1", elementPath);665 return mes;666 } catch (Exception ex) {667 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);668 mes.resolveDescription("ERROR", ex.toString());669 return mes;670 }671 }672 default:673 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);674 mes.resolveDescription("TYPE", execution.getLastServiceCalled().getResponseHTTPBodyContentType());675 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTNOTPRESENT);676 return mes;677 }678 } else {679 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);680 return mes;681 }682 } else {683 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);684 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTNOTPRESENT);685 mes.resolveDescription("APPLICATIONTYPE", execution.getAppTypeEngine());686 return mes;687 }688 } else {689 return new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT_NULL);690 }691 }692 private MessageEvent verifyElementInElement(TestCaseExecution tCExecution, String element, String childElement) {693 LOG.debug("Control: verifyElementInElement on: '{}' is child of '{}'", element, childElement);694 MessageEvent mes;695 if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)696 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)) {697 if (!StringUtil.isNull(element) && !StringUtil.isNull(childElement)) {698 try {699 Identifier identifier = identifierService.convertStringToIdentifier(element);700 Identifier childIdentifier = identifierService.convertStringToIdentifier(childElement);701 if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {702 if (this.webdriverService.isElementInElement(tCExecution.getSession(), identifier, childIdentifier)) {703 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTINELEMENT);704 } else {705 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTINELEMENT);706 }707 mes.resolveDescription("STRING2", element);708 mes.resolveDescription("STRING1", childElement);709 } else {710 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NO_SUCH_ELEMENT);711 mes.resolveDescription("SELEX", new NoSuchElementException("").toString());712 mes.resolveDescription("ELEMENT", element);713 }714 } catch (WebDriverException exception) {715 return parseWebDriverException(exception);716 }717 } else {718 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTINELEMENT);719 mes.resolveDescription("STRING2", element);720 mes.resolveDescription("STRING1", childElement);721 }722 } else {723 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);724 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTINELEMENT);725 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());726 }727 return mes;728 }729 private MessageEvent verifyElementVisible(TestCaseExecution tCExecution, String html) {730 LOG.debug("Control: verifyElementVisible on: {}", html);731 MessageEvent mes;732 if (!StringUtil.isNull(html)) {733 if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)734 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)735 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_IPA)) {736 try {737 Identifier identifier = identifierService.convertStringToIdentifier(html);738 if (this.webdriverService.isElementVisible(tCExecution.getSession(), identifier)) {739 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_VISIBLE);740 } else {741 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VISIBLE);742 }743 mes.resolveDescription("STRING1", html);744 } catch (WebDriverException exception) {745 return parseWebDriverException(exception);746 }747 } else {748 mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);749 mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTVISIBLE);750 mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());751 }752 } else {753 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VISIBLE_NULL);754 }755 return mes;756 }757 private MessageEvent verifyElementNotVisible(TestCaseExecution tCExecution, String html) {758 LOG.debug("Control: verifyElementNotVisible on: {}", html);759 MessageEvent mes;760 if (!StringUtil.isNull(html)) {761 if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)762 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)763 || tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_IPA)) {764 try {765 Identifier identifier = identifierService.convertStringToIdentifier(html);766 if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {767 if (this.webdriverService.isElementNotVisible(tCExecution.getSession(), identifier)) {768 mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTVISIBLE);769 } else {770 mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTVISIBLE);771 }772 mes.resolveDescription("STRING1", html);...

Full Screen

Full Screen

Source:ControlServiceTest.java Github

copy

Full Screen

...671// identifier.setIdentifier("id");672// identifier.setLocator("test");673//674// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();675// tcsace.setControl("verifyElementNotVisible");676// tcsace.setValue1(property);677// tcsace.setValue2(value);678// tcsace.setFatal("Y");679// TestCaseStepExecution tcse = new TestCaseStepExecution();680// tcse.settCExecution(tCExecution);681// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();682// tcsae.setTestCaseStepExecution(tcse);683// tcsace.setTestCaseStepActionExecution(tcsae);684//685// when(webdriverService.isElementPresent(session, identifier)).thenReturn(true);686// when(webdriverService.isElementNotVisible(session, identifier)).thenReturn(true);687//688// this.controlService.doControl(tcsace);689//690// Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());691// Assert.assertEquals("OK", tcsace.getReturnCode());692// }693//694// @Ignore695// @Test696// public void testDoControlElementNotVisibleWhenFail() {697// String property = "id=test";698// String value = "null";699// String msg = "Element '" + property + "' is visible on the page.";700// Identifier identifier = new Identifier();701// identifier.setIdentifier("id");702// identifier.setLocator("test");703//704// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();705// tcsace.setControl("verifyElementNotVisible");706// tcsace.setValue1(property);707// tcsace.setValue2(value);708// tcsace.setFatal("Y");709// TestCaseStepExecution tcse = new TestCaseStepExecution();710// tcse.settCExecution(tCExecution);711// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();712// tcsae.setTestCaseStepExecution(tcse);713// tcsace.setTestCaseStepActionExecution(tcsae);714//715// when(webdriverService.isElementPresent(session, identifier)).thenReturn(true);716// when(webdriverService.isElementNotVisible(session, identifier)).thenReturn(false);717//718// this.controlService.doControl(tcsace);719//720// Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());721// Assert.assertEquals("KO", tcsace.getReturnCode());722// Assert.assertEquals("Y", tcsace.getFatal());723// }724 @Test725 public void testDoControlElementNotVisibleWhenPropertyNull() {726 String property = "null";727 String value = "id=test";728 String msg = "Object is 'null'. This is mandatory in order to perform the control verify element not visible";729 TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();730 tcsace.setControl("verifyElementNotVisible");731 tcsace.setValue1(property);732 tcsace.setValue2(value);733 tcsace.setFatal("Y");734 TestCaseStepExecution tcse = new TestCaseStepExecution();735 tcse.settCExecution(tCExecution);736 TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();737 tcsae.setTestCaseStepExecution(tcse);738 tcsace.setTestCaseStepActionExecution(tcsae);739 this.controlService.doControl(tcsace);740 Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());741 Assert.assertEquals("KO", tcsace.getReturnCode());742 Assert.assertEquals("Y", tcsace.getFatal());743 }744// @Ignore745// @Test746// public void testDoControlElementNotVisibleWhenWebDriverException() {747// String property = "id=test";748// String value = "null";749// String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*";750// Identifier identifier = new Identifier();751// identifier.setIdentifier("id");752// identifier.setLocator("test");753//754// TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();755// tcsace.setControl("verifyElementNotVisible");756// tcsace.setValue1(property);757// tcsace.setValue2(value);758// tcsace.setFatal("Y");759// TestCaseStepExecution tcse = new TestCaseStepExecution();760// tcse.settCExecution(tCExecution);761// TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();762// tcsae.setTestCaseStepExecution(tcse);763// tcsace.setTestCaseStepActionExecution(tcsae);764//765// when(webdriverService.isElementPresent(session, identifier)).thenThrow(new WebDriverException());766//767// this.controlService.doControl(tcsace);768//769// Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg));...

Full Screen

Full Screen

verifyElementNotVisible

Using AI Code Generation

copy

Full Screen

1package com.cerberus.test;2import org.cerberus.engine.gwt.impl.ControlService;3import org.cerberus.engine.gwt.impl.PageService;4import org.cerberus.engine.gwt.impl.SeleniumService;5import org.cerberus.engine.gwt.impl.WebService;6import org.cerberus.engine.gwt.impl.WebServiceFactory;7import org.cerberus.engine.gwt.shared.IControlService;8import org.cerberus.engine.gwt.shared.IPageService;9import org.cerberus.engine.gwt.shared.ISeleniumService;10import org.cerberus.engine.gwt.shared.IWebService;11import org.cerberus.engine.gwt.shared.IWebServiceFactory;12import org.cerberus.engine.gwt.shared.exception.CerberusException;13import org.cerberus.engine.gwt.shared.exception.CerberusExceptionFactory;14import org.cerberus.engine.gwt.shared.exception.CerberusExceptionFactoryImpl;15import org.cerberus.engine.gwt.shared.exception.CerberusExceptionType;16import org.cerberus.engine.gwt.shared.exception.CerberusExceptionTypeImpl;17import org.cerberus.engine.gwt.shared.exception.CerberusFatalException;18import org.cerberus.engine.gwt.shared.exception.CerberusFatalExceptionFactory;19import org.cerberus.engine.gwt.shared.exception.CerberusFatalExceptionFactoryImpl;20import org.cerberus.engine.gwt.shared.exception.CerberusFatalExceptionType;21import org.cerberus.engine.gwt.shared.exception.CerberusFatalExceptionTypeImpl;22import org.cerberus.engine.gwt.shared.exception.CerberusRuntimeException;23import org.cerberus.engine.gwt.shared.exception.CerberusRuntimeExceptionFactory;24import org.cerberus.engine.gwt.shared.exception.CerberusRuntimeExceptionFactoryImpl;25import org.cerberus.engine.gwt.shared.exception.CerberusRuntimeExceptionType;26import org.cerberus.engine.gwt.shared.exception.CerberusRuntimeExceptionTypeImpl;27import org.cerberus.engine.gwt.shared.exception.CerberusTestException;28import org.cerberus.engine.gwt.shared.exception.CerberusTestExceptionFactory;29import org.cerberus.engine.gwt.shared.exception.CerberusTestExceptionFactoryImpl;30import org.cerberus.engine.gwt.shared.exception.CerberusTestExceptionType;31import org.cerberus.engine.gwt.shared.exception.CerberusTestExceptionTypeImpl;32import org.cerberus.engine.gwt.shared.exception.C

Full Screen

Full Screen

verifyElementNotVisible

Using AI Code Generation

copy

Full Screen

1package org.cerberus.samples;2import org.cerberus.engine.gwt.impl.ControlService;3import org.cerberus.engine.gwt.impl.PageService;4public class VerifyElementNotVisible {5 public static void main(String[] args) {6 PageService pageService = new PageService();7 ControlService controlService = new ControlService();8 System.out.println(controlService.verifyElementNotVisible("q"));9 }10}11package org.cerberus.samples;12import org.cerberus.engine.gwt.impl.ControlService;13import org.cerberus.engine.gwt.impl.PageService;14public class VerifyElementNotVisible {15 public static void main(String[] args) {16 PageService pageService = new PageService();17 ControlService controlService = new ControlService();18 System.out.println(controlService.verifyElementNotVisible("q"));19 }20}21package org.cerberus.samples;22import org.cerberus.engine.gwt.impl.ControlService;23import org.cerberus.engine.gwt.impl.PageService;24public class VerifyElementNotVisible {25 public static void main(String[] args) {26 PageService pageService = new PageService();27 ControlService controlService = new ControlService();28 System.out.println(controlService.verifyElementNotVisible("q"));29 }30}31package org.cerberus.samples;32import org.cerberus.engine.gwt.impl.ControlService;33import org.cerberus.engine.gwt.impl.PageService;34public class VerifyElementNotVisible {35 public static void main(String[] args) {36 PageService pageService = new PageService();37 ControlService controlService = new ControlService();38 System.out.println(controlService.verifyElementNotVisible("q"));39 }40}

Full Screen

Full Screen

verifyElementNotVisible

Using AI Code Generation

copy

Full Screen

1package com.cerberus.test;2import org.cerberus.engine.gwt.impl.ControlService;3import org.cerberus.engine.gwt.impl.WebPage;4import org.cerberus.engine.gwt.impl.WebPageService;5import org.cerberus.exception.CerberusException;6import org.cerberus.util.CerberusProperties;7import org.cerberus.util.CerberusProperties.CerberusProperty;8import org.cerberus.util.CerberusUtil;9import org.cerberus.util.StringUtil;10import org.openqa.selenium.WebDriver;11import org.openqa.selenium.firefox.FirefoxDriver;12public class 3 {13 public static void main(String[] args) throws CerberusException {14 CerberusUtil.setCerberusProperty(CerberusProperty.WEBDRIVER_FIREFOX_BINARY, "C:\\Users\\Rajesh\\AppData\\Local\\Mozilla Firefox\\firefox.exe");15 CerberusUtil.setCerberusProperty(CerberusProperty.WEBDRIVER_FIREFOX_DRIVER, "C:\\Users\\Rajesh\\workspace\\Cerberus\\src\\test\\resources\\geckodriver.exe");16 CerberusUtil.setCerberusProperty(CerberusProperty.WEBDRIVER_CHROME_DRIVER, "C:\\Users\\Rajesh\\workspace\\Cerberus\\src\\test\\resources\\chromedriver.exe");17 CerberusUtil.setCerberusProperty(CerberusProperty.WEBDRIVER_IE_DRIVER, "C:\\Users\\Rajesh\\workspace\\Cerberus\\src\\test\\resources\\IEDriverServer.exe");18 CerberusUtil.setCerberusProperty(CerberusProperty.WEBDRIVER_PHANTOMJS_BINARY, "C:\\Users\\Rajesh\\workspace\\Cerberus\\src\\test\\resources\\phantomjs.exe");19 CerberusUtil.setCerberusProperty(CerberusProperty.WEBDRIVER_CHROME_BINARY, "C:\\Users\\Rajesh\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");20 CerberusUtil.setCerberusProperty(CerberusProperty.WEBDRIVER_IE_BINARY, "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe");

Full Screen

Full Screen

verifyElementNotVisible

Using AI Code Generation

copy

Full Screen

1package com.cerberus.test;2import org.cerberus.engine.gwt.impl.ControlService;3import org.cerberus.engine.gwt.impl.ControlServiceFactory;4public class Test {5 public static void main(String[] args) {6 ControlService controlService = ControlServiceFactory.getControlService();7 controlService.verifyElementNotVisible("id=123", "test");8 }9}10package com.cerberus.test;11import org.cerberus.engine.gwt.impl.ControlService;12import org.cerberus.engine.gwt.impl.ControlServiceFactory;13public class Test {14 public static void main(String[] args) {15 ControlService controlService = ControlServiceFactory.getControlService();16 controlService.verifyElementPresent("id=123", "test");17 }18}19package com.cerberus.test;20import org.cerberus.engine.gwt.impl.ControlService;21import org.cerberus.engine.gwt.impl.ControlServiceFactory;22public class Test {23 public static void main(String[] args) {24 ControlService controlService = ControlServiceFactory.getControlService();25 controlService.verifyElementVisible("id=123", "test");26 }27}28package com.cerberus.test;29import org.cerberus.engine.gwt.impl.ControlService;30import org.cerberus.engine.gwt.impl.ControlServiceFactory;31public class Test {32 public static void main(String[] args) {33 ControlService controlService = ControlServiceFactory.getControlService();34 controlService.verifyElementNotPresent("id=123", "test");35 }36}37package com.cerberus.test;38import org.cerberus.engine.gwt.impl.ControlService;39import org.cerberus.engine.gwt.impl.ControlServiceFactory;40public class Test {41 public static void main(String[] args) {42 ControlService controlService = ControlServiceFactory.getControlService();43 controlService.verifyElementNotVisible("id=123", "test

Full Screen

Full Screen

verifyElementNotVisible

Using AI Code Generation

copy

Full Screen

1package org.cerberus.sandbox;2import org.cerberus.engine.gwt.impl.ControlService;3import org.cerberus.engine.gwt.impl.PageService;4import org.cerberus.engine.gwt.impl.SeleniumService;5import org.cerberus.event.IEvent;6import org.cerberus.exception.CerberusException;7import org.cerberus.launch.CerberusInstance;8import org.cerberus.launch.IApplication;9import org.cerberus.utils.CerberusProperties;10public class 3 {11 public static void main(String[] args) throws CerberusException {12 IApplication app = CerberusInstance.getInstance();13 app.init(CerberusProperties.getInstance());14 app.start();15 IEvent e = app.getEvent();16 SeleniumService ss = new SeleniumService();17 ss.init(e);18 PageService ps = new PageService();19 ps.init(e);20 ControlService cs = new ControlService();21 cs.init(e);22 ps.waitUntilPageLoad();23 app.stop();24 }25}

Full Screen

Full Screen

verifyElementNotVisible

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.gwt.impl.ControlService;2import org.cerberus.testing.Test;3import org.cerberus.testing.TestRunner;4import org.cerberus.testing.TestRunnerFactory;5import org.cerberus.testing.TestRunnerFactory.TestRunnerType;6public class 3 {7 public static void main(String[] args) {8 TestRunner runner = TestRunnerFactory.getTestRunner(TestRunnerType.GUI);9 Test test = new Test();10 test.setTestName("3");11 test.setTestDescription("test");12 ControlService controlService = new ControlService();13 controlService.verifyElementNotVisible("id=123", 30);14 }15}16import org.cerberus.engine.gwt.impl.ControlService;17import org.cerberus.testing.Test;18import org.cerberus.testing.TestRunner;19import org.cerberus.testing.TestRunnerFactory;20import org.cerberus.testing.TestRunnerFactory.TestRunnerType;21public class 4 {22 public static void main(String[] args) {23 TestRunner runner = TestRunnerFactory.getTestRunner(TestRunnerType.GUI);24 Test test = new Test();25 test.setTestName("4");26 test.setTestDescription("test");27 ControlService controlService = new ControlService();28 controlService.verifyElementNotVisible("name=123", 30);29 }30}

Full Screen

Full Screen

verifyElementNotVisible

Using AI Code Generation

copy

Full Screen

1package org.cerberus.engine.gwt.impl;2import com.google.gwt.user.client.ui.Widget;3public class ControlService extends org.cerberus.engine.gwt.ControlService {4 public ControlService() {5 }6 public boolean verifyElementNotVisible(Widget widget) {7 return !widget.isVisible();8 }9}10package org.cerberus.engine.gwt.impl;11import com.google.gwt.user.client.ui.Widget;12public class ControlService extends org.cerberus.engine.gwt.ControlService {13 public ControlService() {14 }15 public boolean verifyElementNotVisible(Widget widget) {16 return !widget.isVisible();17 }18}

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