当前位置: 首页>>代码示例>>Java>>正文


Java DriverCommand类代码示例

本文整理汇总了Java中org.openqa.selenium.remote.DriverCommand的典型用法代码示例。如果您正苦于以下问题:Java DriverCommand类的具体用法?Java DriverCommand怎么用?Java DriverCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DriverCommand类属于org.openqa.selenium.remote包,在下文中一共展示了DriverCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeAsyncScript

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
@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");
	}

	// 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();
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:17,代码来源:QAFExtendedWebDriver.java

示例2: executeScript

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
@Override
public Object executeScript(String script, Object... args) {
	if (!getCapabilities().isJavascriptEnabled()) {
		throw new UnsupportedOperationException(
				"You must be using an underlying instance of WebDriver that supports executing javascript");
	}

	// 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_SCRIPT, params).getValue();
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:17,代码来源:QAFExtendedWebDriver.java

示例3: execute

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
@Override
public Response execute(Command command) throws IOException {
    Response response;
    if (DriverCommand.QUIT.equals(command.getName())) {
        response = grid.execute(command);
    } else {
        response = node.execute(command);
    }
    return response;
}
 
开发者ID:RationaleEmotions,项目名称:talk2grid,代码行数:11,代码来源:CustomCommandExecutor.java

示例4: context

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
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;
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:37,代码来源:DeviceWebDriver.java

示例5: _getContext

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
/**
 * _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;
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:31,代码来源:DeviceWebDriver.java

示例6: getContextHandles

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
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;
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:14,代码来源:DeviceWebDriver.java

示例7: switchToContext

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
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);
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:10,代码来源:BrowserCacheLogic.java

示例8: getCurrentContextHandle

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
private static String getCurrentContextHandle(RemoteWebDriver driver)
{          
    RemoteExecuteMethod executeMethod = new RemoteExecuteMethod(driver);
    
    String context =  (String) executeMethod.execute(DriverCommand.GET_CURRENT_CONTEXT_HANDLE, null);
    
    return context;
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:9,代码来源:BrowserCacheLogic.java

示例9: getContextHandles

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
@Override public Set<String> getContextHandles() {
    Response response = execute(DriverCommand.GET_CONTEXT_HANDLES);
    Object value = response.getValue();
    try {
        List<String> returnedValues = (List<String>) value;
        return new LinkedHashSet<>(returnedValues);
    } catch (ClassCastException ex) {
        throw new WebDriverException(
            "Returned value cannot be converted to List<String>: " + value, ex);
    }
}
 
开发者ID:JoeUtt,项目名称:menggeqa,代码行数:12,代码来源:AppiumDriver.java

示例10: getContext

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
@Override public String getContext() {
    String contextName =
        String.valueOf(execute(DriverCommand.GET_CURRENT_CONTEXT_HANDLE).getValue());
    if (contextName.equals("null")) {
        return null;
    }
    return contextName;
}
 
开发者ID:JoeUtt,项目名称:menggeqa,代码行数:9,代码来源:AppiumDriver.java

示例11: getOrientation

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
@Override public ScreenOrientation getOrientation() {
    Response response = execute(DriverCommand.GET_SCREEN_ORIENTATION);
    String orientation = response.getValue().toString().toLowerCase();
    if (orientation.equals(ScreenOrientation.LANDSCAPE.value())) {
        return ScreenOrientation.LANDSCAPE;
    } else if (orientation.equals(ScreenOrientation.PORTRAIT.value())) {
        return ScreenOrientation.PORTRAIT;
    } else {
        throw new WebDriverException("Unexpected orientation returned: " + orientation);
    }
}
 
开发者ID:JoeUtt,项目名称:menggeqa,代码行数:12,代码来源:AppiumDriver.java

示例12: execute

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
@Override public Response execute(Command command) throws IOException, WebDriverException {
    if (DriverCommand.NEW_SESSION.equals(command.getName()) && service != null) {
        service.start();
    }

    try {
        return super.execute(command);
    } catch (Throwable t) {
        Throwable rootCause = Throwables.getRootCause(t);
        if (rootCause instanceof ConnectException
            && rootCause.getMessage().contains("Connection refused")
            && service != null) {
            if (service.isRunning()) {
                throw new WebDriverException("The session is closed!", t);
            }

            if (!service.isRunning()) {
                throw new WebDriverException("The appium server has accidentally died!", t);
            }
        }
        Throwables.propagateIfPossible(t);
        throw new WebDriverException(t);
    } finally {
        if (DriverCommand.QUIT.equals(command.getName()) && service != null) {
            service.stop();
        }
    }
}
 
开发者ID:JoeUtt,项目名称:menggeqa,代码行数:29,代码来源:AppiumCommandExecutor.java

示例13: execute

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
@Override
protected Response execute(String driverCommand, Map<String, ?> parameters) {
	if (driverCommand.equalsIgnoreCase(DriverCommand.QUIT)) {
		return new Response();
	}
	return super.execute(driverCommand, parameters);
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:8,代码来源:LiveIsExtendedWebDriver.java

示例14: getScreenshotAs

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
@Override
public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException {
	Object takeScreenshot =
			getCapabilities().getCapability(CapabilityType.TAKES_SCREENSHOT);
	if (null == takeScreenshot || (Boolean) takeScreenshot) {
		String base64Str = execute(DriverCommand.SCREENSHOT).getValue().toString();
		return target.convertFromBase64Png(base64Str);
	}
	return null;
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:11,代码来源:QAFExtendedWebDriver.java

示例15: getScreenshotAs

import org.openqa.selenium.remote.DriverCommand; //导入依赖的package包/类
public <X> X getScreenshotAs(final OutputType<X> target) throws WebDriverException {
    if ((Boolean) getCapabilities().getCapability(CapabilityType.TAKES_SCREENSHOT)) {
        String output = execute(DriverCommand.SCREENSHOT).getValue().toString();
        return target.convertFromBase64Png(output);
    }

    return null;
}
 
开发者ID:tarun3kumar,项目名称:seleniumtestsframework,代码行数:9,代码来源:ScreenShotRemoteWebDriver.java


注:本文中的org.openqa.selenium.remote.DriverCommand类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。