Search in sources :

Example 1 with Identifier

use of org.cerberus.engine.entity.Identifier in project cerberus-source by cerberustesting.

the class ActionService method doActionManageDialog.

private MessageEvent doActionManageDialog(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, "manageDialog", tCExecution);
        /**
         * Get Identifier (identifier, locator)
         */
        Identifier identifier = identifierService.convertStringToIdentifier(element);
        identifierService.checkWebElementIdentifier(identifier.getIdentifier());
        if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
            return webdriverService.doSeleniumActionManageDialog(tCExecution.getSession(), identifier);
        }
        message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
        message.setDescription(message.getDescription().replace("%ACTION%", "ManageDialog"));
        message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));
        return message;
    } catch (CerberusEventException ex) {
        LOG.fatal("Error doing Action ManageDialog :" + ex);
        return ex.getMessageError();
    }
}
Also used : CerberusEventException(org.cerberus.exception.CerberusEventException) Identifier(org.cerberus.engine.entity.Identifier) MessageEvent(org.cerberus.engine.entity.MessageEvent)

Example 2 with Identifier

use of org.cerberus.engine.entity.Identifier in project cerberus-source by cerberustesting.

the class ActionService method doActionRightClick.

private MessageEvent doActionRightClick(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, "rightClick", 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.doSikuliActionRightClick(tCExecution.getSession(), identifier.getLocator(), "");
            } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {
                return sikuliService.doSikuliActionRightClick(tCExecution.getSession(), "", identifier.getLocator());
            } else {
                identifierService.checkWebElementIdentifier(identifier.getIdentifier());
                return webdriverService.doSeleniumActionRightClick(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.doSikuliActionRightClick(tCExecution.getSession(), identifier.getLocator(), "");
            } else {
                return sikuliService.doSikuliActionRightClick(tCExecution.getSession(), "", identifier.getLocator());
            }
        }
        message = new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION);
        message.setDescription(message.getDescription().replace("%ACTION%", "rightClick"));
        message.setDescription(message.getDescription().replace("%APPLICATIONTYPE%", tCExecution.getApplicationObj().getType()));
        return message;
    } catch (CerberusEventException ex) {
        LOG.fatal("Error doing Action RightClick :" + ex);
        return ex.getMessageError();
    }
}
Also used : CerberusEventException(org.cerberus.exception.CerberusEventException) Identifier(org.cerberus.engine.entity.Identifier) MessageEvent(org.cerberus.engine.entity.MessageEvent)

Example 3 with Identifier

use of org.cerberus.engine.entity.Identifier in project cerberus-source by cerberustesting.

the class ActionService method doActionSwitchToWindow.

private MessageEvent doActionSwitchToWindow(TestCaseExecution tCExecution, String object, String property) {
    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, "switchToWindow", tCExecution);
        /**
         * Get Identifier (identifier, locator)
         */
        Identifier identifier = identifierService.convertStringToIdentifier(element);
        if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
            return webdriverService.doSeleniumActionSwitchToWindow(tCExecution.getSession(), identifier);
        } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {
            return androidAppiumService.switchToContext(tCExecution.getSession(), identifier);
        } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {
            return iosAppiumService.switchToContext(tCExecution.getSession(), identifier);
        } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {
            return sikuliService.doSikuliActionSwitchApp(tCExecution.getSession(), identifier.getLocator());
        } else {
            return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION).resolveDescription("ACTION", "SwitchToWindow").resolveDescription("APPLICATIONTYPE", tCExecution.getApplicationObj().getType());
        }
    } catch (CerberusEventException ex) {
        LOG.fatal("Error doing Action SwitchToWindow :" + ex);
        return ex.getMessageError();
    }
}
Also used : CerberusEventException(org.cerberus.exception.CerberusEventException) Identifier(org.cerberus.engine.entity.Identifier) MessageEvent(org.cerberus.engine.entity.MessageEvent)

Example 4 with Identifier

use of org.cerberus.engine.entity.Identifier in project cerberus-source by cerberustesting.

the class ActionService method doActionClick.

private MessageEvent doActionClick(TestCaseExecution tCExecution, String value1, String value2) {
    String element;
    try {
        /**
         * Get element to use String object if not empty, String property if
         * object empty, throws Exception if both empty)
         */
        element = getElementToUse(value1, value2, TestCaseStepAction.ACTION_CLICK, tCExecution);
        /**
         * Get Identifier (identifier, locator) and check it's valid
         */
        Identifier identifier = identifierService.convertStringToIdentifier(element);
        if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
            if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {
                return sikuliService.doSikuliActionClick(tCExecution.getSession(), identifier.getLocator(), "");
            } else if (identifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_TEXT)) {
                return sikuliService.doSikuliActionClick(tCExecution.getSession(), "", identifier.getLocator());
            } else {
                identifierService.checkWebElementIdentifier(identifier.getIdentifier());
                return webdriverService.doSeleniumActionClick(tCExecution.getSession(), identifier, true, true);
            }
        } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)) {
            identifierService.checkWebElementIdentifier(identifier.getIdentifier());
            return androidAppiumService.click(tCExecution.getSession(), identifier);
        } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {
            identifierService.checkWebElementIdentifier(identifier.getIdentifier());
            return iosAppiumService.click(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.doSikuliActionClick(tCExecution.getSession(), identifier.getLocator(), "");
            } else {
                return sikuliService.doSikuliActionClick(tCExecution.getSession(), "", identifier.getLocator());
            }
        } else {
            return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION).resolveDescription("ACTION", "Click").resolveDescription("APPLICATIONTYPE", tCExecution.getApplicationObj().getType());
        }
    } catch (CerberusEventException ex) {
        LOG.fatal("Error doing Action Click :" + ex);
        return ex.getMessageError();
    }
}
Also used : CerberusEventException(org.cerberus.exception.CerberusEventException) Identifier(org.cerberus.engine.entity.Identifier) MessageEvent(org.cerberus.engine.entity.MessageEvent)

Example 5 with Identifier

use of org.cerberus.engine.entity.Identifier in project cerberus-source by cerberustesting.

the class ActionService method doActionKeyPress.

private MessageEvent doActionKeyPress(TestCaseExecution tCExecution, String value1, String value2) {
    try {
        String appType = tCExecution.getApplicationObj().getType();
        // if (appType.equalsIgnoreCase(Application.TYPE_APK) || appType.equalsIgnoreCase(Application.TYPE_IPA)) {
        if (StringUtil.isNullOrEmpty(value2)) {
            return new MessageEvent(MessageEventEnum.ACTION_FAILED_KEYPRESS_MISSINGKEY).resolveDescription("APPLICATIONTYPE", appType);
        }
        // } else if (appType.equalsIgnoreCase(Application.TYPE_GUI) || appType.equalsIgnoreCase(Application.TYPE_FAT)) {
        // if (StringUtil.isNullOrEmpty(value1) || StringUtil.isNullOrEmpty(value2)) {
        // return new MessageEvent(MessageEventEnum.ACTION_FAILED_KEYPRESS);
        // }
        // }
        /**
         * Get Identifier (identifier, locator)
         */
        Identifier objectIdentifier = identifierService.convertStringToIdentifier(value1);
        if (appType.equalsIgnoreCase(Application.TYPE_GUI)) {
            if (objectIdentifier.getIdentifier().equals(SikuliService.SIKULI_IDENTIFIER_PICTURE)) {
                return sikuliService.doSikuliActionKeyPress(tCExecution.getSession(), objectIdentifier.getLocator(), value2);
            } else {
                identifierService.checkWebElementIdentifier(objectIdentifier.getIdentifier());
                return webdriverService.doSeleniumActionKeyPress(tCExecution.getSession(), objectIdentifier, value2);
            }
        } else if (appType.equalsIgnoreCase(Application.TYPE_APK)) {
            return androidAppiumService.keyPress(tCExecution.getSession(), value2);
        } else if (appType.equalsIgnoreCase(Application.TYPE_IPA)) {
            return iosAppiumService.keyPress(tCExecution.getSession(), value2);
        } else if (appType.equalsIgnoreCase(Application.TYPE_FAT)) {
            return sikuliService.doSikuliActionKeyPress(tCExecution.getSession(), objectIdentifier.getLocator(), value2);
        } else {
            return new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED_NOTSUPPORTED_FOR_APPLICATION).resolveDescription("ACTION", "KeyPress").resolveDescription("APPLICATIONTYPE", appType);
        }
    } catch (CerberusEventException ex) {
        LOG.fatal("Error doing Action KeyPress :" + ex);
        return ex.getMessageError();
    }
}
Also used : CerberusEventException(org.cerberus.exception.CerberusEventException) Identifier(org.cerberus.engine.entity.Identifier) MessageEvent(org.cerberus.engine.entity.MessageEvent)

Aggregations

Identifier (org.cerberus.engine.entity.Identifier)31 MessageEvent (org.cerberus.engine.entity.MessageEvent)30 CerberusEventException (org.cerberus.exception.CerberusEventException)20 WebDriverException (org.openqa.selenium.WebDriverException)12 NoSuchElementException (org.openqa.selenium.NoSuchElementException)8 PatternSyntaxException (java.util.regex.PatternSyntaxException)5 AnswerItem (org.cerberus.util.answer.AnswerItem)2 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1