Skip to content

Commit

Permalink
Fixed error message when filtering some pages with empty string.
Browse files Browse the repository at this point in the history
  • Loading branch information
vertigo17 committed Apr 19, 2024
1 parent 2f20b88 commit 9757314
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -976,25 +976,54 @@ private MessageEvent verifyElementInElement(TestCaseExecution tCExecution, Strin
return mes;
}

private MessageEvent verifyElementVisible(TestCaseExecution tCExecution, String html) {
LOG.debug("Control: verifyElementVisible on: {}", html);
private MessageEvent verifyElementVisible(TestCaseExecution tCExecution, String elementPath) {
LOG.debug("Control: verifyElementVisible on: {}", elementPath);
MessageEvent mes;
if (!StringUtil.isEmptyOrNullValue(html)) {
if (!StringUtil.isEmptyOrNullValue(elementPath)) {
if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)
|| tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)
|| tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_IPA)) {

try {
Identifier identifier = identifierService.convertStringToIdentifier(html);
if (this.webdriverService.isElementVisible(tCExecution.getSession(), identifier)) {
Identifier identifier = identifierService.convertStringToIdentifier(elementPath);
if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {
return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator(), "");

} else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {
return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), "", identifier.getLocator());

} else if (this.webdriverService.isElementVisible(tCExecution.getSession(), identifier)) {
mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_VISIBLE);
mes.resolveDescription("STRING1", elementPath);
return mes;

} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VISIBLE);
mes.resolveDescription("STRING1", elementPath);
return mes;
}
mes.resolveDescription("STRING1", html);
} catch (WebDriverException exception) {
return parseWebDriverException(exception);
}

} else if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_FAT)) {

Identifier identifier = identifierService.convertStringToIdentifier(elementPath);
if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {
return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator(), "");

} else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {
return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), "", identifier.getLocator());

} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION_AND_IDENTIFIER);
mes.resolveDescription("IDENTIFIER", identifier.getIdentifier());
mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTVISIBLE);
mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());
return mes;

}

} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTVISIBLE);
Expand All @@ -1006,34 +1035,61 @@ private MessageEvent verifyElementVisible(TestCaseExecution tCExecution, String
return mes;
}

private MessageEvent verifyElementNotVisible(TestCaseExecution tCExecution, String html) {
LOG.debug("Control: verifyElementNotVisible on: {}", html);
private MessageEvent verifyElementNotVisible(TestCaseExecution execution, String elementPath) {
LOG.debug("Control: verifyElementNotVisible on: {}", elementPath);
MessageEvent mes;
if (!StringUtil.isEmptyOrNullValue(html)) {
if (tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)
|| tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)
|| tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_IPA)) {
if (!StringUtil.isEmptyOrNullValue(elementPath)) {
if (execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)
|| execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_APK)
|| execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_IPA)) {

try {
Identifier identifier = identifierService.convertStringToIdentifier(html);
if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {
if (this.webdriverService.isElementNotVisible(tCExecution.getSession(), identifier)) {
Identifier identifier = identifierService.convertStringToIdentifier(elementPath);
if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {
return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), identifier.getLocator(), "");

} else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {
return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), "", identifier.getLocator());

} else if (this.webdriverService.isElementPresent(execution.getSession(), identifier)) {
if (this.webdriverService.isElementNotVisible(execution.getSession(), identifier)) {
mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTVISIBLE);
} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTVISIBLE);
}
mes.resolveDescription("STRING1", html);
mes.resolveDescription("STRING1", elementPath);

} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);
}
mes.resolveDescription("STRING1", html);
mes.resolveDescription("STRING1", elementPath);
return mes;
} catch (WebDriverException exception) {
return parseWebDriverException(exception);
}

} else if (execution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_FAT)) {

Identifier identifier = identifierService.convertStringToIdentifier(elementPath);
if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_PICTURE)) {
return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), identifier.getLocator(), "");

} else if (identifier.getIdentifier().equals(Identifier.IDENTIFIER_TEXT)) {
return sikuliService.doSikuliVerifyElementNotPresent(execution.getSession(), "", identifier.getLocator());

} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION_AND_IDENTIFIER);
mes.resolveDescription("IDENTIFIER", identifier.getIdentifier());
mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTNOTVISIBLE);
mes.resolveDescription("APPLICATIONTYPE", execution.getAppTypeEngine());
return mes;

}

} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
mes.resolveDescription("CONTROL", TestCaseStepActionControl.CONTROL_VERIFYELEMENTNOTVISIBLE);
mes.resolveDescription("APPLICATIONTYPE", tCExecution.getAppTypeEngine());
mes.resolveDescription("APPLICATIONTYPE", execution.getAppTypeEngine());
}
} else {
mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTVISIBLE_NULL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* SFTP support on call service Action.
* A Property length of 0 now will take all available rows of the data (whether it is csv, internal, sql or service related). All existing properties with lengths of 0 will be changed to 1 in order to secure the behavior is unchanged.
* Value1, 2 and 3 are no longer decoded when not used. (for ex, switching condition to 'always' or 'never' no longer force you to empty parameter values that could crash during decode) fix #2038
* controls on element visible are now aligned with element present when using image recognition feature.

*Warning to be considered before applying the version (deprecated features)*
[square]
Expand Down

0 comments on commit 9757314

Please sign in to comment.