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

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

Introduction

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

Prototype

String EXECUTE_ASYNC_SCRIPT

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

Click Source Link

Usage

From source file:com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver.java

License:Open Source License

@Override
public Object executeAsyncScript(String script, Object... args) {
    if (!getCapabilities().isJavascriptEnabled()) {
        throw new UnsupportedOperationException("You must be using an underlying instance of "
                + "WebDriver that supports executing javascript");
    }//from  w  ww  . j  ava  2 s .  com

    // Escape the quote marks
    script = script.replaceAll("\"", "\\\"");

    Iterable<Object> convertedArgs = Iterables.transform(Lists.newArrayList(args),
            new WebElementToJsonConverter());

    Map<String, ?> params = ImmutableMap.of("script", script, "args", Lists.newArrayList(convertedArgs));

    return execute(DriverCommand.EXECUTE_ASYNC_SCRIPT, params).getValue();
}