Java Code Examples for org.openqa.selenium.remote.RemoteWebDriver#executeScript()

The following examples show how to use org.openqa.selenium.remote.RemoteWebDriver#executeScript() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrowserService.java    From collect-earth with MIT License 6 votes vote down vote up
private boolean loadPlotInDGMap(SimplePlacemarkObject placemarkObject, RemoteWebDriver driver)
		throws InterruptedException {

	boolean success = true;
	if (driver != null && waitFor("mainContent", driver) && driver instanceof JavascriptExecutor) {
		try {
			String dgmapJs = getDGMapJavascript(placemarkObject);
			driver.executeScript(dgmapJs);

			Thread.sleep( 1000 );
			// Unlock the view if it is locked
			if( isCssElementPresent(".lock.on",  driver)  ) {
				driver.findElementByCssSelector(".lock.on").click(); // UNLOCK
			}

		} catch (final Exception e) {
			processSeleniumError(e);
			success = false;
		}
	}
	return success;
}
 
Example 2
Source File: BrowserCacheLogic.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
private static boolean clickIfPresent( RemoteWebDriver driver, String xpath )
{
    boolean rtn = false;

    HashMap<String, Object> params = new HashMap();
    params.put("value", xpath);
    params.put("framework", "perfectoMobile");

    String result = (String) driver.executeScript("mobile:application.element:find", params);

    if (( result != null ) && ( !( "false".equalsIgnoreCase( result ) )))
    {
        //
        // This shouldn't be necessary, but I'm seeing the 'find' call finding
        // elements that are scrolled off of the screen/page.
        //
        
        try
        {
            driver.executeScript("mobile:application.element:click", params);

            rtn = true;
        }
        catch( Throwable e )
        {}
    }

    return rtn;
}
 
Example 3
Source File: IosUtil.java    From agent with MIT License 4 votes vote down vote up
public static void uninstallApp(RemoteWebDriver driver, String bundleId) {
    driver.executeScript("mobile: removeApp", ImmutableMap.of("bundleId", bundleId));
}
 
Example 4
Source File: IosUtil.java    From agent with MIT License 4 votes vote down vote up
public static void launchApp(RemoteWebDriver driver, String bundleId) {
    driver.executeScript("mobile: launchApp", ImmutableMap.of("bundleId", bundleId));
}
 
Example 5
Source File: IosUtil.java    From agent with MIT License 4 votes vote down vote up
public static boolean terminateApp(RemoteWebDriver driver, String bundleId) {
    return (Boolean) driver.executeScript("mobile: terminateApp", ImmutableMap.of("bundleId", bundleId));
}
 
Example 6
Source File: IosUtil.java    From agent with MIT License 4 votes vote down vote up
public static void pressHome(RemoteWebDriver driver) {
    driver.executeScript("mobile:pressButton", ImmutableMap.of("name", "home"));
}
 
Example 7
Source File: AdfComponent.java    From adf-selenium with Apache License 2.0 4 votes vote down vote up
public static <T extends AdfComponent> T forElement(WebElement element) {
    RemoteWebElement rwe = (RemoteWebElement) element;
    RemoteWebDriver rwd = (RemoteWebDriver) rwe.getWrappedDriver();
    String clientid = (String) rwd.executeScript(JS_FIND_ANCESTOR_COMPONENT, element);
    return forClientId(rwd, clientid);
}