Best Cerberus-source code snippet using org.cerberus.service.webdriver.impl.WebDriverService.isElementPresent
Source:ControlService.java  
...538                    || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {539                try {540                    if (identifier.getIdentifier().equals("picture")) {541                        return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator());542                    } else if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {543                        mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT);544                        mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));545                        return mes;546                    } else {547                        mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);548                        mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));549                        return mes;550                    }551                } catch (WebDriverException exception) {552                    return parseWebDriverException(exception);553                }554            } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_SRV)) {555                if (tCExecution.getLastServiceCalled() != null) {556                    String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();557                    switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {558                        case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:559                            if (xmlUnitService.isElementPresent(responseBody, elementPath)) {560                                mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT);561                                mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));562                                return mes;563                            } else {564                                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);565                                mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));566                                return mes;567                            }568                        case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {569                            try {570                                if (jsonService.getFromJson(responseBody, null, elementPath) != null) {571                                    mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_PRESENT);572                                    mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));573                                    return mes;574                                } else {575                                    mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);576                                    mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));577                                    return mes;578                                }579                            } catch (Exception ex) {580                                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);581                                mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));582                                return mes;583                            }584                        }585                        default:586                            mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);587                            mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));588                            mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementPresent"));589                            return mes;590                    }591                } else {592                    mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);593                    return mes;594                }595            } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {596                return sikuliService.doSikuliVerifyElementPresent(tCExecution.getSession(), identifier.getLocator());597            } else {598                mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);599                mes.setDescription(mes.getDescription().replace("%CONTROL%", "VerifyElementPresent"));600                mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));601                return mes;602            }603        } else {604            return new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT_NULL);605        }606    }607    private MessageEvent verifyElementNotPresent(TestCaseExecution tCExecution, String elementPath) {608        LOG.debug("Control : verifyElementNotPresent on : " + elementPath);609        MessageEvent mes;610        if (!StringUtil.isNull(elementPath)) {611            Identifier identifier = identifierService.convertStringToIdentifier(elementPath);612            if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)613                    || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)614                    || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {615                try {616                    if (identifier.getIdentifier().equals("picture")) {617                        return sikuliService.doSikuliVerifyElementNotPresent(tCExecution.getSession(), identifier.getLocator());618                    } else if (!this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {619                        mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);620                        mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));621                        return mes;622                    } else {623                        mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);624                        mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));625                        return mes;626                    }627                } catch (WebDriverException exception) {628                    return parseWebDriverException(exception);629                }630            } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {631                return sikuliService.doSikuliVerifyElementNotPresent(tCExecution.getSession(), identifier.getLocator());632            } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_SRV)) {633                if (tCExecution.getLastServiceCalled() != null) {634                    String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();635                    switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {636                        case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:637                            if (!(xmlUnitService.isElementPresent(responseBody, elementPath))) {638                                mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);639                                mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));640                                return mes;641                            } else {642                                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);643                                mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));644                                return mes;645                            }646                        case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {647                            try {648                                if (jsonService.getFromJson(responseBody, null, elementPath) == null) {649                                    mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTPRESENT);650                                    mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));651                                    return mes;652                                } else {653                                    mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT);654                                    mes.setDescription(mes.getDescription().replace("%STRING1%", elementPath));655                                    return mes;656                                }657                            } catch (Exception ex) {658                                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);659                                mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));660                                return mes;661                            }662                        }663                        default:664                            mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);665                            mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));666                            mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementNotPresent"));667                            return mes;668                    }669                } else {670                    mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);671                    return mes;672                }673            } else {674                mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);675                mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementNotPresent"));676                mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));677                return mes;678            }679        } else {680            return new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTPRESENT_NULL);681        }682    }683    private MessageEvent verifyElementInElement(TestCaseExecution tCExecution, String element, String childElement) {684        if (LOG.isDebugEnabled()) {685            LOG.debug("Control : verifyElementInElement on : '" + element + "' is child of '" + childElement + "'");686        }687        MessageEvent mes;688        if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)689                || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {690            if (!StringUtil.isNull(element) && !StringUtil.isNull(childElement)) {691                try {692                    Identifier identifier = identifierService.convertStringToIdentifier(element);693                    Identifier childIdentifier = identifierService.convertStringToIdentifier(childElement);694                    if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {695                        if (this.webdriverService.isElementInElement(tCExecution.getSession(), identifier, childIdentifier)) {696                            mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTINELEMENT);697                            mes.setDescription(mes.getDescription().replace("%STRING2%", element).replace("%STRING1%", childElement));698                            return mes;699                        } else {700                            mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTINELEMENT);701                            mes.setDescription(mes.getDescription().replace("%STRING2%", element).replace("%STRING1%", childElement));702                            return mes;703                        }704                    } else {705                        mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NO_SUCH_ELEMENT);706                        mes.setDescription(mes.getDescription().replace("%SELEX%", new NoSuchElementException("").toString()).replace("%ELEMENT%", element));707                        return mes;708                    }709                } catch (WebDriverException exception) {710                    return parseWebDriverException(exception);711                }712            } else {713                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTINELEMENT);714                mes.setDescription(mes.getDescription().replace("%STRING2%", element).replace("%STRING1%", childElement));715                return mes;716            }717        } else {718            mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);719            mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementInElement"));720            mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));721            return mes;722        }723    }724    private MessageEvent verifyElementVisible(TestCaseExecution tCExecution, String html) {725        LOG.debug("Control : verifyElementVisible on : " + html);726        MessageEvent mes;727        if (!StringUtil.isNull(html)) {728            if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)729                    || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)730                    || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {731                try {732                    Identifier identifier = identifierService.convertStringToIdentifier(html);733                    if (this.webdriverService.isElementVisible(tCExecution.getSession(), identifier)) {734                        mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_VISIBLE);735                        mes.setDescription(mes.getDescription().replace("%STRING1%", html));736                        return mes;737                    } else {738                        mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_VISIBLE);739                        mes.setDescription(mes.getDescription().replace("%STRING1%", html));740                        return mes;741                    }742                } catch (WebDriverException exception) {743                    return parseWebDriverException(exception);744                }745            } else {746                mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);747                mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementVisible"));748                mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));749                return mes;750            }751        } else {752            return new MessageEvent(MessageEventEnum.CONTROL_FAILED_VISIBLE_NULL);753        }754    }755    private MessageEvent verifyElementNotVisible(TestCaseExecution tCExecution, String html) {756        LOG.debug("Control : verifyElementNotVisible on : " + html);757        MessageEvent mes;758        if (!StringUtil.isNull(html)) {759            if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)760                    || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)761                    || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {762                try {763                    Identifier identifier = identifierService.convertStringToIdentifier(html);764                    if (this.webdriverService.isElementPresent(tCExecution.getSession(), identifier)) {765                        if (this.webdriverService.isElementNotVisible(tCExecution.getSession(), identifier)) {766                            mes = new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_NOTVISIBLE);767                            mes.setDescription(mes.getDescription().replace("%STRING1%", html));768                            return mes;769                        } else {770                            mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTVISIBLE);771                            mes.setDescription(mes.getDescription().replace("%STRING1%", html));772                            return mes;773                        }774                    } else {775                        mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_PRESENT);776                        mes.setDescription(mes.getDescription().replace("%STRING1%", html));777                        return mes;778                    }779                } catch (WebDriverException exception) {780                    return parseWebDriverException(exception);781                }782            } else {783                mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);784                mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementNotVisible"));785                mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));786                return mes;787            }788        } else {789            return new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOTVISIBLE_NULL);790        }791    }792    private MessageEvent verifyElementEquals(TestCaseExecution tCExecution, String xpath, String expectedElement) {793        LOG.debug("Control : verifyElementEquals on : " + xpath + " expected Element : " + expectedElement);794        MessageEvent mes = null;795        // If case of not compatible application then exit with error796        if (!tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_SRV)) {797            mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);798            mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementEquals"));799            mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));800            return mes;801        }802        // Check if element on the given xpath is equal to the given expected element803        if (tCExecution.getLastServiceCalled() != null) {804            String xmlResponse = tCExecution.getLastServiceCalled().getResponseHTTPBody();805            switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {806                case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:807                    mes = xmlUnitService.isElementEquals(xmlResponse, xpath, expectedElement) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTEQUALS) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTEQUALS);808                    mes.setDescription(mes.getDescription().replace("%XPATH%", xpath));809                    mes.setDescription(mes.getDescription().replace("%EXPECTED_ELEMENT%", expectedElement));810                    return mes;811                default:812                    mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);813                    mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));814                    mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementEquals"));815                    return mes;816            }817            // TODO Give the actual element found into the description.818        } else {819            mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);820            return mes;821        }822    }823    private MessageEvent verifyElementDifferent(TestCaseExecution tCExecution, String xpath, String differentElement) {824        LOG.debug("Control : verifyElementDifferent on : " + xpath + " expected Element : " + differentElement);825        MessageEvent mes = null;826        // If case of not compatible application then exit with error827        if (!tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_SRV)) {828            mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);829            mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementDifferent"));830            mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));831            return mes;832        }833        // Check if element on the given xpath is different from the given different element834//        SOAPExecution lastSoapCalled = (SOAPExecution) tCExecution.getLastSOAPCalled().getItem();835        if (tCExecution.getLastServiceCalled() != null) {836            switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {837                case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:838                    String xmlResponse = tCExecution.getLastServiceCalled().getResponseHTTPBody();839                    mes = xmlUnitService.isElementEquals(xmlResponse, xpath, differentElement) ? new MessageEvent(MessageEventEnum.CONTROL_FAILED_ELEMENTDIFFERENT) : new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_ELEMENTDIFFERENT);840                    mes.setDescription(mes.getDescription().replace("%XPATH%", xpath));841                    mes.setDescription(mes.getDescription().replace("%DIFFERENT_ELEMENT%", differentElement));842                    return mes;843                default:844                    mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);845                    mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));846                    mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyElementDifferent"));847                    return mes;848            }849            // TODO Give the actual element found into the description.850        } else {851            mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);852            return mes;853        }854    }855    public MessageEvent verifyTextInElement(TestCaseExecution tCExecution, String path, String expected, String isCaseSensitive) {856        if (LOG.isDebugEnabled()) {857            LOG.debug("Control: verifyTextInElement on " + path + " element against value: " + expected);858        }859        MessageEvent mes;860        // Get value from the path element according to the application type861        String actual = null;862        try {863            Identifier identifier = identifierService.convertStringToIdentifier(path);864            String applicationType = tCExecution.getApplicationObj().getType();865            if (Application.TYPE_GUI.equalsIgnoreCase(applicationType)866                    || Application.TYPE_APK.equalsIgnoreCase(applicationType)867                    || Application.TYPE_IPA.equalsIgnoreCase(applicationType)) {868                actual = webdriverService.getValueFromHTML(tCExecution.getSession(), identifier);869                // In case of null actual value then we alert user870                if (actual == null) {871                    mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NULL);872                    mes.setDescription(mes.getDescription().replace("%STRING1%", path));873                    return mes;874                }875                // Construct the message from the actual response876                mes = verifyTextInElementCaseSensitiveCheck(actual, expected, isCaseSensitive);877                mes.setDescription(mes.getDescription().replace("%STRING1%", path));878                mes.setDescription(mes.getDescription().replace("%STRING2%", actual));879                mes.setDescription(mes.getDescription().replace("%STRING3%", expected));880                mes.setDescription(mes.getDescription().replace("%STRING4%", caseSensitiveMessageValue(isCaseSensitive)));881                return mes;882            } else if (Application.TYPE_SRV.equalsIgnoreCase(applicationType)) {883                if (tCExecution.getLastServiceCalled() != null) {884                    String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();885                    switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {886                        case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:887                            if (!xmlUnitService.isElementPresent(responseBody, path)) {888                                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NO_SUCH_ELEMENT);889                                mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));890                                return mes;891                            }892                            String newPath = StringUtil.addSuffixIfNotAlready(path, "/text()");893                            actual = xmlUnitService.getFromXml(responseBody, newPath);894                            // In case of null actual value then we alert user895                            if (actual == null) {896                                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NULL);897                                mes.setDescription(mes.getDescription().replace("%STRING1%", path));898                                return mes;899                            }900                            // Construct the message from the actual response901                            mes = verifyTextInElementCaseSensitiveCheck(actual, expected, isCaseSensitive);902                            mes.setDescription(mes.getDescription().replace("%STRING1%", path));903                            mes.setDescription(mes.getDescription().replace("%STRING2%", actual));904                            mes.setDescription(mes.getDescription().replace("%STRING3%", expected));905                            mes.setDescription(mes.getDescription().replace("%STRING4%", caseSensitiveMessageValue(isCaseSensitive)));906                            return mes;907                        case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {908                            try {909                                actual = jsonService.getFromJson(responseBody, null, path);910                            } catch (Exception ex) {911                                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);912                                mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));913                                return mes;914                            }915                        }916                        // In case of null actual value then we alert user917                        if (actual == null) {918                            mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NO_SUCH_ELEMENT);919                            mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));920                            return mes;921                        }922                        // Construct the message from the actual response923                        mes = verifyTextInElementCaseSensitiveCheck(actual, expected, isCaseSensitive);924                        mes.setDescription(mes.getDescription().replace("%STRING1%", path));925                        mes.setDescription(mes.getDescription().replace("%STRING2%", actual));926                        mes.setDescription(mes.getDescription().replace("%STRING3%", expected));927                        mes.setDescription(mes.getDescription().replace("%STRING4%", caseSensitiveMessageValue(isCaseSensitive)));928                        return mes;929                        default:930                            mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);931                            mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));932                            mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyTextInElement"));933                            return mes;934                    }935                    // TODO Give the actual element found into the description.936                } else {937                    mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);938                    return mes;939                }940            } else {941                mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);942                mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyTextInElement"));943                mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));944                return mes;945            }946        } catch (NoSuchElementException exception) {947            mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NO_SUCH_ELEMENT);948            mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));949            return mes;950        } catch (WebDriverException exception) {951            return parseWebDriverException(exception);952        }953    }954    private MessageEvent verifyTextInElementCaseSensitiveCheck(String actual, String expected, String isCaseSensitive) {955        MessageEvent mes;956        if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false)) {957            mes = actual.equals(expected) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTINELEMENT) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT);958        } else {959            mes = actual.equalsIgnoreCase(expected) ? new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTINELEMENT) : new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT);960        }961        return mes;962    }963    public MessageEvent verifyTextNotInElement(TestCaseExecution tCExecution, String path, String expected, String isCaseSensitive) {964        if (LOG.isDebugEnabled()) {965            LOG.debug("Control: verifyTextNotInElement on " + path + " element against value: " + expected);966        }967        MessageEvent mes;968        // Get value from the path element according to the application type969        String actual = null;970        try {971            Identifier identifier = identifierService.convertStringToIdentifier(path);972            String applicationType = tCExecution.getApplicationObj().getType();973            if (Application.TYPE_GUI.equalsIgnoreCase(applicationType)974                    || Application.TYPE_APK.equalsIgnoreCase(applicationType)975                    || Application.TYPE_IPA.equalsIgnoreCase(applicationType)) {976                actual = webdriverService.getValueFromHTML(tCExecution.getSession(), identifier);977                // In case of null actual value then we alert user978                if (actual == null) {979                    mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT_NULL);980                    mes.setDescription(mes.getDescription().replace("%STRING1%", path));981                    return mes;982                }983                // Construct the message from the actual response984                mes = verifyTextNotInElementCaseSensitiveCheck(actual, expected, isCaseSensitive);985                mes.setDescription(mes.getDescription().replace("%STRING1%", path));986                mes.setDescription(mes.getDescription().replace("%STRING2%", actual));987                mes.setDescription(mes.getDescription().replace("%STRING3%", expected));988                mes.setDescription(mes.getDescription().replace("%STRING4%", caseSensitiveMessageValue(isCaseSensitive)));989                return mes;990            } else if (Application.TYPE_SRV.equalsIgnoreCase(applicationType)) {991                if (tCExecution.getLastServiceCalled() != null) {992                    String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();993                    switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {994                        case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:995                            if (!xmlUnitService.isElementPresent(responseBody, path)) {996                                throw new NoSuchElementException("Unable to find element " + path);997                            }998                            String newPath = StringUtil.addSuffixIfNotAlready(path, "/text()");999                            actual = xmlUnitService.getFromXml(responseBody, newPath);1000                            // In case of null actual value then we alert user1001                            if (actual == null) {1002                                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT_NULL);1003                                mes.setDescription(mes.getDescription().replace("%STRING1%", path));1004                                return mes;1005                            }1006                            // Construct the message from the actual response1007                            mes = verifyTextNotInElementCaseSensitiveCheck(actual, expected, isCaseSensitive);1008                            mes.setDescription(mes.getDescription().replace("%STRING1%", path));1009                            mes.setDescription(mes.getDescription().replace("%STRING2%", actual));1010                            mes.setDescription(mes.getDescription().replace("%STRING3%", expected));1011                            mes.setDescription(mes.getDescription().replace("%STRING4%", caseSensitiveMessageValue(isCaseSensitive)));1012                            return mes;1013                        case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON: {1014                            try {1015                                actual = jsonService.getFromJson(responseBody, null, path);1016                            } catch (Exception ex) {1017                                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);1018                                mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));1019                                return mes;1020                            }1021                        }1022                        // In case of null actual value then we alert user1023                        if (actual == null) {1024                            mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NO_SUCH_ELEMENT);1025                            mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));1026                            return mes;1027                        }1028                        // Construct the message from the actual response1029                        mes = verifyTextNotInElementCaseSensitiveCheck(actual, expected, isCaseSensitive);1030                        mes.setDescription(mes.getDescription().replace("%STRING1%", path));1031                        mes.setDescription(mes.getDescription().replace("%STRING2%", actual));1032                        mes.setDescription(mes.getDescription().replace("%STRING3%", expected));1033                        return mes;1034                        default:1035                            mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_MESSAGETYPE);1036                            mes.setDescription(mes.getDescription().replace("%TYPE%", tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()));1037                            mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyTextNotInElement"));1038                            return mes;1039                    }1040                } else {1041                    mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_NOOBJECTINMEMORY);1042                    return mes;1043                }1044            } else {1045                mes = new MessageEvent(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);1046                mes.setDescription(mes.getDescription().replace("%CONTROL%", "verifyTextNotInElement"));1047                mes.setDescription(mes.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));1048                return mes;1049            }1050        } catch (NoSuchElementException exception) {1051            mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT_NO_SUCH_ELEMENT);1052            mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));1053            return mes;1054        } catch (WebDriverException exception) {1055            return parseWebDriverException(exception);1056        }1057    }1058    private MessageEvent verifyTextNotInElementCaseSensitiveCheck(String actual, String expected, String isCaseSensitive) {1059        MessageEvent mes;1060        if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false)) {1061            mes = actual.equals(expected) ? new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT) : new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTNOTINELEMENT);1062        } else {1063            mes = actual.equalsIgnoreCase(expected) ? new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT) : new MessageEvent(MessageEventEnum.CONTROL_SUCCESS_TEXTNOTINELEMENT);1064        }1065        return mes;1066    }1067    private MessageEvent VerifyRegexInElement(TestCaseExecution tCExecution, String path, String regex) {1068        LOG.debug("Control : verifyRegexInElement on : " + path + " element against value : " + regex);1069        MessageEvent mes;1070        String pathContent = null;1071        try {1072            Identifier identifier = identifierService.convertStringToIdentifier(path);1073            String applicationType = tCExecution.getApplicationObj().getType();1074            // Get value from the path element according to the application type1075            if (Application.TYPE_GUI.equalsIgnoreCase(applicationType)1076                    || Application.TYPE_APK.equalsIgnoreCase(applicationType)1077                    || Application.TYPE_IPA.equalsIgnoreCase(applicationType)) {1078                pathContent = this.webdriverService.getValueFromHTML(tCExecution.getSession(), identifier);1079            } else if (Application.TYPE_SRV.equalsIgnoreCase(applicationType)) {1080                if (tCExecution.getLastServiceCalled() != null) {1081                    String responseBody = tCExecution.getLastServiceCalled().getResponseHTTPBody();1082                    switch (tCExecution.getLastServiceCalled().getResponseHTTPBodyContentType()) {1083                        case AppService.RESPONSEHTTPBODYCONTENTTYPE_XML:1084                            if (!xmlUnitService.isElementPresent(responseBody, path)) {1085                                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NO_SUCH_ELEMENT);1086                                mes.setDescription(mes.getDescription().replace("%ELEMENT%", path));1087                                return mes;1088                            }1089                            String newPath = StringUtil.addSuffixIfNotAlready(path, "/text()");1090                            pathContent = xmlUnitService.getFromXml(responseBody, newPath);1091                            break;1092                        case AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON:1093                            try {1094                                pathContent = jsonService.getFromJson(responseBody, null, path);1095                            } catch (Exception ex) {1096                                mes = new MessageEvent(MessageEventEnum.CONTROL_FAILED_GENERIC);1097                                mes.setDescription(mes.getDescription().replace("%ERROR%", ex.toString()));1098                                return mes;...Source:ControlServiceTest.java  
...467//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();468//        tcsae.setTestCaseStepExecution(tcse);469//        tcsace.setTestCaseStepActionExecution(tcsae);470//471//        when(webdriverService.isElementPresent(session, identifier)).thenReturn(true);472//473//        this.controlService.doControl(tcsace);474//475//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());476//        Assert.assertEquals("OK", tcsace.getReturnCode());477//    }478//    @Ignore479//    @Test480//    public void testDoControlElementPresentWhenFail() {481//        String property = "id=test";482//        String value = "null";483//        String msg = "Element '" + property + "' is not present on the page.";484//        Identifier identifier = new Identifier();485//        identifier.setIdentifier("id");486//        identifier.setLocator("test");487//488//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();489//        tcsace.setControl("verifyElementPresent");490//        tcsace.setValue1(property);491//        tcsace.setValue2(value);492//        tcsace.setFatal("Y");493//        TestCaseStepExecution tcse = new TestCaseStepExecution();494//        tcse.settCExecution(tCExecution);495//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();496//        tcsae.setTestCaseStepExecution(tcse);497//        tcsace.setTestCaseStepActionExecution(tcsae);498//499//        when(webdriverService.isElementPresent(session, identifier)).thenReturn(false);500//501//        this.controlService.doControl(tcsace);502//503//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());504//        Assert.assertEquals("KO", tcsace.getReturnCode());505//        Assert.assertEquals("Y", tcsace.getFatal());506//    }507    @Ignore508    @Test509    public void testDoControlElementPresentWhenPropertyNull() {510        String property = "null";511        String value = "id=test";512        String msg = "Object is 'null'. This is mandatory in order to perform the control verify element present";513        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();514        tcsace.setControl("verifyElementPresent");515        tcsace.setValue1(property);516        tcsace.setValue2(value);517        tcsace.setFatal("Y");518        TestCaseStepExecution tcse = new TestCaseStepExecution();519        tcse.settCExecution(tCExecution);520        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();521        tcsae.setTestCaseStepExecution(tcse);522        tcsace.setTestCaseStepActionExecution(tcsae);523        this.controlService.doControl(tcsace);524        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());525        Assert.assertEquals("KO", tcsace.getReturnCode());526        Assert.assertEquals("Y", tcsace.getFatal());527    }528//    @Ignore529//    @Test530//    public void testDoControlElementPresentWhenWebDriverException() {531//        String property = "id=test";532//        String value = "null";533//        String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*";534//        Identifier identifier = new Identifier();535//        identifier.setIdentifier("id");536//        identifier.setLocator("test");537//538//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();539//        tcsace.setControl("verifyElementPresent");540//        tcsace.setValue1(property);541//        tcsace.setValue2(value);542//        tcsace.setFatal("Y");543//        tCExecution.setSession(session);544//        TestCaseStepExecution tcse = new TestCaseStepExecution();545//        tcse.settCExecution(tCExecution);546//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();547//        tcsae.setTestCaseStepExecution(tcse);548//        tcsace.setTestCaseStepActionExecution(tcsae);549//        550//        when(webdriverService.isElementPresent(tCExecution.getSession(), identifier)).thenThrow(new WebDriverException());551//552//        this.controlService.doControl(tcsace);553//554//        Assert.assertTrue( tcsace.getControlResultMessage().getDescription().matches(msg));555//        Assert.assertEquals("CA", tcsace.getReturnCode());556//        Assert.assertEquals("Y", tcsace.getFatal());557//    }558//    @Ignore559//    @Test560//    public void testDoControlElementNotPresentWhenSuccess() {561//        String property = "id=test";562//        String value = "null";563//        String msg = "Element '" + property + "' is not present on the page.";564//        Identifier identifier = new Identifier();565//        identifier.setIdentifier("id");566//        identifier.setLocator("test");567//568//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();569//        tcsace.setControl("verifyElementNotPresent");570//        tcsace.setValue1(property);571//        tcsace.setValue2(value);572//        TestCaseStepExecution tcse = new TestCaseStepExecution();573//        tcse.settCExecution(tCExecution);574//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();575//        tcsae.setTestCaseStepExecution(tcse);576//        tcsace.setTestCaseStepActionExecution(tcsae);577//578//        when(webdriverService.isElementPresent(session, identifier)).thenReturn(false);579//580//        this.controlService.doControl(tcsace);581//582//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());583//        Assert.assertEquals("OK", tcsace.getReturnCode());584//    }585//    @Ignore586//    @Test587//    public void testDoControlElementNotPresentWhenFail() {588//        String property = "id=test";589//        String value = "null";590//        String msg = "Element '" + property + "' is present on the page.";591//        Identifier identifier = new Identifier();592//        identifier.setIdentifier("id");593//        identifier.setLocator("test");594//595//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();596//        tcsace.setControl("verifyElementNotPresent");597//        tcsace.setValue1(property);598//        tcsace.setValue2(value);599//        tcsace.setFatal("Y");600//        TestCaseStepExecution tcse = new TestCaseStepExecution();601//        tcse.settCExecution(tCExecution);602//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();603//        tcsae.setTestCaseStepExecution(tcse);604//        tcsace.setTestCaseStepActionExecution(tcsae);605//606//        when(webdriverService.isElementPresent(session, identifier)).thenReturn(true);607//608//        this.controlService.doControl(tcsace);609//610//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());611//        Assert.assertEquals("KO", tcsace.getReturnCode());612//        Assert.assertEquals("Y", tcsace.getFatal());613//    }614    @Ignore615    @Test616    public void testDoControlElementNotPresentWhenPropertyNull() {617        String property = "null";618        String value = "id=test";619        String msg = "Object is 'null'. This is mandatory in order to perform the control verify element not present";620        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();621        tcsace.setControl("verifyElementNotPresent");622        tcsace.setValue1(property);623        tcsace.setValue2(value);624        tcsace.setFatal("Y");625        TestCaseStepExecution tcse = new TestCaseStepExecution();626        tcse.settCExecution(tCExecution);627        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();628        tcsae.setTestCaseStepExecution(tcse);629        tcsace.setTestCaseStepActionExecution(tcsae);630        this.controlService.doControl(tcsace);631        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());632        Assert.assertEquals("KO", tcsace.getReturnCode());633        Assert.assertEquals("Y", tcsace.getFatal());634    }635//    @Ignore636//    @Test637//    public void testDoControlElementNotPresentWhenWebDriverException() {638//        String property = "id=test";639//        String value = "null";640//        String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*";641//        Identifier identifier = new Identifier();642//        identifier.setIdentifier("id");643//        identifier.setLocator("test");644//645//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();646//        tcsace.setControl("verifyElementNotPresent");647//        tcsace.setValue1(property);648//        tcsace.setValue2(value);649//        tcsace.setFatal("Y");650//        TestCaseStepExecution tcse = new TestCaseStepExecution();651//        tcse.settCExecution(tCExecution);652//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();653//        tcsae.setTestCaseStepExecution(tcse);654//        tcsace.setTestCaseStepActionExecution(tcsae);655//656//        when(webdriverService.isElementPresent(session, identifier)).thenThrow(new WebDriverException());657//658//        this.controlService.doControl(tcsace);659//660//        Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg));661//        Assert.assertEquals("CA", tcsace.getReturnCode());662//        Assert.assertEquals("Y", tcsace.getFatal());663//    }664//    @Ignore665//    @Test666//    public void testDoControlElementNotVisibleWhenSuccess() {667//        String property = "id=test";668//        String value = "null";669//        String msg = "Element '" + property + "' is present and not visible on the page.";670//        Identifier identifier = new Identifier();671//        identifier.setIdentifier("id");672//        identifier.setLocator("test");673//674//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();675//        tcsace.setControl("verifyElementNotVisible");676//        tcsace.setValue1(property);677//        tcsace.setValue2(value);678//        tcsace.setFatal("Y");679//        TestCaseStepExecution tcse = new TestCaseStepExecution();680//        tcse.settCExecution(tCExecution);681//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();682//        tcsae.setTestCaseStepExecution(tcse);683//        tcsace.setTestCaseStepActionExecution(tcsae);684//685//        when(webdriverService.isElementPresent(session, identifier)).thenReturn(true);686//        when(webdriverService.isElementNotVisible(session, identifier)).thenReturn(true);687//688//        this.controlService.doControl(tcsace);689//690//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());691//        Assert.assertEquals("OK", tcsace.getReturnCode());692//    }693//694//    @Ignore695//    @Test696//    public void testDoControlElementNotVisibleWhenFail() {697//        String property = "id=test";698//        String value = "null";699//        String msg = "Element '" + property + "' is visible on the page.";700//        Identifier identifier = new Identifier();701//        identifier.setIdentifier("id");702//        identifier.setLocator("test");703//704//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();705//        tcsace.setControl("verifyElementNotVisible");706//        tcsace.setValue1(property);707//        tcsace.setValue2(value);708//        tcsace.setFatal("Y");709//        TestCaseStepExecution tcse = new TestCaseStepExecution();710//        tcse.settCExecution(tCExecution);711//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();712//        tcsae.setTestCaseStepExecution(tcse);713//        tcsace.setTestCaseStepActionExecution(tcsae);714//715//        when(webdriverService.isElementPresent(session, identifier)).thenReturn(true);716//        when(webdriverService.isElementNotVisible(session, identifier)).thenReturn(false);717//718//        this.controlService.doControl(tcsace);719//720//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());721//        Assert.assertEquals("KO", tcsace.getReturnCode());722//        Assert.assertEquals("Y", tcsace.getFatal());723//    }724    @Test725    public void testDoControlElementNotVisibleWhenPropertyNull() {726        String property = "null";727        String value = "id=test";728        String msg = "Object is 'null'. This is mandatory in order to perform the control verify element not visible";729        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();730        tcsace.setControl("verifyElementNotVisible");731        tcsace.setValue1(property);732        tcsace.setValue2(value);733        tcsace.setFatal("Y");734        TestCaseStepExecution tcse = new TestCaseStepExecution();735        tcse.settCExecution(tCExecution);736        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();737        tcsae.setTestCaseStepExecution(tcse);738        tcsace.setTestCaseStepActionExecution(tcsae);739        this.controlService.doControl(tcsace);740        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());741        Assert.assertEquals("KO", tcsace.getReturnCode());742        Assert.assertEquals("Y", tcsace.getFatal());743    }744//    @Ignore745//    @Test746//    public void testDoControlElementNotVisibleWhenWebDriverException() {747//        String property = "id=test";748//        String value = "null";749//        String msg = "The test case is canceled due to lost connection to Selenium Server! Detailed error : .*";750//        Identifier identifier = new Identifier();751//        identifier.setIdentifier("id");752//        identifier.setLocator("test");753//754//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();755//        tcsace.setControl("verifyElementNotVisible");756//        tcsace.setValue1(property);757//        tcsace.setValue2(value);758//        tcsace.setFatal("Y");759//        TestCaseStepExecution tcse = new TestCaseStepExecution();760//        tcse.settCExecution(tCExecution);761//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();762//        tcsae.setTestCaseStepExecution(tcse);763//        tcsace.setTestCaseStepActionExecution(tcsae);764//765//        when(webdriverService.isElementPresent(session, identifier)).thenThrow(new WebDriverException());766//767//        this.controlService.doControl(tcsace);768//769//        Assert.assertTrue(tcsace.getControlResultMessage().getDescription().matches(msg));770//        Assert.assertEquals("CA", tcsace.getReturnCode());771//        Assert.assertEquals("Y", tcsace.getFatal());772//    }773    @Test774    public void testDoControlElementInElementWhenValueIsNull() {775        String property = "id=test";776        String value = "null";777        String msg = "Element '" + value + "' is not child of element '" + property + "'.";778        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();779        tcsace.setControl("verifyElementInElement");780        tcsace.setValue1(property);781        tcsace.setValue2(value);782        tcsace.setFatal("Y");783        TestCaseStepExecution tcse = new TestCaseStepExecution();784        tcse.settCExecution(tCExecution);785        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();786        tcsae.setTestCaseStepExecution(tcse);787        tcsace.setTestCaseStepActionExecution(tcsae);788        this.controlService.doControl(tcsace);789        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());790        Assert.assertEquals("KO", tcsace.getReturnCode());791        Assert.assertEquals("Y", tcsace.getFatal());792    }793    @Test794    public void testDoControlElementInElementWhenPropertyIsNull() {795        String property = "null";796        String value = "id=test";797        String msg = "Element '" + value + "' is not child of element '" + property + "'.";798        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();799        tcsace.setControl("verifyElementInElement");800        tcsace.setValue1(property);801        tcsace.setValue2(value);802        tcsace.setFatal("Y");803        TestCaseStepExecution tcse = new TestCaseStepExecution();804        tcse.settCExecution(tCExecution);805        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();806        tcsae.setTestCaseStepExecution(tcse);807        tcsace.setTestCaseStepActionExecution(tcsae);808        this.controlService.doControl(tcsace);809        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());810        Assert.assertEquals("KO", tcsace.getReturnCode());811        Assert.assertEquals("Y", tcsace.getFatal());812    }813//    @Ignore814//    @Test815//    public void testDoControlElementInElementWhenValueIsNotChildOfProperty() {816//        String property = "id=parent";817//        String value = "id=child";818//        String msg = "Element '" + value + "' is not child of element '" + property + "'.";819//        Identifier identifier = new Identifier();820//        identifier.setIdentifier("id");821//        identifier.setLocator("test");822//        Identifier identifierValue = new Identifier();823//        identifier.setIdentifier("id");824//        identifier.setLocator("test2");825//826//        when(webdriverService.isElementInElement(session, identifier, identifierValue)).thenReturn(Boolean.FALSE);827//828//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();829//        tcsace.setControl("verifyElementInElement");830//        tcsace.setValue1(property);831//        tcsace.setValue2(value);832//        tcsace.setFatal("Y");833//        TestCaseStepExecution tcse = new TestCaseStepExecution();834//        tcse.settCExecution(tCExecution);835//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();836//        tcsae.setTestCaseStepExecution(tcse);837//        tcsace.setTestCaseStepActionExecution(tcsae);838//839//        this.controlService.doControl(tcsace);840//841//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());842//        Assert.assertEquals("KO", tcsace.getReturnCode());843//        Assert.assertEquals("Y", tcsace.getFatal());844//    }845//846//    @Ignore847//    @Test848//    public void testDoControlElementInElementWhenValueIsChildOfProperty() {849//        String property = "id=parent";850//        String value = "id=child";851//        String msg = "Element '" + value + "' in child of element '" + property + "'.";852//        Identifier identifier = new Identifier();853//        identifier.setIdentifier("id");854//        identifier.setLocator("test");855//        Identifier identifierValue = new Identifier();856//        identifier.setIdentifier("id");857//        identifier.setLocator("test2");858//859//        when(webdriverService.isElementInElement(session, identifier, identifierValue)).thenReturn(Boolean.TRUE);860//861//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();862//        tcsace.setControl("verifyElementInElement");863//        tcsace.setValue1(property);864//        tcsace.setValue2(value);865//        tcsace.setFatal("Y");866//        TestCaseStepExecution tcse = new TestCaseStepExecution();867//        tcse.settCExecution(tCExecution);868//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();869//        tcsae.setTestCaseStepExecution(tcse);870//        tcsace.setTestCaseStepActionExecution(tcsae);871//872//        this.controlService.doControl(tcsace);873//874//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());875//        Assert.assertEquals("OK", tcsace.getReturnCode());876//        Assert.assertEquals("Y", tcsace.getFatal());877//    }878    @Test879    public void testVerifyElementEqualsWithNotCompatibleApplication() {880        String xpath = "/foo/bar";881        String expectedElement = "<bar>baz</bar>";882        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();883        tcsace.setControl("verifyElementEquals");884        tcsace.setValue1(xpath);885        tcsace.setValue2(expectedElement);886        tcsace.setFatal("Y");887        TestCaseStepExecution tcse = new TestCaseStepExecution();888        tcse.settCExecution(tCExecution);889        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();890        tcsae.setTestCaseStepExecution(tcse);891        tcsace.setTestCaseStepActionExecution(tcsae);892        this.controlService.doControl(tcsace);893        Assert.assertEquals(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION.getCode(), tcsace.getControlResultMessage().getCode());894    }895//    @Test896//    public void testVerifyElementEqualsWithElementPresent() {897//        String xpath = "/foo/bar";898//        String expectedElement = "<bar>baz</bar>";899//        String xmlResponse = "<bar>bar</bar>";900//        String msg = "Element in path '" + xpath + "' is equal to '" + expectedElement + "'.";901//902////        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();903////        tcsace.setControlType("verifyElementEquals");904////        tcsace.setControlProperty(xpath);905////        tcsace.setControlValue(expectedElement);906////        tcsace.setFatal("Y");907////        TestCaseStepExecution tcse = new TestCaseStepExecution();908////        tcse.settCExecution(tCExecution);909////        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();910////        tcsae.setTestCaseStepExecution(tcse);911////        tcsace.setTestCaseStepActionExecution(tcsae);912//        //when(application.getType()).thenReturn("WS");913//        when(xmlUnitService.isElementEquals(xmlResponse, xpath, expectedElement)).thenReturn(Boolean.TRUE);914//915//        this.controlService.doControl(tcsace);916//917//        Assert.assertEquals(MessageEventEnum.CONTROL_SUCCESS_ELEMENTEQUALS.getCode(), tcsace.getControlResultMessage().getCode());918//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());919//    }920//    @Test921//    public void testVerifyElementEqualsWithElementAbsent() {922//    	String xpath = "/foo/bar";923//        String expectedElement = "<bar>baz</bar>";924//        String msg = "Element in path '" + xpath + "' is not equal to '" + expectedElement + "'.";925//        926//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();927//        tcsace.setControlType("verifyElementEquals");928//        tcsace.setControlProperty(xpath);929//        tcsace.setControlValue(expectedElement);930//        tcsace.setFatal("Y");931//        TestCaseStepExecution tcse = new TestCaseStepExecution();932//        tcse.settCExecution(tCExecution);933//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();934//        tcsae.setTestCaseStepExecution(tcse);935//        tcsace.setTestCaseStepActionExecution(tcsae);936//        937//        when(application.getType()).thenReturn("WS");938//        when(xmlUnitService.isElementEquals(tCExecution, xpath, expectedElement)).thenReturn(Boolean.FALSE);939//940//        this.controlService.doControl(tcsace);941//942//        Assert.assertEquals(MessageEventEnum.CONTROL_FAILED_ELEMENTEQUALS.getCode(), tcsace.getControlResultMessage().getCode());943//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());944//    }945//    946//    @Test947//    public void testVerifyElementDifferentWithNotCompatibleApplication() {948//    	String xpath = "/foo/bar";949//        String expectedElement = "<bar>baz</bar>";950//951//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();952//        tcsace.setControlType("verifyElementDifferent");953//        tcsace.setControlProperty(xpath);954//        tcsace.setControlValue(expectedElement);955//        tcsace.setFatal("Y");956//        TestCaseStepExecution tcse = new TestCaseStepExecution();957//        tcse.settCExecution(tCExecution);958//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();959//        tcsae.setTestCaseStepExecution(tcse);960//        tcsace.setTestCaseStepActionExecution(tcsae);961//962//        this.controlService.doControl(tcsace);963//964//        Assert.assertEquals(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION.getCode(), tcsace.getControlResultMessage().getCode());965//    }966//    967//    @Test968//    public void testVerifyElementDifferentWithElementDifferent() {969//    	String xpath = "/foo/bar";970//        String expectedElement = "<bar>baz</bar>";971//        String msg = "Element in path '" + xpath + "' is different from '" + expectedElement + "'.";972//        973//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();974//        tcsace.setControlType("verifyElementDifferent");975//        tcsace.setControlProperty(xpath);976//        tcsace.setControlValue(expectedElement);977//        tcsace.setFatal("Y");978//        TestCaseStepExecution tcse = new TestCaseStepExecution();979//        tcse.settCExecution(tCExecution);980//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();981//        tcsae.setTestCaseStepExecution(tcse);982//        tcsace.setTestCaseStepActionExecution(tcsae);983//        984//        when(application.getType()).thenReturn("WS");985//        when(xmlUnitService.isElementEquals(tCExecution, xpath, expectedElement)).thenReturn(Boolean.FALSE);986//987//        this.controlService.doControl(tcsace);988//989//        Assert.assertEquals(MessageEventEnum.CONTROL_SUCCESS_ELEMENTDIFFERENT.getCode(), tcsace.getControlResultMessage().getCode());990//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());991//    }992//    993//    @Test994//    public void testVerifyElementDifferentWithElementEquals() {995//    	String xpath = "/foo/bar";996//        String expectedElement = "<bar>baz</bar>";997//        String msg = "Element in path '" + xpath + "' is not different from '" + expectedElement + "'.";998//        999//        TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();1000//        tcsace.setControlType("verifyElementDifferent");1001//        tcsace.setControlProperty(xpath);1002//        tcsace.setControlValue(expectedElement);1003//        tcsace.setFatal("Y");1004//        TestCaseStepExecution tcse = new TestCaseStepExecution();1005//        tcse.settCExecution(tCExecution);1006//        TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();1007//        tcsae.setTestCaseStepExecution(tcse);1008//        tcsace.setTestCaseStepActionExecution(tcsae);1009//        1010//        when(application.getType()).thenReturn("WS");1011//        when(xmlUnitService.isElementEquals(tCExecution, xpath, expectedElement)).thenReturn(Boolean.TRUE);1012//1013//        this.controlService.doControl(tcsace);1014//1015//        Assert.assertEquals(MessageEventEnum.CONTROL_FAILED_ELEMENTDIFFERENT.getCode(), tcsace.getControlResultMessage().getCode());1016//        Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());1017//    }1018//    1019//    @Test1020//    public void testVerifyTextInElementWhenElementExistsAndTextEquals() {1021//		String xpath = "/foo/bar";1022//		String actual = "foo";1023//		String expected = "foo";1024//		String msg = "Element '" + xpath + "' with value '" + actual + "' is equal to '" + expected + "'.";1025//1026//		TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();1027//		tcsace.setControlType("verifyTextInElement");1028//		tcsace.setControlProperty(xpath);1029//		tcsace.setControlValue(expected);1030//		tcsace.setFatal("Y");1031//		TestCaseStepExecution tcse = new TestCaseStepExecution();1032//		tcse.settCExecution(tCExecution);1033//		TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();1034//		tcsae.setTestCaseStepExecution(tcse);1035//		tcsace.setTestCaseStepActionExecution(tcsae);1036//1037//		when(application.getType()).thenReturn("WS");1038//		when(tCExecution.getExecutionUUID()).thenReturn("uuid");1039//		when(xmlUnitService.isElementPresent(tCExecution, xpath)).thenReturn(true);1040//		when(xmlUnitService.getFromXml("uuid", null, xpath)).thenReturn(actual);1041//1042//		this.controlService.doControl(tcsace);1043//1044//		Assert.assertEquals(MessageEventEnum.CONTROL_SUCCESS_TEXTINELEMENT.getCode(), tcsace.getControlResultMessage().getCode());1045//		Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());1046//    }1047//    1048//    @Test1049//    public void testVerifyTextInElementWhenElementExistsAndTextNotEquals() {1050//		String xpath = "/foo/bar";1051//		String actual = "foo";1052//		String expected = "bar";1053//		String msg = "Element '" + xpath + "' with value '" + actual + "' is not equal to '" + expected + "'.";1054//1055//		TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();1056//		tcsace.setControlType("verifyTextInElement");1057//		tcsace.setControlProperty(xpath);1058//		tcsace.setControlValue(expected);1059//		tcsace.setFatal("Y");1060//		TestCaseStepExecution tcse = new TestCaseStepExecution();1061//		tcse.settCExecution(tCExecution);1062//		TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();1063//		tcsae.setTestCaseStepExecution(tcse);1064//		tcsace.setTestCaseStepActionExecution(tcsae);1065//1066//		when(application.getType()).thenReturn("WS");1067//		when(tCExecution.getExecutionUUID()).thenReturn("uuid");1068//		when(xmlUnitService.isElementPresent(tCExecution, xpath)).thenReturn(true);1069//		when(xmlUnitService.getFromXml("uuid", null, xpath)).thenReturn(actual);1070//1071//		this.controlService.doControl(tcsace);1072//1073//		Assert.assertEquals(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT.getCode(), tcsace.getControlResultMessage().getCode());1074//		Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());1075//    }1076//    1077//    @Test1078//    public void testVerifyTextInElementWhenElementExistsAndTextIsNull() {1079//		String xpath = "/foo/bar";1080//		String actual = null;1081//		String expected = "bar";1082//		String msg = "Found Element '" + xpath + "' but can not find text or value.";1083//1084//		TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();1085//		tcsace.setControlType("verifyTextInElement");1086//		tcsace.setControlProperty(xpath);1087//		tcsace.setControlValue(expected);1088//		tcsace.setFatal("Y");1089//		TestCaseStepExecution tcse = new TestCaseStepExecution();1090//		tcse.settCExecution(tCExecution);1091//		TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();1092//		tcsae.setTestCaseStepExecution(tcse);1093//		tcsace.setTestCaseStepActionExecution(tcsae);1094//1095//		when(application.getType()).thenReturn("WS");1096//		when(tCExecution.getExecutionUUID()).thenReturn("uuid");1097//		when(xmlUnitService.isElementPresent(tCExecution, xpath)).thenReturn(true);1098//		when(xmlUnitService.getFromXml("uuid", null, xpath)).thenReturn(actual);1099//1100//		this.controlService.doControl(tcsace);1101//1102//		Assert.assertEquals(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NULL.getCode(), tcsace.getControlResultMessage().getCode());1103//		Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());1104//    }1105//    1106//    @Test1107//    public void testVerifyTextInElementWhenElementNotExists() {1108//		String xpath = "/foo/bar";1109//		String expected = "bar";1110//		String msg = "Failed to verifyTextInElement because could not find element '" + xpath + "'";1111//1112//		TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();1113//		tcsace.setControlType("verifyTextInElement");1114//		tcsace.setControlProperty(xpath);1115//		tcsace.setControlValue(expected);1116//		tcsace.setFatal("Y");1117//		TestCaseStepExecution tcse = new TestCaseStepExecution();1118//		tcse.settCExecution(tCExecution);1119//		TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();1120//		tcsae.setTestCaseStepExecution(tcse);1121//		tcsace.setTestCaseStepActionExecution(tcsae);1122//1123//		when(application.getType()).thenReturn("WS");1124//		when(tCExecution.getExecutionUUID()).thenReturn("uuid");1125//		when(xmlUnitService.isElementPresent(tCExecution, xpath)).thenReturn(false);1126//1127//		this.controlService.doControl(tcsace);1128//1129//		Assert.assertEquals(MessageEventEnum.CONTROL_FAILED_TEXTINELEMENT_NO_SUCH_ELEMENT.getCode(), tcsace.getControlResultMessage().getCode());1130//		Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());1131//    }1132//    1133//    public void testVerifyTextInElementWithNotSupportedApplication() {1134//		String xpath = "/foo/bar";1135//		String actual = "foo";1136//		String expected = "bar";1137//		String msg = "Not executed because Control 'verifyTextInElement' is not supported for application type 'UNKNOWN'.";1138//1139//		TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();1140//		tcsace.setControlType("verifyTextInElement");1141//		tcsace.setControlProperty(xpath);1142//		tcsace.setControlValue(expected);1143//		tcsace.setFatal("Y");1144//		TestCaseStepExecution tcse = new TestCaseStepExecution();1145//		tcse.settCExecution(tCExecution);1146//		TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();1147//		tcsae.setTestCaseStepExecution(tcse);1148//		tcsace.setTestCaseStepActionExecution(tcsae);1149//1150//		when(application.getType()).thenReturn("UNKNOWN");1151//		when(tCExecution.getExecutionUUID()).thenReturn("uuid");1152//		when(xmlUnitService.isElementPresent(tCExecution, xpath)).thenReturn(true);1153//		when(xmlUnitService.getFromXml("uuid", null, xpath)).thenReturn(actual);1154//1155//		this.controlService.doControl(tcsace);1156//1157//		Assert.assertEquals(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION.getCode(), tcsace.getControlResultMessage().getCode());1158//		Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());1159//    }1160//    1161//    @Test1162//    public void testVerifyTextNotInElementWhenElementExistsAndTextDifferent() {1163//		String xpath = "/foo/bar";1164//		String actual = "foo";1165//		String expected = "bar";1166//		String msg = "Element '" + xpath + "' with value '" + actual + "' is different than '" + expected + "'.";1167//1168//		TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();1169//		tcsace.setControlType("verifyTextNotInElement");1170//		tcsace.setControlProperty(xpath);1171//		tcsace.setControlValue(expected);1172//		tcsace.setFatal("Y");1173//		TestCaseStepExecution tcse = new TestCaseStepExecution();1174//		tcse.settCExecution(tCExecution);1175//		TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();1176//		tcsae.setTestCaseStepExecution(tcse);1177//		tcsace.setTestCaseStepActionExecution(tcsae);1178//1179//		when(application.getType()).thenReturn("WS");1180//		when(tCExecution.getExecutionUUID()).thenReturn("uuid");1181//		when(xmlUnitService.isElementPresent(tCExecution, xpath)).thenReturn(true);1182//		when(xmlUnitService.getFromXml("uuid", null, xpath)).thenReturn(actual);1183//1184//		this.controlService.doControl(tcsace);1185//1186//		Assert.assertEquals(MessageEventEnum.CONTROL_SUCCESS_TEXTNOTINELEMENT.getCode(), tcsace.getControlResultMessage().getCode());1187//		Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());1188//    }1189//    1190//    @Test1191//    public void testVerifyTextNotInElementWhenElementExistsAndTextNotDifferent() {1192//		String xpath = "/foo/bar";1193//		String actual = "foo";1194//		String expected = "foo";1195//		String msg = "Element '" + xpath + "' with value '" + actual + "' is not different than '" + expected + "'.";1196//1197//		TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();1198//		tcsace.setControlType("verifyTextNotInElement");1199//		tcsace.setControlProperty(xpath);1200//		tcsace.setControlValue(expected);1201//		tcsace.setFatal("Y");1202//		TestCaseStepExecution tcse = new TestCaseStepExecution();1203//		tcse.settCExecution(tCExecution);1204//		TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();1205//		tcsae.setTestCaseStepExecution(tcse);1206//		tcsace.setTestCaseStepActionExecution(tcsae);1207//1208//		when(application.getType()).thenReturn("WS");1209//		when(tCExecution.getExecutionUUID()).thenReturn("uuid");1210//		when(xmlUnitService.isElementPresent(tCExecution, xpath)).thenReturn(true);1211//		when(xmlUnitService.getFromXml("uuid", null, xpath)).thenReturn(actual);1212//1213//		this.controlService.doControl(tcsace);1214//1215//		Assert.assertEquals(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT.getCode(), tcsace.getControlResultMessage().getCode());1216//		Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());1217//    }1218//    1219//    @Test1220//    public void testVerifyTextNotInElementWhenElementExistsAndTextIsNull() {1221//		String xpath = "/foo/bar";1222//		String actual = null;1223//		String expected = "bar";1224//		String msg = "Found Element '" + xpath + "' but can not find text or value.";1225//1226//		TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();1227//		tcsace.setControlType("verifyTextNotInElement");1228//		tcsace.setControlProperty(xpath);1229//		tcsace.setControlValue(expected);1230//		tcsace.setFatal("Y");1231//		TestCaseStepExecution tcse = new TestCaseStepExecution();1232//		tcse.settCExecution(tCExecution);1233//		TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();1234//		tcsae.setTestCaseStepExecution(tcse);1235//		tcsace.setTestCaseStepActionExecution(tcsae);1236//1237//		when(application.getType()).thenReturn("WS");1238//		when(tCExecution.getExecutionUUID()).thenReturn("uuid");1239//		when(xmlUnitService.isElementPresent(tCExecution, xpath)).thenReturn(true);1240//		when(xmlUnitService.getFromXml("uuid", null, xpath)).thenReturn(actual);1241//1242//		this.controlService.doControl(tcsace);1243//1244//		Assert.assertEquals(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT_NULL.getCode(), tcsace.getControlResultMessage().getCode());1245//		Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());1246//    }1247//    1248//    @Test1249//    public void testVerifyTextNotInElementWhenElementNotExists() {1250//		String xpath = "/foo/bar";1251//		String expected = "bar";1252//		String msg = "Failed to verifyTextNotInElement because could not find element '" + xpath + "'";1253//1254//		TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();1255//		tcsace.setControlType("verifyTextNotInElement");1256//		tcsace.setControlProperty(xpath);1257//		tcsace.setControlValue(expected);1258//		tcsace.setFatal("Y");1259//		TestCaseStepExecution tcse = new TestCaseStepExecution();1260//		tcse.settCExecution(tCExecution);1261//		TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();1262//		tcsae.setTestCaseStepExecution(tcse);1263//		tcsace.setTestCaseStepActionExecution(tcsae);1264//1265//		when(application.getType()).thenReturn("WS");1266//		when(tCExecution.getExecutionUUID()).thenReturn("uuid");1267//		when(xmlUnitService.isElementPresent(tCExecution, xpath)).thenReturn(false);1268//1269//		this.controlService.doControl(tcsace);1270//1271//		Assert.assertEquals(MessageEventEnum.CONTROL_FAILED_TEXTNOTINELEMENT_NO_SUCH_ELEMENT.getCode(), tcsace.getControlResultMessage().getCode());1272//		Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());1273//    }1274//    1275//    public void testVerifyTextNotInElementWithNotSupportedApplication() {1276//		String xpath = "/foo/bar";1277//		String actual = "foo";1278//		String expected = "bar";1279//		String msg = "Not executed because Control 'verifyTextNotInElement' is not supported for application type 'UNKNOWN'.";1280//1281//		TestCaseStepActionControlExecution tcsace = new TestCaseStepActionControlExecution();1282//		tcsace.setControlType("verifyTextNotInElement");1283//		tcsace.setControlProperty(xpath);1284//		tcsace.setControlValue(expected);1285//		tcsace.setFatal("Y");1286//		TestCaseStepExecution tcse = new TestCaseStepExecution();1287//		tcse.settCExecution(tCExecution);1288//		TestCaseStepActionExecution tcsae = new TestCaseStepActionExecution();1289//		tcsae.setTestCaseStepExecution(tcse);1290//		tcsace.setTestCaseStepActionExecution(tcsae);1291//1292//		when(application.getType()).thenReturn("UNKNOWN");1293//		when(tCExecution.getExecutionUUID()).thenReturn("uuid");1294//		when(xmlUnitService.isElementPresent(tCExecution, xpath)).thenReturn(true);1295//		when(xmlUnitService.getFromXml("uuid", null, xpath)).thenReturn(actual);1296//1297//		this.controlService.doControl(tcsace);1298//1299//		Assert.assertEquals(MessageEventEnum.CONTROL_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION.getCode(), tcsace.getControlResultMessage().getCode());1300//		Assert.assertEquals(msg, tcsace.getControlResultMessage().getDescription());1301//    }1302//    1303}...isElementPresent
Using AI Code Generation
1import org.cerberus.engine.entity.MessageEvent;2import org.cerberus.engine.entity.MessageGeneral;3import org.cerberus.engine.entity.Test;4import org.cerberus.engine.entity.TestCaseExecution;5import org.cerberus.engine.entity.TestDataLibData;6import org.cerberus.engine.execution.IExecutionManagerService;7import org.cerberus.engine.execution.impl.ExecutionManagerService;8import org.cerberus.engine.execution.impl.TestExecutorService;9import org.cerberus.engine.execution.impl.TestExecutorService2;10import org.cerberus.engine.execution.impl.TestExecutorService3;11import org.cerberus.engine.execution.impl.TestExecutorService4;12import org.cerberus.engine.execution.impl.TestExecutorService5;13import org.cerberus.engine.execution.impl.TestExecutorService6;14import org.cerberus.engine.execution.impl.TestExecutorService7;15import org.cerberus.engine.execution.impl.TestExecutorService8;16import org.cerberus.engine.execution.impl.TestExecutorService9;17import org.cerberus.engine.execution.impl.TestExecutorService10;18import org.cerberus.engine.execution.impl.TestExecutorService11;19import org.cerberus.engine.execution.impl.TestExecutorService12;20import org.cerberus.engine.execution.impl.TestExecutorService13;21import org.cerberus.engine.execution.impl.TestExecutorService14;22import org.cerberus.engine.execution.impl.TestExecutorService15;23import org.cerberus.engine.execution.impl.TestExecutorService16;24import org.cerberus.engine.execution.impl.TestExecutorService17;25import org.cerberus.engine.execution.impl.TestExecutorService18;26import org.cerberus.engine.execution.impl.TestExecutorService19;27import org.cerberus.engine.execution.impl.TestExecutorService20;28import org.cerberus.engine.execution.impl.TestExecutorService21;29import org.cerberus.engine.execution.impl.TestExecutorService22;30import org.cerberus.engine.execution.impl.TestExecutorService23;31import org.cerberus.engine.execution.impl.TestExecutorService24;32import org.cerberus.engine.execution.impl.TestExecutorService25;33import org.cerberus.engine.execution.impl.TestExecutorService26;34import org.cerberus.engine.execution.impl.TestExecutorService27;35import org.cerberus.engine.execution.impl.TestExecutorService28;36import org.cerberus.engine.execution.impl.TestExecutorService29;37import org.cerberus.engine.execution.impl.TestExecutorisElementPresent
Using AI Code Generation
1import org.openqa.selenium.By;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.WebElement;4import org.openqa.selenium.chrome.ChromeDriver;5public class Test {6    public static void main(String[] args) {7        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Suresh\\Downloads\\chromedriver_win32\\chromedriver.exe");8        WebDriver driver = new ChromeDriver();9        WebElement element = driver.findElement(By.name("q"));10        element.sendKeys("Selenium");11        element.submit();12        System.out.println("Page title is: " + driver.getTitle());13        driver.quit();14    }15}16import org.openqa.selenium.By;17import org.openqa.selenium.WebDriver;18import org.openqa.selenium.WebElement;19import org.openqa.selenium.chrome.ChromeDriver;20public class Test {21    public static void main(String[] args) {22        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Suresh\\Downloads\\chromedriver_win32\\chromedriver.exe");23        WebDriver driver = new ChromeDriver();24        WebElement element = driver.findElement(By.name("q"));25        element.sendKeys("Selenium");26        element.submit();27        System.out.println("Page title is: " + driver.getTitle());28        driver.quit();29    }30}31import org.openqa.selenium.By;32import org.openqa.selenium.WebDriver;33import org.openqa.selenium.WebElement;34import org.openqa.selenium.chrome.ChromeDriver;35public class Test {36    public static void main(String[] args) {37        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Suresh\\Downloads\\chromedriver_win32\\chromedriver.exe");38        WebDriver driver = new ChromeDriver();39        WebElement element = driver.findElement(By.name("q"));40        element.sendKeys("Selenium");41        element.submit();42        System.out.println("Page title is: " + driver.getTitle());43        driver.quit();44    }45}46import org.openqaisElementPresent
Using AI Code Generation
1import org.cerberus.engine.entity.MessageEvent;2import org.cerberus.engine.entity.Session;3import org.cerberus.engine.execution.impl.TestService;4import org.cerberus.engine.execution.impl.TestCaseService;5import org.cerberus.engine.execution.impl.TestStepService;6import org.cerberus.engine.execution.impl.TestCaseStepActionExecutionService;7import org.cerberus.exception.CerberusEventException;8import org.cerberus.service.engine.IRecorderService;9import org.cerberus.service.engine.IParameterService;10import org.cerberus.service.engine.IInvariantService;11import org.cerberus.service.engine.IPropertyService;12import org.cerberus.service.engine.IApplicationObjectService;13import org.cerberus.service.engine.IElementService;14import org.cerberus.service.engine.IFactoryLogEventService;15import org.cerberus.service.engine.IFactorySeleniumService;16import org.cerberus.service.engine.IFactoryTestCaseService;17import org.cerberus.service.engine.IFactoryTestCaseStepActionService;18import org.cerberus.service.engine.IFactoryTestCaseStepActionExecutionService;19import org.cerberus.service.engine.IFactoryTestCaseStepActionControlService;20import org.cerberus.service.engine.IFactoryTestCaseStepActionControlExecutionService;21import org.cerberus.service.engine.IFactoryTestCaseStepActionControlExecutionFileService;22import org.cerberus.service.engine.IFactoryTestCaseStepActionControlExecutionObjectService;23import org.cerberus.service.engine.IFactoryTestCaseStepActionControlExecutionPageSourceService;24import org.cerberus.service.engine.IFactoryTestCaseStepActionControlExecutionScreenshotService;25import org.cerberus.service.engine.IFactoryTestCaseStepActionControlExecutionSoapService;26import org.cerberus.service.engine.IFactoryTestCaseStepActionControlExecutionTableService;27import org.cerberus.service.engine.IFactoryTestCaseStepActionControlExecutionTestCaseService;28import org.cerberus.service.engine.IFactoryTestCaseStepActionControlExecutionTimeService;29import org.cerberus.service.engine.IFactoryTestCaseStepActionControlExecutionXmlService;30import org.cerberus.service.engine.IFactoryTestCaseStepActionControlExecutionXmlUnitService;31import org.cerberus.service.engine.IFactoryTestCaseStepActionControlService;32import org.cerberus.service.engine.IFactoryTestCaseStepActionExecutionService;33import org.cerberus.serviceisElementPresent
Using AI Code Generation
1package com.cerberus;2import org.cerberus.engine.entity.SeleniumTest;3import org.cerberus.engine.entity.TestCaseExecution;4import org.cerberus.engine.execution.IExecutionThreadService;5import org.cerberus.engine.execution.impl.ExecutionThreadService;6import org.cerberus.engine.execution.impl.TestCaseExecutionService;7import org.cerberus.engine.execution.impl.TestCaseStepActionExecutionService;8import org.cerberus.engine.queuemanagement.IExecutionThreadPoolService;9import org.cerberus.engine.queuemanagement.impl.ExecutionThreadPoolService;10import org.cerberus.engine.queuemanagement.impl.ExecutionThreadPoolServiceFactory;11import org.cerberus.engine.queuemanagement.impl.TestCaseExecutionQueueService;12import org.cerberus.engine.queuemanagement.impl.TestCaseExecutionQueueServiceFactory;13import org.cerberus.engine.queuemanagement.impl.TestCaseExecutionThreadPoolService;14import org.cerberus.engine.queuemanagement.impl.TestCaseExecutionThreadPoolServiceFactory;15import org.cerberus.engine.queuemanagement.impl.TestCaseStepActionExecutionQueueService;16import org.cerberus.engine.queuemanagement.impl.TestCaseStepActionExecutionQueueServiceFactory;17import org.cerberus.engine.queuemanagement.impl.TestCaseStepActionExecutionThreadPoolService;18import org.cerberus.engine.queuemanagement.impl.TestCaseStepActionExecutionThreadPoolServiceFactory;19import org.cerberus.engine.scheduler.ISchedulerService;20import org.cerberus.engine.scheduler.impl.SchedulerService;21import org.cerberus.engine.scheduler.impl.SchedulerServiceFactory;22import org.cerberus.engine.threadpool.IExecutionThreadPoolServiceFactory;23import org.cerberus.engine.threadpool.impl.ExecutionThreadPoolServiceFactoryImpl;24import org.cerberus.engine.threadpool.impl.TestCaseExecutionThreadPoolServiceFactoryImpl;25import org.cerberus.engine.threadpool.impl.TestCaseStepActionExecutionThreadPoolServiceFactoryImpl;26import org.cerberus.engine.threadpool.impl.TestSuiteExecutionThreadPoolServiceFactoryImpl;27import org.cerberus.engine.threadpool.impl.TestSuiteExecutionThreadPoolServiceFactoryImpl;28import org.cerberus.engine.threadpool.impl.TestExecutionThreadPoolServiceFactoryImpl;29import org.cerberus.engine.threadpool.impl.TestExecutionThreadPoolServiceFactoryImpl;30import org.cerberus.engine.threadpool.impl.TestManualExecutionThreadPoolServiceFactoryImpl;31import org.cerisElementPresent
Using AI Code Generation
1public class Test {2    public static void main(String[] args) {3        WebDriverService wds = new WebDriverService();4        WebDriver driver = wds.initWebDriver("firefox");5        WebElement ele = driver.findElement(By.name("q"));6        ele.sendKeys("Cerberus");7        ele.submit();8        System.out.println("Page title is: " + driver.getTitle());9        wds.quitDriver(driver);10    }11}12public class Test {13    public static void main(String[] args) {14        WebDriverService wds = new WebDriverService();15        WebDriver driver = wds.initWebDriver("firefox");16        WebElement ele = driver.findElement(By.name("q"));17        ele.sendKeys("Cerberus");18        ele.submit();19        System.out.println("Page title is: " + driver.getTitle());20        wds.quitDriver(driver);21    }22}23public class Test {24    public static void main(String[] args) {25        WebDriverService wds = new WebDriverService();26        WebDriver driver = wds.initWebDriver("firefox");27        WebElement ele = driver.findElement(By.name("q"));28        ele.sendKeys("Cerberus");29        ele.submit();30        System.out.println("Page title is: " + driver.getTitle());31        wds.quitDriver(driver);32    }33}34public class Test {35    public static void main(String[] args) {36        WebDriverService wds = new WebDriverService();37        WebDriver driver = wds.initWebDriver("firefox");38        WebElement ele = driver.findElement(By.name("q"));39        ele.sendKeys("Cerberus");40        ele.submit();41        System.out.println("Page title is: " + driver.getTitle());42        wds.quitDriver(driver);43    }44}45public class Test {46    public static void main(String[] args) {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!!
