diff --git a/source/src/main/java/org/cerberus/crud/entity/TestCaseStepActionControl.java b/source/src/main/java/org/cerberus/crud/entity/TestCaseStepActionControl.java index 29f640dfe8..cfbe6724d0 100644 --- a/source/src/main/java/org/cerberus/crud/entity/TestCaseStepActionControl.java +++ b/source/src/main/java/org/cerberus/crud/entity/TestCaseStepActionControl.java @@ -86,6 +86,7 @@ public class TestCaseStepActionControl { public static final String CONTROL_VERIFYELEMENTNOTCLICKABLE = "verifyElementNotClickable"; public static final String CONTROL_VERIFYELEMENTTEXTEQUAL = "verifyElementTextEqual"; public static final String CONTROL_VERIFYELEMENTTEXTDIFFERENT = "verifyElementTextDifferent"; + public static final String CONTROL_VERIFYELEMENTTEXTCONTAINS = "verifyElementTextContains"; public static final String CONTROL_VERIFYELEMENTTEXTMATCHREGEX = "verifyElementTextMatchRegex"; public static final String CONTROL_VERIFYELEMENTNUMERICEQUAL = "verifyElementNumericEqual"; public static final String CONTROL_VERIFYELEMENTNUMERICDIFFERENT = "verifyElementNumericDifferent"; diff --git a/source/src/main/java/org/cerberus/engine/gwt/impl/ControlService.java b/source/src/main/java/org/cerberus/engine/gwt/impl/ControlService.java index 70473929c2..91dfeb72bf 100644 --- a/source/src/main/java/org/cerberus/engine/gwt/impl/ControlService.java +++ b/source/src/main/java/org/cerberus/engine/gwt/impl/ControlService.java @@ -303,6 +303,9 @@ public TestCaseStepActionControlExecution doControl(TestCaseStepActionControlExe case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTDIFFERENT: res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTDIFFERENT, tCExecution, testCaseStepActionControlExecution.getValue1(), testCaseStepActionControlExecution.getValue2(), testCaseStepActionControlExecution.getValue3()); break; + case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTCONTAINS: + res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTCONTAINS, tCExecution, testCaseStepActionControlExecution.getValue1(), testCaseStepActionControlExecution.getValue2(), testCaseStepActionControlExecution.getValue3()); + break; case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICEQUAL: res = this.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICEQUAL, tCExecution, testCaseStepActionControlExecution.getValue1(), testCaseStepActionControlExecution.getValue2(), testCaseStepActionControlExecution.getValue3()); break; @@ -1109,6 +1112,9 @@ private MessageEvent switchControl(String control, String path, String actual, S case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTDIFFERENT: mes = verifyElementTextDifferentCaseSensitiveCheck(actual, expected, isCaseSensitive); break; + case TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTCONTAINS: + mes = verifyElementTextContainsCaseSensitiveCheck(actual, expected, isCaseSensitive); + break; case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICEQUAL: case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICDIFFERENT: case TestCaseStepActionControl.CONTROL_VERIFYELEMENTNUMERICGREATER: @@ -1163,6 +1169,16 @@ private MessageEvent verifyElementTextDifferentCaseSensitiveCheck(String actual, return mes; } + private MessageEvent verifyElementTextContainsCaseSensitiveCheck(String text, String textToSearch, String isCaseSensitive) { + MessageEvent mes; + if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false)) { + mes = text.contains(textToSearch) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTTEXTCONTAINS) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_CONTAINS); + } else { + mes = text.toLowerCase().contains(textToSearch.toLowerCase()) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTTEXTCONTAINS) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_CONTAINS); + } + return mes; + } + private MessageEvent checkNumericVerifyElement(String control, Double actual, Double expected) { MessageEvent mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION); mes.setDescription(mes.getDescription().replace("%CONTROL%", "checkNumericVerifyElement-" + control)); diff --git a/source/src/main/java/org/cerberus/enums/MessageEventEnum.java b/source/src/main/java/org/cerberus/enums/MessageEventEnum.java index c2a2e5ca99..f844c63256 100644 --- a/source/src/main/java/org/cerberus/enums/MessageEventEnum.java +++ b/source/src/main/java/org/cerberus/enums/MessageEventEnum.java @@ -367,6 +367,7 @@ public enum MessageEventEnum { CONTROL_SUCCESS_NOTVISIBLE(300, "OK", "Element '%STRING1%' is present and not visible on the page.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONTROL_SUCCESS_ELEMENTTEXTEQUAL(300, "OK", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' is equal to %VALUE% (%CASESENSITIVE%).", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONTROL_SUCCESS_ELEMENTTEXTDIFFERENT(300, "OK", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' is different than %VALUE% (%CASESENSITIVE%).", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONTROL_SUCCESS_ELEMENTTEXTCONTAINS(300, "OK", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' contains %VALUE% (%CASESENSITIVE%).", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONTROL_SUCCESS_ELEMENTNUMERICEQUAL(300, "OK", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' is equal than %VALUE%.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONTROL_SUCCESS_ELEMENTNUMERICDIFFERENT(300, "OK", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' is different than %VALUE%.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONTROL_SUCCESS_ELEMENTNUMERICGREATER(300, "OK", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' is greater than %VALUE%.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), @@ -414,6 +415,7 @@ public enum MessageEventEnum { CONTROL_FAILED_ELEMENTTEXTDIFFERENT(367, "KO", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' is not different than %VALUE% (%CASESENSITIVE%).", true, true, true, MessageGeneralEnum.EXECUTION_KO), CONTROL_FAILED_ELEMENTNUMERICEQUAL(367, "KO", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' is not equal to %VALUE%.", true, true, true, MessageGeneralEnum.EXECUTION_KO), CONTROL_FAILED_ELEMENTNUMERICDIFFERENT(367, "KO", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' is not different than %VALUE%.", true, true, true, MessageGeneralEnum.EXECUTION_KO), + CONTROL_FAILED_ELEMENTTEXTCONTAINS(367, "KO", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' does not contain %VALUE% (%CASESENSITIVE%).", true, true, true, MessageGeneralEnum.EXECUTION_KO), CONTROL_FAILED_ELEMENTNUMERICGREATER(367, "KO", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' is not greater than %VALUE%.", true, true, true, MessageGeneralEnum.EXECUTION_KO), CONTROL_FAILED_ELEMENTNUMERICGREATEROREQUAL(367, "KO", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' is not greater or equal to %VALUE%.", true, true, true, MessageGeneralEnum.EXECUTION_KO), CONTROL_FAILED_ELEMENTNUMERICMINOR(367, "KO", "Element '%ELEMENT%' with value '%ELEMENTVALUE%' is not lower than %VALUE%.", true, true, true, MessageGeneralEnum.EXECUTION_KO), diff --git a/source/src/main/resources/database.sql b/source/src/main/resources/database.sql index d52dd3f786..e95f64b5f7 100644 --- a/source/src/main/resources/database.sql +++ b/source/src/main/resources/database.sql @@ -6009,3 +6009,6 @@ UPDATE `invariant` SET `gp1` = 'Element', `gp2` = '', `gp3` = '' WHERE idname = INSERT INTO `parameter` (`system`, `param`, `value`, `description`) VALUES ('', 'cerberus_executionlog_enable', 'true','Enable (true) or disable (false) the execution json log messages inside application server logs. If false, no json log messages will never be logged. If true, json message will be logged only if verbose level is at the correct level.'); +--1690 +INSERT INTO `invariant` (idname, value, sort, description) + VALUES ('CONTROL', 'verifyElementTextContains', 4200, 'verifyElementTextContains'); \ No newline at end of file