org.openqa.selenium.remote.RemoteExecuteMethod Java Examples

The following examples show how to use org.openqa.selenium.remote.RemoteExecuteMethod. 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: DeviceWebDriver.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
/**
 * _get context.
 *
 * @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;
}
 
Example #2
Source File: LocalStorageProvider.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Override
public LocalStorage getLocalStorage()
{
    RemoteWebDriver driver = webDriverProvider.getUnwrapped(RemoteWebDriver.class);
    if (!webDriverManager.isTypeAnyOf(WebDriverType.SAFARI) && isWebStorageEnabled(driver))
    {
        return new RemoteLocalStorage(new RemoteExecuteMethod(driver));
    }
    return new JavascriptLocalStorage(javascriptActions);
}
 
Example #3
Source File: DeviceWebDriver.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public WebDriver context( String newContext )
{
    setLastAction();
    if ( !contextSwitchSupported )
        return webDriver;

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

    if ( webDriver != null )
    {

        if ( webDriver instanceof RemoteWebDriver )
        {
            log.info( "Switching context to " + newContext );
            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 )
        {
            log.info( "Switching context to " + newContext );
            ((AppiumDriver) webDriver).context( newContext );
        }
        else
            return null;

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

    return webDriver;
}
 
Example #4
Source File: DeviceWebDriver.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public Set<String> getContextHandles()
{
    setLastAction();
    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 );
    return contextHandles;
}
 
Example #5
Source File: BrowserCacheLogic.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #6
Source File: BrowserCacheLogic.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
private static String getCurrentContextHandle(RemoteWebDriver driver)
{          
    RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(driver);
    
    String context =  (String) executeMethod.execute(DriverCommand.GET_CURRENT_CONTEXT_HANDLE, null);
    
    return context;
}
 
Example #7
Source File: DeviceUtils.java    From Quantum with MIT License 4 votes vote down vote up
public static void switchToContext(String context) {
	RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(getQAFDriver());
	Map<String, String> params = new HashMap<String, String>();
	params.put("name", context);
	executeMethod.execute(DriverCommand.SWITCH_TO_CONTEXT, params);
}
 
Example #8
Source File: DeviceUtils.java    From Quantum with MIT License 4 votes vote down vote up
/**
 * @return the current context - "NATIVE_APP", "WEBVIEW", "VISUAL"
 */
public static String getCurrentContext() {
	RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(getQAFDriver());
	return (String) executeMethod.execute(DriverCommand.GET_CURRENT_CONTEXT_HANDLE, null);
}