How to use evaluateCondition_ifElementPresent method of org.cerberus.engine.execution.impl.ConditionService class

Best Cerberus-source code snippet using org.cerberus.engine.execution.impl.ConditionService.evaluateCondition_ifElementPresent

Source:ConditionService.java Github

copy

Full Screen

...77 case "": // In case condition is not defined, it is considered as always.78 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_ALWAYS);79 break;80 case TestCaseStepAction.CONDITIONOPER_IFELEMENTPRESENT:81 ans = evaluateCondition_ifElementPresent(conditionOper, conditionValue1, tCExecution);82 mes = ans.getResultMessage();83 break;84 case TestCaseStepAction.CONDITIONOPER_IFPROPERTYEXIST:85 ans = evaluateCondition_ifPropertyExist(conditionOper, conditionValue1, tCExecution);86 mes = ans.getResultMessage();87 break;88 case TestCaseStepAction.CONDITIONOPER_IFNUMERICEQUAL:89 case TestCaseStepAction.CONDITIONOPER_IFNUMERICDIFFERENT:90 case TestCaseStepAction.CONDITIONOPER_IFNUMERICGREATER:91 case TestCaseStepAction.CONDITIONOPER_IFNUMERICGREATEROREQUAL:92 case TestCaseStepAction.CONDITIONOPER_IFNUMERICMINOR:93 case TestCaseStepAction.CONDITIONOPER_IFNUMERICMINOROREQUAL:94 ans = evaluateCondition_ifNumericXXX(conditionOper, conditionValue1, conditionValue2);95 mes = ans.getResultMessage();96 break;97 case TestCaseStepAction.CONDITIONOPER_IFSTRINGEQUAL:98 ans = evaluateCondition_ifStringEqual(conditionOper, conditionValue1, conditionValue2);99 mes = ans.getResultMessage();100 break;101 case TestCaseStepAction.CONDITIONOPER_IFSTRINGDIFFERENT:102 ans = evaluateCondition_ifStringDifferent(conditionOper, conditionValue1, conditionValue2);103 mes = ans.getResultMessage();104 break;105 case TestCaseStepAction.CONDITIONOPER_IFSTRINGGREATER:106 ans = evaluateCondition_ifStringGreater(conditionOper, conditionValue1, conditionValue2);107 mes = ans.getResultMessage();108 break;109 case TestCaseStepAction.CONDITIONOPER_IFSTRINGMINOR:110 ans = evaluateCondition_ifStringMinor(conditionOper, conditionValue1, conditionValue2);111 mes = ans.getResultMessage();112 break;113 case TestCaseStepAction.CONDITIONOPER_IFSTRINGCONTAINS:114 ans = evaluateCondition_ifStringContains(conditionOper, conditionValue1, conditionValue2);115 mes = ans.getResultMessage();116 break;117 case TestCaseStepAction.CONDITIONOPER_NEVER:118 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_NEVER);119 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));120 break;121 default:122 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_UNKNOWNCONDITION);123 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));124 }125 LOG.debug("Finished Evaluation condition : " + mes.getCodeString());126 // the decision whether we execute the action/control/step is taken from the codeString of the message.127 if (mes.getCodeString().equals("OK")) { // If code is OK, we execute the Operation.128 execute_Operation = true;129 } else { // Any other status and we don't execute anything.130 execute_Operation = false;131 }132 ans.setItem(execute_Operation);133 ans.setResultMessage(mes);134 return ans;135 }136 private AnswerItem<Boolean> evaluateCondition_ifPropertyExist(String conditionOper, String conditionValue1, TestCaseExecution tCExecution) {137 if (LOG.isDebugEnabled()) {138 LOG.debug("Checking if property Exist");139 }140 AnswerItem ans = new AnswerItem();141 MessageEvent mes;142 if (StringUtil.isNullOrEmpty(conditionValue1)) {143 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFPROPERTYEXIST_MISSINGPARAMETER);144 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));145 } else {146 String myCountry = tCExecution.getCountry();147 String myProperty = conditionValue1;148 boolean execute_Action = false;149 for (TestCaseCountryProperties prop : tCExecution.getTestCaseCountryPropertyList()) {150 LOG.debug(prop.getCountry() + " - " + myCountry + " - " + prop.getProperty() + " - " + myProperty);151 if ((prop.getCountry().equals(myCountry)) && (prop.getProperty().equals(myProperty))) {152 execute_Action = true;153 }154 }155 if (execute_Action == false) {156 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFPROPERTYEXIST);157 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));158 mes.setDescription(mes.getDescription().replace("%PROP%", conditionValue1));159 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));160 } else {161 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFPROPERTYEXIST);162 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));163 mes.setDescription(mes.getDescription().replace("%PROP%", conditionValue1));164 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));165 }166 }167 ans.setResultMessage(mes);168 return ans;169 }170 private AnswerItem<Boolean> evaluateCondition_ifElementPresent(String conditionOper, String conditionValue1, TestCaseExecution tCExecution) {171 if (LOG.isDebugEnabled()) {172 LOG.debug("Checking if Element Present");173 }174 AnswerItem ans = new AnswerItem();175 MessageEvent mes;176 if (StringUtil.isNullOrEmpty(conditionValue1)) {177 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFELEMENTPRESENT_MISSINGPARAMETER);178 mes.setDescription(mes.getDescription().replace("%COND%", conditionOper));179 } else {180 boolean condition_result = false;181 Identifier identifier = identifierService.convertStringToIdentifier(conditionValue1);182 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)183 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)184 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {...

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