Java 类org.openqa.selenium.remote.RemoteExecuteMethod 实例源码

项目:xframium-java    文件:DeviceWebDriver.java   
/**
 * _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;
}
项目:xframium-java    文件:DeviceWebDriver.java   
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;
}
项目:xframium-java    文件:DeviceWebDriver.java   
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;
}
项目:xframium-java    文件:BrowserCacheLogic.java   
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);
}
项目:xframium-java    文件:BrowserCacheLogic.java   
private static String getCurrentContextHandle(RemoteWebDriver driver)
{          
    RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(driver);

    String context =  (String) executeMethod.execute(DriverCommand.GET_CURRENT_CONTEXT_HANDLE, null);

    return context;
}
项目:selendroid    文件:SelendroidDriver.java   
private SelendroidDriver(CommandExecutor executor, Capabilities caps) throws Exception {
  super(executor, caps);
  RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(this);
  touchScreen = new RemoteTouchScreen(executeMethod);
  multiTouchScreen = new MultiTouchScreen(executeMethod);
  adbConnection = new RemoteAdbConnection(executeMethod);
  trackBall = new TrackBall(executeMethod);
}
项目:Quantum    文件:DeviceUtils.java   
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);
}
项目:Quantum    文件:DeviceUtils.java   
/**
 * @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);
}