Search in sources :

Example 1 with Command

use of org.openqa.selenium.remote.Command in project flow by vaadin.

the class ChromeDeviceTest method setConnectionType.

/**
 * Change network connection type in the browser.
 *
 * @param connectionType
 *            the new connection type
 * @throws IOException
 */
protected void setConnectionType(NetworkConnection.ConnectionType connectionType) throws IOException {
    RemoteWebDriver driver = (RemoteWebDriver) ((TestBenchDriverProxy) getDriver()).getWrappedDriver();
    final Map<String, Integer> parameters = new HashMap<>();
    parameters.put("type", connectionType.hashCode());
    final Map<String, Object> connectionParams = new HashMap<>();
    connectionParams.put("parameters", parameters);
    Response response = driver.getCommandExecutor().execute(new Command(driver.getSessionId(), "setNetworkConnection", connectionParams));
    if (response.getStatus() != 0) {
        throw new RuntimeException("Unable to set connection type");
    }
}
Also used : Response(org.openqa.selenium.remote.Response) HashMap(java.util.HashMap) Command(org.openqa.selenium.remote.Command) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver)

Aggregations

HashMap (java.util.HashMap)1 Command (org.openqa.selenium.remote.Command)1 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)1 Response (org.openqa.selenium.remote.Response)1