Search in sources :

Example 26 with CerberusEventException

use of org.cerberus.exception.CerberusEventException in project cerberus-source by cerberustesting.

the class ActionService method doActionFocusToIframe.

private MessageEvent doActionFocusToIframe(TestCaseExecution tCExecution, String object, String property) {
    MessageEvent message;
    String element;
    try {
        /**
         * Get element to use String object if not empty, String property if
         * object empty, throws Exception if both empty)
         */
        element = getElementToUse(object, property, "focusToIframe", tCExecution);
        /**
         * Get Identifier (identifier, locator)
         */
        Identifier identifier = identifierService.convertStringToIdentifier(element);
        identifierService.checkWebElementIdentifier(identifier.getIdentifier());
        if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
            return webdriverService.doSeleniumActionFocusToIframe(tCExecution.getSession(), identifier);
        }
        message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
        message.setDescription(message.getDescription().replace("%ACTION%", "FocusToIframe"));
        message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));
        return message;
    } catch (CerberusEventException ex) {
        LOG.fatal("Error doing Action FocusToIframe :" + ex);
        return ex.getMessageError();
    }
}
Also used : CerberusEventException(org.cerberus.exception.CerberusEventException) Identifier(org.cerberus.engine.entity.Identifier) MessageEvent(org.cerberus.engine.entity.MessageEvent)

Example 27 with CerberusEventException

use of org.cerberus.exception.CerberusEventException in project cerberus-source by cerberustesting.

the class ActionService method doActionWait.

private MessageEvent doActionWait(TestCaseExecution tCExecution, String object, String property) {
    MessageEvent message;
    String element;
    long timeToWaitInMs = 0;
    Identifier identifier = null;
    try {
        /**
         * Get element to use String object if not empty, String property if
         * object empty, null if both are empty
         */
        element = getElementToUse(object, property, "wait", tCExecution);
        if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI) || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK) || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA) || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {
            /**
             * if element is integer, set time to that value else Get
             * Identifier (identifier, locator)
             */
            if (StringUtil.isNullOrEmpty(element)) {
                timeToWaitInMs = tCExecution.getCerberus_action_wait_default();
            } else if (StringUtil.isInteger(element)) {
                timeToWaitInMs = Long.valueOf(element);
            } else {
                identifier = identifierService.convertStringToIdentifier(element);
            }
            if (identifier != null && identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {
                return sikuliService.doSikuliActionWait(tCExecution.getSession(), identifier.getLocator(), "");
            } else if (identifier != null && identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {
                return sikuliService.doSikuliActionWait(tCExecution.getSession(), "", identifier.getLocator());
            } else if (identifier != null) {
                identifierService.checkWebElementIdentifier(identifier.getIdentifier());
                return webdriverService.doSeleniumActionWait(tCExecution.getSession(), identifier);
            } else {
                return this.waitTime(timeToWaitInMs);
            }
        } else {
            // For any other application we wait for the integer value.
            if (StringUtil.isNullOrEmpty(element)) {
                // Get default wait from parameter
                timeToWaitInMs = tCExecution.getCerberus_action_wait_default();
            } else if (StringUtil.isInteger(element)) {
                timeToWaitInMs = Long.valueOf(element);
            }
            return this.waitTime(timeToWaitInMs);
        }
    } catch (CerberusEventException ex) {
        LOG.fatal("Error doing Action Wait :" + ex);
        return ex.getMessageError();
    }
}
Also used : CerberusEventException(org.cerberus.exception.CerberusEventException) Identifier(org.cerberus.engine.entity.Identifier) MessageEvent(org.cerberus.engine.entity.MessageEvent)

Example 28 with CerberusEventException

use of org.cerberus.exception.CerberusEventException in project cerberus-source by cerberustesting.

the class ActionService method doActionMouseOver.

private MessageEvent doActionMouseOver(TestCaseExecution tCExecution, String object, String property) {
    MessageEvent message;
    String element;
    try {
        /**
         * Get element to use String object if not empty, String property if
         * object empty, throws Exception if both empty)
         */
        element = getElementToUse(object, property, "mouseOver", tCExecution);
        /**
         * Get Identifier (identifier, locator)
         */
        Identifier identifier = identifierService.convertStringToIdentifier(element);
        if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
            if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {
                return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "");
            } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {
                return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator());
            } else {
                identifierService.checkWebElementIdentifier(identifier.getIdentifier());
                return webdriverService.doSeleniumActionMouseOver(tCExecution.getSession(), identifier);
            }
        } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {
            identifierService.checkSikuliIdentifier(identifier.getIdentifier());
            if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {
                return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), identifier.getLocator(), "");
            } else {
                return sikuliService.doSikuliActionMouseOver(tCExecution.getSession(), "", identifier.getLocator());
            }
        }
        message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
        message.setDescription(message.getDescription().replace("%ACTION%", "mouseOver"));
        message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));
        return message;
    } catch (CerberusEventException ex) {
        LOG.fatal("Error doing Action MouseOver :" + ex);
        return ex.getMessageError();
    }
}
Also used : CerberusEventException(org.cerberus.exception.CerberusEventException) Identifier(org.cerberus.engine.entity.Identifier) MessageEvent(org.cerberus.engine.entity.MessageEvent)

Example 29 with CerberusEventException

use of org.cerberus.exception.CerberusEventException in project cerberus-source by cerberustesting.

the class ActionService method doActionMouseLeftButtonPress.

private MessageEvent doActionMouseLeftButtonPress(TestCaseExecution tCExecution, String object, String property) {
    MessageEvent message;
    String element;
    try {
        /**
         * Get element to use String object if not empty, String property if
         * object empty, throws Exception if both empty)
         */
        element = getElementToUse(object, property, "mouseLeftButtonPress", tCExecution);
        /**
         * Get Identifier (identifier, locator)
         */
        Identifier identifier = identifierService.convertStringToIdentifier(element);
        identifierService.checkWebElementIdentifier(identifier.getIdentifier());
        if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
            return webdriverService.doSeleniumActionMouseDown(tCExecution.getSession(), identifier);
        }
        message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
        message.setDescription(message.getDescription().replace("%ACTION%", "MouseDown"));
        message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));
        return message;
    } catch (CerberusEventException ex) {
        LOG.fatal("Error doing Action MouseDown :" + ex);
        return ex.getMessageError();
    }
}
Also used : CerberusEventException(org.cerberus.exception.CerberusEventException) Identifier(org.cerberus.engine.entity.Identifier) MessageEvent(org.cerberus.engine.entity.MessageEvent)

Example 30 with CerberusEventException

use of org.cerberus.exception.CerberusEventException in project cerberus-source by cerberustesting.

the class ActionService method doActionOpenURL.

private MessageEvent doActionOpenURL(TestCaseExecution tCExecution, String object, String property, boolean withBase) {
    MessageEvent message;
    String element;
    try {
        /**
         * Get element to use String object if not empty, String property if
         * object empty, throws Exception if both empty)
         */
        element = getElementToUse(object, property, "openUrl[WithBase]", tCExecution);
        /**
         * Get Identifier (identifier, locator)
         */
        Identifier identifier = new Identifier();
        identifier.setIdentifier("url");
        identifier.setLocator(element);
        if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
            return webdriverService.doSeleniumActionOpenURL(tCExecution.getSession(), tCExecution.getUrl(), identifier, withBase);
        }
        message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
        message.setDescription(message.getDescription().replace("%ACTION%", "OpenURL[WithBase]"));
        message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));
        return message;
    } catch (CerberusEventException ex) {
        LOG.fatal("Error doing Action OpenUrl :" + ex);
        return ex.getMessageError();
    }
}
Also used : CerberusEventException(org.cerberus.exception.CerberusEventException) Identifier(org.cerberus.engine.entity.Identifier) MessageEvent(org.cerberus.engine.entity.MessageEvent)

Aggregations

CerberusEventException (org.cerberus.exception.CerberusEventException)36 MessageEvent (org.cerberus.engine.entity.MessageEvent)35 Identifier (org.cerberus.engine.entity.Identifier)15 AnswerItem (org.cerberus.util.answer.AnswerItem)11 ArrayList (java.util.ArrayList)7 CerberusException (org.cerberus.exception.CerberusException)7 Date (java.util.Date)6 MessageGeneral (org.cerberus.engine.entity.MessageGeneral)6 HashMap (java.util.HashMap)3 AppService (org.cerberus.crud.entity.AppService)3 CountryEnvironmentDatabase (org.cerberus.crud.entity.CountryEnvironmentDatabase)3 JSONException (org.json.JSONException)3 NoSuchElementException (org.openqa.selenium.NoSuchElementException)3 WebDriverException (org.openqa.selenium.WebDriverException)3 List (java.util.List)2 PatternSyntaxException (java.util.regex.PatternSyntaxException)2 TestCase (org.cerberus.crud.entity.TestCase)2 TestCaseExecution (org.cerberus.crud.entity.TestCaseExecution)2 TestCaseExecutionData (org.cerberus.crud.entity.TestCaseExecutionData)2 AnswerList (org.cerberus.util.answer.AnswerList)2