All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.siwenyan.si.SiCommandExecutorOpen Maven / Gradle / Ivy

There is a newer version: 1.25.1.0
Show newest version
package com.github.siwenyan.si;

class SiCommandExecutorOpen extends SiCommandExecutor implements ISiCommandExecutorFlagUi {

    @Override
    public void execute(SiCommand command, SiContext siContext) throws SiVerifyException, SiWebDriverException {
        String target = command.getSiModelCommand().getTarget();
        target = siContext.dynamic(target, "", "");

        siContext.getReporter().reportMessage("url: " + target);
        String url = null;
        if (target.startsWith("http")) {
            url = target;
        } else {
            String baseUrl = siContext.getUrl();
            siContext.getReporter().reportMessage("endpoint: " + baseUrl + target);
            url = baseUrl + target;
        }

        try {
            siContext.asWebDriver().get(url);
            try {
                siContext.asWebDriver().switchTo().alert().accept();
            } catch (Exception e) {
                // do nothing
            }
        } catch (Exception e) {
            try {
                siContext.asWebDriver().switchTo().alert().accept();
            } catch (Exception e1) {
                //do nothing;
            }
            siContext.asWebDriver().get(url);
        }
    }

    @Override
    public void beforeExecute(SiCommand command, SiContext siContext) throws SiVerifyException, SiWebDriverException {
        super.beforeExecute(command, siContext);
        siContext.clearAlert();
    }

    @Override
    public void afterExecute(SiCommand command, SiContext siContext) throws SiVerifyException, SiWebDriverException {
        siContext.clearAlert();
        super.afterExecute(command, siContext);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy