Example usage for org.openqa.selenium.remote RemoteExecuteMethod execute

List of usage examples for org.openqa.selenium.remote RemoteExecuteMethod execute

Introduction

In this page you can find the example usage for org.openqa.selenium.remote RemoteExecuteMethod execute.

Prototype

@Override
    public Object execute(String commandName, Map<String, ?> parameters) 

Source Link

Usage

From source file:com.qmetry.qaf.automation.step.PerfectoMobileSteps.java

License:Open Source License

@QAFTestStep(description = "open {appname} application")
public static void openApplication(String appName) {
    // open application command
    String command = "mobile:application:open";
    // open application
    getDriver().executeScript(command, ImmutableMap.of("name", appName));
    RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(getDriver());
    executeMethod.execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", "NATIVE"));
}

From source file:com.qmetry.qaf.automation.step.PerfectoMobileSteps.java

License:Open Source License

@QAFTestStep(description = "switch to {context-name} context")
public static void switchToContext(String context) {
    RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(getDriver());
    executeMethod.execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", context));
}

From source file:com.qmetry.qaf.automation.step.PerfectoMobileSteps.java

License:Open Source License

public static String getCurrentContextHandle() {
    RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(getDriver());
    String context = (String) executeMethod.execute(DriverCommand.GET_CURRENT_CONTEXT_HANDLE, null);
    return context;
}

From source file:com.qmetry.qaf.automation.step.PerfectoMobileSteps.java

License:Open Source License

@SuppressWarnings("unchecked")
public static List<String> getContextHandles() {
    RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(getDriver());
    List<String> contexts = (List<String>) executeMethod.execute(DriverCommand.GET_CONTEXT_HANDLES, null);
    return contexts;
}

From source file:com.qmetry.qaf.automation.support.perfecto.PerfectoDriverListener.java

License:Open Source License

private void openApplication(QAFExtendedWebDriver driver, String appName) {
    PerfectoReportiumConnector.logTestStep("open '" + appName + "' application");
    // open application command
    String command = "mobile:application:open";
    // open application
    driver.executeScript(command, ImmutableMap.of("name", appName));
    RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(driver);
    executeMethod.execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", "NATIVE"));

}

From source file:org.xframium.device.factory.DeviceWebDriver.java

License:Open Source License

public WebDriver context(String newContext) {
    if (!contextSwitchSupported)
        return webDriver;

    if (newContext == null || newContext.equals(currentContext))
        return webDriver;

    if (webDriver != null) {

        if (webDriver instanceof RemoteWebDriver) {
            RemoteExecuteMethod executeMethod = new RemoteExecuteMethod((RemoteWebDriver) webDriver);
            Map<String, String> params = new HashMap<String, String>(5);
            params.put("name", newContext);
            executeMethod.execute(DriverCommand.SWITCH_TO_CONTEXT, params);
        } else if (webDriver instanceof AppiumDriver) {
            ((AppiumDriver) webDriver).context(newContext);
        } else//from   w  w  w  .  ja v a2  s .com
            return null;

        if (newContext.equals(_getContext()))
            currentContext = newContext;
        else
            throw new IllegalStateException(
                    "Could not change context to " + newContext + " against " + webDriver);
    }

    return webDriver;
}

From source file:org.xframium.device.factory.DeviceWebDriver.java

License:Open Source License

/**
 * _get context.//from  w  ww .  j av  a  2s . co  m
 *
 * @return the string
 */
private String _getContext() {
    if (webDriver != null) {
        try {
            if (webDriver instanceof RemoteWebDriver) {
                RemoteExecuteMethod executeMethod = new RemoteExecuteMethod((RemoteWebDriver) webDriver);
                return (String) executeMethod.execute(DriverCommand.GET_CURRENT_CONTEXT_HANDLE, null);
            } else if (webDriver instanceof AppiumDriver) {
                return ((AppiumDriver) webDriver).getContext();
            }
        } catch (Exception e) {
            log.warn("Context Switches are not supported - " + e.getMessage());
            contextSwitchSupported = false;
        }
    }

    return null;
}

From source file:org.xframium.device.factory.DeviceWebDriver.java

License:Open Source License

public Set<String> getContextHandles() {
    if (contextHandles != null)
        return contextHandles;

    RemoteExecuteMethod executeMethod = new RemoteExecuteMethod((RemoteWebDriver) webDriver);
    List<String> handleList = (List<String>) executeMethod.execute(DriverCommand.GET_CONTEXT_HANDLES, null);

    contextHandles = new HashSet<String>(10);
    contextHandles.addAll(handleList);/* w w w . ja  v  a 2 s .c  om*/
    return contextHandles;
}

From source file:org.xframium.utility.BrowserCacheLogic.java

License:Open Source License

private static void switchToContext(RemoteWebDriver driver, String context) {
    RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(driver);

    Map<String, String> params = new HashMap<>();
    params.put("name", context);

    executeMethod.execute(DriverCommand.SWITCH_TO_CONTEXT, params);
}

From source file:org.xframium.utility.BrowserCacheLogic.java

License:Open Source License

private static String getCurrentContextHandle(RemoteWebDriver driver) {
    RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(driver);

    String context = (String) executeMethod.execute(DriverCommand.GET_CURRENT_CONTEXT_HANDLE, null);

    return context;
}