类org.openqa.selenium.remote.CommandInfo源码实例Demo

下面列出了怎么用org.openqa.selenium.remote.CommandInfo的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: neodymium-library   文件: BrowserRunnerHelper.java
/**
 * Returns an {@link HttpCommandExecutor} to a Selenium grid (e.g. SauceLabs) that contains basic authentication for
 * access
 * 
 * @param testEnvironment
 *            The {@link TestEnvironment} to the grid
 * @return {@link HttpCommandExecutor} to Selenium grid augmented with credentials
 * @throws MalformedURLException
 *             if the given gridUrl is invalid
 */
protected static HttpCommandExecutor createGridExecutor(String testEnvironment) throws MalformedURLException

{
    TestEnvironment testEnvironmentProperties = MultibrowserConfiguration.getInstance().getTestEnvironment(testEnvironment);

    if (testEnvironmentProperties == null)
    {
        throw new IllegalArgumentException("No properties found for test environment: \"" + testEnvironment + "\"");
    }

    final Map<String, CommandInfo> additionalCommands = new HashMap<String, CommandInfo>(); // just a dummy

    URL gridUrl = new URL(testEnvironmentProperties.getUrl());
    return new HttpCommandExecutor(additionalCommands, gridUrl, new NeodymiumProxyHttpClientFactory(testEnvironmentProperties));
}
 
源代码2 项目: selenium-shutterbug   文件: Browser.java
public BufferedImage takeScreenshotEntirePageUsingChromeCommand() {
    //should use devicePixelRatio by default as chrome command executor makes screenshot account for that
    Object devicePixelRatio = executeJsScript(DEVICE_PIXEL_RATIO);
    this.devicePixelRatio = devicePixelRatio instanceof Double ? (Double) devicePixelRatio : (Long) devicePixelRatio * 1.0;

    defineCustomCommand("sendCommand", new CommandInfo("/session/:sessionId/chromium/send_command_and_get_result", HttpMethod.POST));

    int verticalIterations = (int) Math.ceil(((double) this.getDocHeight()) / this.getViewportHeight());
    for (int j = 0; j < verticalIterations; j++) {
        this.scrollTo(0, j * this.getViewportHeight());
        wait(betweenScrollTimeout);
    }
    Object metrics = this.evaluate(FileUtil.getJsScript(ALL_METRICS));
    this.sendCommand("Emulation.setDeviceMetricsOverride", metrics);
    wait(beforeShootCondition,beforeShootTimeout);
    Object result = this.sendCommand("Page.captureScreenshot", ImmutableMap.of("format", "png", "fromSurface", true));
    this.sendCommand("Emulation.clearDeviceMetricsOverride", ImmutableMap.of());
    return decodeBase64EncodedPng((String) ((Map<String, ?>) result).get("data"));
}
 
源代码3 项目: selenium-shutterbug   文件: Browser.java
public BufferedImage takeScreenshotEntirePageUsingGeckoDriver() {
    // Check geckodriver version (>= 0.24.0 is requried)
    String version = (String) ((RemoteWebDriver) driver).getCapabilities().getCapability("moz:geckodriverVersion");
    if (version == null || Version.valueOf(version).satisfies("<0.24.0")) {
        return takeScreenshotEntirePageDefault();
    }
    defineCustomCommand("mozFullPageScreenshot", new CommandInfo("/session/:sessionId/moz/screenshot/full", HttpMethod.GET));
    Object result = this.executeCustomCommand("mozFullPageScreenshot");
    String base64EncodedPng;
    if (result instanceof String) {
        base64EncodedPng = (String) result;
    } else if (result instanceof byte[]) {
        base64EncodedPng = new String((byte[]) result);
    } else {
        throw new RuntimeException(String.format("Unexpected result for /moz/screenshot/full command: %s",
            result == null ? "null" : result.getClass().getName() + "instance"));
    }
    return decodeBase64EncodedPng(base64EncodedPng);
}
 
源代码4 项目: selenium-shutterbug   文件: Browser.java
private void defineCustomCommand(String name, CommandInfo info) {
    try {
        Method defineCommand = HttpCommandExecutor.class.getDeclaredMethod("defineCommand", String.class, CommandInfo.class);
        defineCommand.setAccessible(true);
        defineCommand.invoke(((RemoteWebDriver) this.driver).getCommandExecutor(), name, info);
    } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
}
 
源代码5 项目: java-client   文件: AppiumCommandExecutor.java
private AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands, DriverService service,
                              URL addressOfRemoteServer,
                              HttpClient.Factory httpClientFactory) {
    super(additionalCommands,
            ofNullable(service)
                    .map(DriverService::getUrl)
                    .orElse(addressOfRemoteServer), httpClientFactory);
    serviceOptional = ofNullable(service);
}
 
源代码6 项目: selenium   文件: ChromiumDriverCommandExecutor.java
private static Map<String, CommandInfo> buildChromiumCommandMappings(String vendorKeyword) {
  String sessionPrefix = "/session/:sessionId/";
  String chromiumPrefix = sessionPrefix + "chromium";
  String vendorPrefix = sessionPrefix + vendorKeyword;

  HashMap<String, CommandInfo> mappings = new HashMap<>();

  mappings.put(ChromiumDriverCommand.LAUNCH_APP,
    new CommandInfo(chromiumPrefix + "/launch_app", HttpMethod.POST));

  String networkConditions = chromiumPrefix + "/network_conditions";
  mappings.put(ChromiumDriverCommand.GET_NETWORK_CONDITIONS,
    new CommandInfo(networkConditions, HttpMethod.GET));
  mappings.put(ChromiumDriverCommand.SET_NETWORK_CONDITIONS,
    new CommandInfo(networkConditions, HttpMethod.POST));
  mappings.put(ChromiumDriverCommand.DELETE_NETWORK_CONDITIONS,
    new CommandInfo(networkConditions, HttpMethod.DELETE));

  mappings.put( ChromiumDriverCommand.EXECUTE_CDP_COMMAND,
    new CommandInfo(vendorPrefix + "/cdp/execute", HttpMethod.POST));

  // Cast / Media Router APIs
  String cast = vendorPrefix + "/cast";
  mappings.put(ChromiumDriverCommand.GET_CAST_SINKS,
    new CommandInfo(cast + "/get_sinks", HttpMethod.GET));
  mappings.put(ChromiumDriverCommand.SET_CAST_SINK_TO_USE,
    new CommandInfo(cast + "/set_sink_to_use", HttpMethod.POST));
  mappings.put(ChromiumDriverCommand.START_CAST_TAB_MIRRORING,
    new CommandInfo(cast + "/start_tab_mirroring", HttpMethod.POST));
  mappings.put(ChromiumDriverCommand.GET_CAST_ISSUE_MESSAGE,
    new CommandInfo(cast + "/get_issue_message", HttpMethod.GET));
  mappings.put(ChromiumDriverCommand.STOP_CASTING,
    new CommandInfo(cast + "/stop_casting", HttpMethod.POST));

  mappings.put(ChromiumDriverCommand.SET_PERMISSION,
    new CommandInfo(sessionPrefix + "/permissions", HttpMethod.POST));

  return unmodifiableMap(mappings);
}
 
源代码7 项目: carina   文件: EventFiringAppiumCommandExecutor.java
private EventFiringAppiumCommandExecutor(Map<String, CommandInfo> additionalCommands, DriverService service,
        URL addressOfRemoteServer,
        HttpClient.Factory httpClientFactory) {
    super(additionalCommands,
            ofNullable(service)
                    .map(DriverService::getUrl)
                    .orElse(addressOfRemoteServer),
            httpClientFactory);
    serviceOptional = ofNullable(service);
}
 
源代码8 项目: QVisual   文件: WebDriverManager.java
private static void setCommand(CommandExecutor executor) throws Exception {
    CommandInfo cmd = new CommandInfo("/session/:sessionId/chromium/send_command_and_get_result", POST);
    Method defineCommand = HttpCommandExecutor.class.getDeclaredMethod("defineCommand", String.class, CommandInfo.class);
    defineCommand.setAccessible(true);
    defineCommand.invoke(executor, "sendCommand", cmd);
}
 
源代码9 项目: java-client   文件: AppiumCommandExecutor.java
public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands, DriverService service,
                             HttpClient.Factory httpClientFactory) {
    this(additionalCommands, checkNotNull(service), null, httpClientFactory);
}
 
源代码10 项目: java-client   文件: AppiumCommandExecutor.java
public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
                             URL addressOfRemoteServer, HttpClient.Factory httpClientFactory) {
    this(additionalCommands, null, checkNotNull(addressOfRemoteServer), httpClientFactory);
}
 
源代码11 项目: java-client   文件: AppiumCommandExecutor.java
public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
                             URL addressOfRemoteServer) {
    this(additionalCommands, addressOfRemoteServer, HttpClient.Factory.createDefault());
}
 
源代码12 项目: java-client   文件: AppiumCommandExecutor.java
public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
                             DriverService service) {
    this(additionalCommands, service, HttpClient.Factory.createDefault());
}
 
源代码13 项目: java-client   文件: AppiumCommandExecutor.java
protected Map<String, CommandInfo> getAdditionalCommands() {
    //noinspection unchecked
    return getPrivateFieldValue("additionalCommands", Map.class);
}
 
源代码14 项目: carina   文件: EventFiringAppiumCommandExecutor.java
public EventFiringAppiumCommandExecutor(Map<String, CommandInfo> additionalCommands, DriverService service,
        HttpClient.Factory httpClientFactory) {
    this(additionalCommands, checkNotNull(service), null, httpClientFactory);
}
 
源代码15 项目: carina   文件: EventFiringAppiumCommandExecutor.java
public EventFiringAppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
        URL addressOfRemoteServer, HttpClient.Factory httpClientFactory) {
    this(additionalCommands, null, checkNotNull(addressOfRemoteServer), httpClientFactory);
}
 
源代码16 项目: carina   文件: EventFiringAppiumCommandExecutor.java
public EventFiringAppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
        URL addressOfRemoteServer) {
    this(additionalCommands, addressOfRemoteServer, new HttpClientFactoryCustom());
}
 
源代码17 项目: carina   文件: EventFiringAppiumCommandExecutor.java
public EventFiringAppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
        DriverService service) {
    this(additionalCommands, service, new HttpClientFactoryCustom());
}
 
源代码18 项目: carina   文件: EventFiringAppiumCommandExecutor.java
private Map<String, CommandInfo> getAdditionalCommands() {
    // noinspection unchecked
    return getPrivateFieldValue("additionalCommands", Map.class);
}
 
源代码19 项目: selenium   文件: DriverCommandExecutor.java
/**
 * Creates an {@link DriverCommandExecutor} that supports non-standard
 * {@code additionalCommands} in addition to the standard.
 *
 * @param service driver server
 * @param additionalCommands additional commands the remote end can process
 */
protected DriverCommandExecutor(
    DriverService service, Map<String, CommandInfo> additionalCommands) {
  super(additionalCommands, service.getUrl());
  this.service = service;
}
 
 类所在包
 同包方法