Best Cerberus-source code snippet using org.cerberus.engine.execution.impl.ConditionService.evaluateCondition_ifElementVisible
Source:ConditionService.java
...102 ans = evaluateCondition_ifElementNotPresent(conditionToEvaluate.getCondition(), conditionValue1, tCExecution);103 mes = ans.getResultMessage();104 break;105 case CONDITIONOPERATOR_IFELEMENTVISIBLE:106 ans = evaluateCondition_ifElementVisible(conditionToEvaluate.getCondition(), conditionValue1, tCExecution);107 mes = ans.getResultMessage();108 break;109 case CONDITIONOPERATOR_IFELEMENTNOTVISIBLE:110 ans = evaluateCondition_ifElementNotVisible(conditionToEvaluate.getCondition(), conditionValue1, tCExecution);111 mes = ans.getResultMessage();112 break;113 case CONDITIONOPERATOR_IFPROPERTYEXIST:114 ans = evaluateCondition_ifPropertyExist(conditionToEvaluate.getCondition(), conditionValue1, tCExecution);115 mes = ans.getResultMessage();116 break;117 case CONDITIONOPERATOR_IFPROPERTYNOTEXIST:118 ans = evaluateCondition_ifPropertyNotExist(conditionToEvaluate.getCondition(), conditionValue1, tCExecution);119 mes = ans.getResultMessage();120 break;121 case CONDITIONOPERATOR_IFNUMERICEQUAL:122 case CONDITIONOPERATOR_IFNUMERICDIFFERENT:123 case CONDITIONOPERATOR_IFNUMERICGREATER:124 case CONDITIONOPERATOR_IFNUMERICGREATEROREQUAL:125 case CONDITIONOPERATOR_IFNUMERICMINOR:126 case CONDITIONOPERATOR_IFNUMERICMINOROREQUAL:127 ans = evaluateCondition_ifNumericXXX(conditionToEvaluate.getCondition(), conditionValue1, conditionValue2);128 mes = ans.getResultMessage();129 break;130 case CONDITIONOPERATOR_IFSTRINGEQUAL:131 ans = evaluateCondition_ifStringEqual(conditionToEvaluate.getCondition(), conditionValue1, conditionValue2, conditionValue3);132 mes = ans.getResultMessage();133 break;134 case CONDITIONOPERATOR_IFSTRINGDIFFERENT:135 ans = evaluateCondition_ifStringDifferent(conditionToEvaluate.getCondition(), conditionValue1, conditionValue2, conditionValue3);136 mes = ans.getResultMessage();137 break;138 case CONDITIONOPERATOR_IFSTRINGGREATER:139 ans = evaluateCondition_ifStringGreater(conditionToEvaluate.getCondition(), conditionValue1, conditionValue2);140 mes = ans.getResultMessage();141 break;142 case CONDITIONOPERATOR_IFSTRINGMINOR:143 ans = evaluateCondition_ifStringMinor(conditionToEvaluate.getCondition(), conditionValue1, conditionValue2);144 mes = ans.getResultMessage();145 break;146 case CONDITIONOPERATOR_IFSTRINGCONTAINS:147 ans = evaluateCondition_ifStringContains(conditionToEvaluate.getCondition(), conditionValue1, conditionValue2, conditionValue3);148 mes = ans.getResultMessage();149 break;150 case CONDITIONOPERATOR_IFSTRINGNOTCONTAINS:151 ans = evaluateCondition_ifStringNotContains(conditionToEvaluate.getCondition(), conditionValue1, conditionValue2, conditionValue3);152 mes = ans.getResultMessage();153 break;154 case CONDITIONOPERATOR_NEVER:155 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_NEVER);156 mes.setDescription(mes.getDescription().replace("%COND%", conditionToEvaluate.getCondition()));157 break;158 case CONDITIONOPERATOR_IFTEXTINELEMENT:159 ans = evaluateCondition_ifTextInElement(tCExecution, conditionValue1, conditionValue2, conditionValue3);160 mes = ans.getResultMessage();161 break;162 case CONDITIONOPERATOR_IFTEXTNOTINELEMENT:163 ans = evaluateCondition_ifTextNotInElement(tCExecution, conditionValue1, conditionValue2, conditionValue3);164 mes = ans.getResultMessage();165 break;166 default:167 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_UNKNOWNCONDITION);168 mes.setDescription(mes.getDescription().replace("%COND%", conditionToEvaluate.getCondition()));169 }170 LOG.debug("Finished Evaluation condition : {}", mes.getCodeString());171 // Reset Timeout to default172 robotServerService.setOptionsToDefault(tCExecution.getSession());173 // the decision whether we execute the action/control/step is taken from the codeString of the message.174 isOperationToBeExecuted = mes.getCodeString().equals("OK");175 ans.setItem(isOperationToBeExecuted);176 ans.setResultMessage(mes);177 return ans;178 }179 private AnswerItem<Boolean> evaluateCondition_ifTextInElement(TestCaseExecution tCExecution, String path, String expected, String isCaseSensitive) {180 LOG.debug("Checking ifTextInElement on {} element against value: {}", path, expected);181 AnswerItem<Boolean> ans = new AnswerItem<>();182 MessageEvent resultControlMes;183 isCaseSensitive = defaultIsSensitiveValue(isCaseSensitive);184 if (tCExecution.getManualExecution().equals("Y")) {185 resultControlMes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUEMANUAL_TEXTINELEMENT);186 resultControlMes.resolveDescription("STRING1", path);187 resultControlMes.resolveDescription("STRING2", expected);188 resultControlMes.resolveDescription("STRING3", isCaseSensitive);189 } else {190 resultControlMes = new MessageEvent(MessageEventEnum.ACTION_SUCCESS);191 // TODO AJOUTER DANS CONDITION OPERATOR ENUM = TRUE + nouveau message192 resultControlMes = controlService.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTEQUAL, tCExecution, path, expected, isCaseSensitive);193 MessageEvent resultCondMes;194 if ("OK".equals(resultControlMes.getCodeString())) {195 resultCondMes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_TEXTINELEMENT);196 ans.setItem(true);197 } else {198 resultCondMes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_TEXTINELEMENT);199 resultCondMes.setDescription(resultCondMes.getDescription().replace("%ERRORMESS%", resultControlMes.getDescription()));200 ans.setItem(false);201 }202 ans.setResultMessage(resultCondMes);203 return ans;204 }205 ans.setResultMessage(resultControlMes);206 return ans;207 }208 private AnswerItem<Boolean> evaluateCondition_ifTextNotInElement(TestCaseExecution tCExecution, String path, String expected, String isCaseSensitive) {209 LOG.debug("Checking ifTextInElement on {} element against value: {}", path, expected);210 AnswerItem<Boolean> ans = new AnswerItem<>();211 MessageEvent resultMes;212 isCaseSensitive = defaultIsSensitiveValue(isCaseSensitive);213 if (tCExecution.getManualExecution().equals("Y")) {214 resultMes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUEMANUAL_TEXTNOTINELEMENT);215 resultMes.resolveDescription("STRING1", path);216 resultMes.resolveDescription("STRING2", expected);217 resultMes.resolveDescription("STRING3", isCaseSensitive);218 } else {219 resultMes = controlService.verifyElementXXX(TestCaseStepActionControl.CONTROL_VERIFYELEMENTTEXTDIFFERENT, tCExecution, path, expected, isCaseSensitive);220 MessageEvent resultCondMes;221 if ("OK".equals(resultMes.getCodeString())) {222 resultCondMes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_TEXTNOTINELEMENT);223 ans.setItem(true);224 } else {225 resultCondMes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_TEXTNOTINELEMENT);226 resultCondMes.setDescription(resultCondMes.getDescription().replace("%ERRORMESS%", resultMes.getDescription()));227 ans.setItem(false);228 }229 ans.setResultMessage(resultCondMes);230 return ans;231 }232 ans.setResultMessage(resultMes);233 return ans;234 }235 private AnswerItem<Boolean> evaluateCondition_ifPropertyExist(String conditionOperator, String conditionValue1, TestCaseExecution tCExecution) {236 LOG.debug("Checking if property Exist");237 AnswerItem<Boolean> ans = new AnswerItem<>();238 MessageEvent mes;239 if (StringUtil.isNullOrEmpty(conditionValue1)) {240 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFPROPERTYEXIST_MISSINGPARAMETER);241 mes.setDescription(mes.getDescription().replace("%COND%", conditionOperator));242 } else {243 String myCountry = tCExecution.getCountry();244 boolean doExecuteAction = false;245 for (TestCaseCountryProperties prop : tCExecution.getTestCaseCountryPropertyList()) {246 LOG.debug("{} - {} - {} - {}", prop.getCountry(), myCountry, prop.getProperty(), conditionValue1);247 if ((prop.getCountry().equals(myCountry)) && (prop.getProperty().equals(conditionValue1))) {248 doExecuteAction = true;249 }250 }251 if (!doExecuteAction) {252 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFPROPERTYEXIST);253 } else {254 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFPROPERTYEXIST);255 }256 mes.setDescription(mes.getDescription().replace("%COND%", conditionOperator));257 mes.setDescription(mes.getDescription().replace("%PROP%", conditionValue1));258 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));259 }260 ans.setResultMessage(mes);261 return ans;262 }263 private AnswerItem<Boolean> evaluateCondition_ifPropertyNotExist(String conditionOperator, String conditionValue1, TestCaseExecution tCExecution) {264 LOG.debug("Checking if property Does not Exist");265 AnswerItem<Boolean> ans = new AnswerItem<>();266 MessageEvent mes;267 if (StringUtil.isNullOrEmpty(conditionValue1)) {268 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFPROPERTYNOTEXIST_MISSINGPARAMETER);269 mes.setDescription(mes.getDescription().replace("%COND%", conditionOperator));270 } else {271 String myCountry = tCExecution.getCountry();272 boolean doExecuteAction = true;273 for (TestCaseCountryProperties prop : tCExecution.getTestCaseCountryPropertyList()) {274 LOG.debug("{} - {} - {} - {}", prop.getCountry(), myCountry, prop.getProperty(), conditionValue1);275 if ((prop.getCountry().equals(myCountry)) && (prop.getProperty().equals(conditionValue1))) {276 doExecuteAction = false;277 }278 }279 if (!doExecuteAction) {280 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFPROPERTYNOTEXIST);281 } else {282 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFPROPERTYNOTEXIST);283 }284 mes.setDescription(mes.getDescription().replace("%COND%", conditionOperator));285 mes.setDescription(mes.getDescription().replace("%PROP%", conditionValue1));286 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));287 }288 ans.setResultMessage(mes);289 return ans;290 }291 private AnswerItem<Boolean> evaluateCondition_ifElementPresent(String conditionOperator, String conditionValue1, TestCaseExecution tCExecution) {292 LOG.debug("Checking if Element Present");293 AnswerItem<Boolean> ans = new AnswerItem<>();294 MessageEvent mes;295 if (tCExecution.getManualExecution().equals("Y")) {296 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUEMANUAL_IFELEMENTPRESENT);297 mes.resolveDescription("ELEMENT", conditionValue1);298 } else if (StringUtil.isNullOrEmpty(conditionValue1)) {299 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFELEMENTPRESENT_MISSINGPARAMETER);300 mes.setDescription(mes.getDescription().replace("%COND%", conditionOperator));301 } else {302 boolean conditionResult = false;303 Identifier identifier = identifierService.convertStringToIdentifier(conditionValue1);304 switch (tCExecution.getApplicationObj().getType()) {305 case Application.TYPE_GUI:306 case Application.TYPE_APK:307 case Application.TYPE_IPA:308 try {309 if (identifier.getIdentifier().equals("picture")) {310 mes = sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator());311 if (mes.equals(new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT))) {312 conditionResult = true;313 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTPRESENT);314 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));315 } else if (mes.equals(new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT))) {316 conditionResult = false;317 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTPRESENT);318 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));319 }320 } else if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {321 conditionResult = true;322 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTPRESENT);323 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));324 } else {325 conditionResult = false;326 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTPRESENT);327 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));328 }329 } catch (WebDriverException exception) {330 conditionResult = false;331 mes = parseWebDriverException(exception);332 }333 break;334 case Application.TYPE_FAT:335 if (identifier.getIdentifier().equals("picture")) {336 mes = sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator());337 LOG.debug("Sikuli : {}", mes.getCode());338 if (mes.equals(new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT))) {339 conditionResult = true;340 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTPRESENT);341 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));342 } else if (mes.equals(new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT))) {343 conditionResult = false;344 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTPRESENT);345 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));346 }347 } else {348 conditionResult = false;349 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_GENERIC);350 mes.resolveDescription("ERROR", "Element must start by picture=");351 }352 break;353 case Application.TYPE_SRV:354 if (tCExecution.getLastServiceCalled() != null) {355 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();356 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {357 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:358 if (LOG.isDebugEnabled()) {359 LOG.debug("Checking if Element Present - XML");360 }361 if (xmlUnitService.isElementPresent(responseBody, conditionValue1)) {362 conditionResult = true;363 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTPRESENT);364 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));365 } else {366 conditionResult = false;367 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTPRESENT);368 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));369 }370 break;371 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON:372 if (LOG.isDebugEnabled()) {373 LOG.debug("Checking if Element Present - JSON");374 }375 try {376 if (jsonService.getFromJson(responseBody, null, conditionValue1) != null) {377 conditionResult = true;378 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTPRESENT);379 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));380 } else {381 conditionResult = false;382 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTPRESENT);383 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));384 }385 } catch (Exception ex) {386 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_GENERIC);387 mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));388 }389 break;390 default:391 conditionResult = false;392 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOTSUPPORTED_FOR_MESSAGETYPE);393 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));394 mes.setDescription(mes.getDescription().replace("%CONDITION%", conditionOperator));395 }396 } else {397 conditionResult = false;398 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOOBJECTINMEMORY);399 }400 break;401 default:402 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOTSUPPORTED_FOR_APPLICATION);403 mes.setDescription(mes.getDescription().replace("%CONDITION%", conditionOperator));404 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));405 }406 }407 ans.setResultMessage(mes);408 return ans;409 }410 private AnswerItem<Boolean> evaluateCondition_ifElementNotPresent(String conditionOperator, String conditionValue1, TestCaseExecution tCExecution) {411 LOG.debug("Checking if Element is Not Present");412 AnswerItem<Boolean> ans = new AnswerItem<>();413 MessageEvent mes;414 if (tCExecution.getManualExecution().equals("Y")) {415 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUEMANUAL_IFELEMENTNOTPRESENT);416 mes.resolveDescription("ELEMENT", conditionValue1);417 } else if (StringUtil.isNullOrEmpty(conditionValue1)) {418 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFELEMENTNOTPRESENT_MISSINGPARAMETER);419 mes.setDescription(mes.getDescription().replace("%COND%", conditionOperator));420 } else {421 boolean conditionResult = false;422 Identifier identifier = identifierService.convertStringToIdentifier(conditionValue1);423 switch (tCExecution.getApplicationObj().getType()) {424 case Application.TYPE_GUI:425 case Application.TYPE_APK:426 case Application.TYPE_IPA:427 try {428 if (identifier.getIdentifier().equals("picture")) {429 mes = sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator());430 if (mes.equals(new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT))) {431 conditionResult = true;432 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTNOTPRESENT);433 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));434 } else if (mes.equals(new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT))) {435 conditionResult = false;436 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTNOTPRESENT);437 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));438 }439 } else if (!this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {440 conditionResult = true;441 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTNOTPRESENT);442 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));443 } else {444 conditionResult = false;445 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTNOTPRESENT);446 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));447 }448 } catch (WebDriverException exception) {449 conditionResult = false;450 mes = parseWebDriverException(exception);451 }452 break;453 case Application.TYPE_FAT:454 if (identifier.getIdentifier().equals("picture")) {455 mes = sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator());456 LOG.debug("Sikuli : {}", mes.getCode());457 if (mes.equals(new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT))) {458 conditionResult = true;459 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTNOTPRESENT);460 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));461 } else if (mes.equals(new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT))) {462 conditionResult = false;463 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTNOTPRESENT);464 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));465 }466 } else {467 conditionResult = false;468 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_GENERIC);469 mes.resolveDescription("ERROR", "Element must start by picture=");470 }471 break;472 case Application.TYPE_SRV:473 if (tCExecution.getLastServiceCalled() != null) {474 String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();475 switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {476 case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:477 if (!xmlUnitService.isElementPresent(responseBody, conditionValue1)) {478 conditionResult = true;479 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTNOTPRESENT);480 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));481 } else {482 conditionResult = false;483 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTNOTPRESENT);484 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));485 }486 break;487 case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON:488 try {489 if (jsonService.getFromJson(responseBody, null, conditionValue1) == null) {490 conditionResult = true;491 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_IFELEMENTNOTPRESENT);492 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));493 } else {494 conditionResult = false;495 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_IFELEMENTNOTPRESENT);496 mes.setDescription(mes.getDescription().replace("%ELEMENT%", conditionValue1));497 }498 } catch (Exception ex) {499 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_GENERIC);500 mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));501 }502 break;503 default:504 conditionResult = false;505 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOTSUPPORTED_FOR_MESSAGETYPE);506 mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));507 mes.setDescription(mes.getDescription().replace("%CONDITION%", conditionOperator));508 }509 } else {510 conditionResult = false;511 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOOBJECTINMEMORY);512 }513 break;514 default:515 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_NOTSUPPORTED_FOR_APPLICATION);516 mes.setDescription(mes.getDescription().replace("%CONDITION%", conditionOperator));517 mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));518 }519 }520 ans.setResultMessage(mes);521 return ans;522 }523 private AnswerItem<Boolean> evaluateCondition_ifElementVisible(String conditionOperator, String conditionValue1, TestCaseExecution tCExecution) {524 LOG.debug("Checking if Element Visible");525 AnswerItem<Boolean> ans = new AnswerItem<>();526 MessageEvent mes;527 if (tCExecution.getManualExecution().equals("Y")) {528 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUEMANUAL_IFELEMENTVISIBLE);529 mes.resolveDescription("ELEMENT", conditionValue1);530 } else if (StringUtil.isNullOrEmpty(conditionValue1)) {531 mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_IFELEMENTVISIBLE_MISSINGPARAMETER);532 mes.setDescription(mes.getDescription().replace("%COND%", conditionOperator));533 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)534 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)535 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {536 try {537 Identifier identifier = identifierService.convertStringToIdentifier(conditionValue1);...
evaluateCondition_ifElementVisible
Using AI Code Generation
1boolean elementVisible = false;2int retries = 0;3int maxRetries = 5;4int timeToWait = 1000;5while (!elementVisible && retries < maxRetries) {6 elementVisible = evaluateCondition_ifElementVisible("myElement");7 if (!elementVisible) {8 sleep(timeToWait);9 retries++;10 }11}12if (elementVisible) {13}14if (!elemen
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!