Skip to content

Commit

Permalink
Condition isElementVisible : Current behavior return false if element…
Browse files Browse the repository at this point in the history
… not present. New behavior is to allow to choose if element must be present or not
  • Loading branch information
bcivel committed Jan 16, 2025
1 parent cdf6f7a commit 55619a0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum ConditionOperatorEnum {
CONDITIONOPERATOR_IFELEMENTNOTPRESENT("ifElementNotPresent", true),
CONDITIONOPERATOR_IFELEMENTVISIBLE("ifElementVisible", true),
CONDITIONOPERATOR_IFELEMENTNOTVISIBLE("ifElementNotVisible", true),
CONDITIONOPERATOR_IFELEMENTNOTPRESENTANDNOTVISIBLE("ifElementNotPresentAndNotVisible", true),
CONDITIONOPERATOR_IFPROPERTYEXIST("ifPropertyExist", false),
CONDITIONOPERATOR_IFPROPERTYNOTEXIST("ifPropertyNotExist", false),
CONDITIONOPERATOR_IFNUMERICEQUAL("ifNumericEqual", false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public AnswerItem<Boolean> evaluateCondition(String conditionOperator, String co
break;

case CONDITIONOPERATOR_IFELEMENTNOTVISIBLE:
ans = evaluateCondition_ifElementNotVisible(conditionToEvaluate.getCondition(), conditionValue1, execution);
ans = evaluateCondition_ifElementNotVisible(conditionToEvaluate.getCondition(), conditionValue1, conditionValue2, execution);
mes = ans.getResultMessage();
break;

Expand Down Expand Up @@ -783,7 +783,7 @@ private AnswerItem<Boolean> evaluateCondition_ifElementVisible(String conditionO
return ans;
}

private AnswerItem<Boolean> evaluateCondition_ifElementNotVisible(String conditionOperator, String conditionValue1, TestCaseExecution tCExecution) {
private AnswerItem<Boolean> evaluateCondition_ifElementNotVisible(String conditionOperator, String conditionValue1, String conditionValue2, TestCaseExecution tCExecution) {
LOG.debug("Checking if Element is Not Visible");
AnswerItem<Boolean> ans = new AnswerItem<>();
MessageEvent mes;
Expand All @@ -800,7 +800,9 @@ private AnswerItem<Boolean> evaluateCondition_ifElementNotVisible(String conditi

try {
Identifier identifier = identifierService.convertStringToIdentifier(conditionValue1);
if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {
boolean elementMustBePresent = ParameterParserUtil.parseBooleanParam(conditionValue2, true);

if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)==elementMustBePresent) {
if (this.webdriverService.isElementNotVisible(tCExecution.getSession(), identifier)) {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTNOTVISIBLE);
mes.setDescription(mes.getDescription().replace("%STRING1%", conditionValue1));
Expand All @@ -811,7 +813,7 @@ private AnswerItem<Boolean> evaluateCondition_ifElementNotVisible(String conditi

}
} else {
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTNOTVISIBLE);
mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTNOTVISIBLEELEMENTPRESENT);
mes.setDescription(mes.getDescription().replace("%STRING1%", conditionValue1));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ public enum MessageEventEnum {
CONDITIONEVAL_FALSE_IFELEMENTNOTPRESENT(1240, "NA", "Element %ELEMENT% present.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
CONDITIONEVAL_FALSE_IFELEMENTVISIBLE(1240, "NA", "Element %STRING1% not visible.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
CONDITIONEVAL_FALSE_IFELEMENTNOTVISIBLE(1240, "NA", "Element %STRING1% visible.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
CONDITIONEVAL_FALSE_IFELEMENTNOTVISIBLEELEMENTPRESENT(1240, "NA", "Didn't evaluate if Element %STRING1% was visible or not because presence of element not in the expected status (default behavior expect element to be present in the DOM).", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
CONDITIONEVAL_FALSE_STRINGEQUAL(1210, "NA", "'%STR1%' is not equal to '%STR2%', %STRING3%", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
CONDITIONEVAL_FALSE_STRINGDIFFERENT(1210, "NA", "'%STR1%' is not different from '%STR2%', %STRING3%", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
CONDITIONEVAL_FALSE_STRINGGREATER(1210, "NA", "'%STR1%' is not greater than '%STR2%'", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ <h5 class="modal-title">Options</h5>
<label class="conditionVal4Label">actionconditionval4</label>
<select class="form-control input-sm" id="actionconditionval4"></select>
</div>
<div class="col-lg-6 form-group v5">
<label class="conditionVal5Label">actionconditionval5</label>
<input class="form-control input-sm" id="actionconditionval5" name="actionconditionval5" type="checkbox">
</div>
</div>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions source/src/main/webapp/js/testcase/condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ function setPlaceholderCondition(conditionElement) {
$(conditionElement).parents("div[class*='conditions']").find(".v4").hide();
}

if (typeof placeHolders.field5 !== 'undefined') {
$(conditionElement).parents("div[class*='conditions']").find("label[class='conditionVal5Label']").parent().show();
$(conditionElement).parents("div[class*='conditions']").find("label[class='conditionVal5Label']").text(placeHolders.field5.label[user.language]);

} else {
$(conditionElement).parents("div[class*='conditions']").find(".v5").hide();
}

}

function displayOverrideOptionsModal(action, htmlElement) {
Expand Down Expand Up @@ -137,6 +145,10 @@ function displayOverrideOptionsModal(action, htmlElement) {
$("#actionconditionval4").val(action.conditionValue1+"-"+action.conditionValue2+"-"+action.conditionValue3);
}
}
if (conditionNewUIList[action.conditionOperator].field5 != undefined) {
let checked = action.conditionValue2=="false"?false:true;
$("#actionconditionval5").prop("checked", checked);
}


$("#conditionSelect").off("change");
Expand Down Expand Up @@ -272,6 +284,10 @@ function displayOverrideOptionsModal(action, htmlElement) {
action.conditionValue2 = $("#actionconditionval4 option:selected").attr("actionId") === undefined ? "":$("#actionconditionval4 option:selected").attr("actionId");
action.conditionValue3 = $("#actionconditionval4 option:selected").attr("controlId")=== undefined ? "":$("#actionconditionval4 option:selected").attr("controlId");
}
console.log(conditionNewUIList[action.conditionOperator].field5);
if (conditionNewUIList[action.conditionOperator].field5 != undefined) {
action.conditionValue2 = $("#actionconditionval5").is(':checked').toString();
}

let newOpts = [];
newOpts.push({
Expand Down
3 changes: 2 additions & 1 deletion source/src/main/webapp/js/testcase/testcaseStatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,8 @@ var conditionNewUIList = {
"ifElementVisible":{"value":"ifElementVisible","label":{"en":"If Element Visible","fr":"Si l'élément est visible'"},
"field1":{"label":{"en": "Element Path", "fr": "Chemin de l'élément"},"class": "crb-autocomplete-element crb-contextual-button"}},
"ifElementNotVisible":{"value":"ifElementNotVisible","label":{"en":"If Element not Visible","fr":"Si l'élément n'est pas visible"},
"field1":{"label":{"en": "Element Path", "fr": "Chemin de l'élément"},"class": "crb-autocomplete-element crb-contextual-button"}},
"field1":{"label":{"en": "Element Path", "fr": "Chemin de l'élément"},"class": "crb-autocomplete-element crb-contextual-button"},
"field5":{"label":{"en": "true/false : Element must be present? Default : true", "fr": "true/false : L'élément doit-il être present? Par défault : true"},"class": "crb-autocomplete-variable"}},
"ifTextInElement":{"value":"ifTextInElement","label":{"en":"If Text in Element","fr":"Si l'élément contient le texte"},
"field1":{"label":{"en": "Element Path", "fr": "Chemin de l'élément"},"class": "crb-autocomplete-element crb-contextual-button"},
"field2":{"label":{"en": "Text", "fr": "Texte"},"class": "crb-autocomplete-variable"}},
Expand Down

0 comments on commit 55619a0

Please sign in to comment.