Example usage for org.openqa.selenium.remote DriverCommand SWITCH_TO_CONTEXT

List of usage examples for org.openqa.selenium.remote DriverCommand SWITCH_TO_CONTEXT

Introduction

In this page you can find the example usage for org.openqa.selenium.remote DriverCommand SWITCH_TO_CONTEXT.

Prototype

String SWITCH_TO_CONTEXT

To view the source code for org.openqa.selenium.remote DriverCommand SWITCH_TO_CONTEXT.

Click Source Link

Usage

From source file:com.mengge.AppiumDriver.java

License:Apache License

@Override
public WebDriver context(String name) {
    checkNotNull(name, "Must supply a context name");
    execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", name));
    return this;
}

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.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:io.appium.java_client.AppiumDriver.java

License:Apache License

@Override
public WebDriver context(String name) {
    if (!_isNotNullOrEmpty(name)) {
        throw new IllegalArgumentException("Must supply a context name");
    }/*  w w  w . j  a v a 2  s . c  o  m*/

    execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", name));
    return AppiumDriver.this;
}

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/* ww  w. j  a va2s .  co m*/
            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.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);
}