org.openqa.selenium.remote.RemoteWebDriver.getCommandExecutor()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中org.openqa.selenium.remote.RemoteWebDriver.getCommandExecutor方法的一些代码示例,展示了RemoteWebDriver.getCommandExecutor的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RemoteWebDriver.getCommandExecutor方法的具体详情如下:
包路径:org.openqa.selenium.remote.RemoteWebDriver
类名称:RemoteWebDriver
方法名:getCommandExecutor

RemoteWebDriver.getCommandExecutor介绍

暂无

代码示例

代码示例来源:origin: com.machinepublishers/jbrowserdriver

/**
 * {@inheritDoc}
 */
@Override
public CommandExecutor getCommandExecutor() {
 return super.getCommandExecutor();
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

@Override
public CommandExecutor getCommandExecutor()
{
  return this.wrappedDriver.getCommandExecutor();
}

代码示例来源:origin: org.uiautomation/ios-client

public WebDriverLikeCommandExecutor(RemoteWebDriver driver) {
 URL remoteServer;
 if (driver.getCommandExecutor() instanceof HttpCommandExecutor) {
  HttpCommandExecutor exe = (HttpCommandExecutor) driver.getCommandExecutor();
  remoteServer = exe.getAddressOfRemoteServer();
 } else {
  throw new WebDriverException("ios driver only supports http communication.");
 }
 this.remoteURL = remoteServer;
 this.driver = driver;
}

代码示例来源:origin: com.vaadin/vaadin-testbench-core

@Override
public String getRemoteControlName() {
  InetAddress ia = null;
  try {
    WebDriver realDriver = driver.getWrappedDriver();
    if (realDriver instanceof RemoteWebDriver) {
      RemoteWebDriver rwd = (RemoteWebDriver) realDriver;
      if (rwd.getCommandExecutor() instanceof HttpCommandExecutor) {
        ia = InetAddress.getByName(
            ((HttpCommandExecutor) rwd.getCommandExecutor())
                .getAddressOfRemoteServer().getHost());
      }
    } else {
      ia = InetAddress.getLocalHost();
    }
  } catch (UnknownHostException e) {
    getLogger().log(Level.WARNING,
        "Could not find name of remote control", e);
    return "unknown";
  }
  if (ia != null) {
    return String.format("%s (%s)", ia.getCanonicalHostName(),
        ia.getHostAddress());
  }
  return null;
}

代码示例来源:origin: org.uiautomation/ios-client

public static RemoteIOSDriver getIOSDriver(RemoteWebDriver driver) {
  if (!(driver.getCommandExecutor() instanceof HttpCommandExecutor)) {
   throw new WebDriverException("ios only supports http communication.");
  }
  HttpCommandExecutor e = (HttpCommandExecutor) driver.getCommandExecutor();
  RemoteIOSDriver
    attach =
    new AttachRemoteIOSDriver(e.getAddressOfRemoteServer(), driver.getSessionId());
  return attach;
 }
}

代码示例来源:origin: qaprosoft/carina

@Override
public String getVncURL(WebDriver driver) {
  String vncURL = null;
  if (driver instanceof RemoteWebDriver && "true".equals(Configuration.getCapability("enableVNC"))) {
    // TODO: resolve negative case when VNC is not supported
    final RemoteWebDriver rwd = (RemoteWebDriver) driver;
    String protocol = R.CONFIG.get(vnc_protocol);
    String host = R.CONFIG.get(vnc_host);
    String port = R.CONFIG.get(vnc_port); 
    // If VNC host/port not set user them from Selenim
    if(StringUtils.isEmpty(host) || StringUtils.isEmpty(port)) {
      host = ((HttpCommandExecutor) rwd.getCommandExecutor()).getAddressOfRemoteServer().getHost();
      port = String.valueOf(((HttpCommandExecutor) rwd.getCommandExecutor()).getAddressOfRemoteServer().getPort());
    }
    vncURL = String.format(R.CONFIG.get("vnc_desktop"), protocol, host, port, rwd.getSessionId().toString());
  }
  return vncURL;
}

代码示例来源:origin: com.assertthat/selenium-shutterbug

public BufferedImage takeScreenshotEntirePageUsingChromeCommand() {
  this.driver = getDriverAfterValidation(this.driver);
  try {
    CommandInfo cmd = new CommandInfo("/session/:sessionId/chromium/send_command_and_get_result", HttpMethod.POST);
    Method defineCommand = HttpCommandExecutor.class.getDeclaredMethod("defineCommand", String.class, CommandInfo.class);
    defineCommand.setAccessible(true);
    defineCommand.invoke(((RemoteWebDriver) this.driver).getCommandExecutor(), "sendCommand", cmd);
  } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
    throw new RuntimeException(e);
  }
  int verticalIterations = (int) Math.ceil(((double) this.getDocHeight()) / this.getViewportHeight());
  for (int j = 0; j < verticalIterations; j++) {
    this.scrollTo(0, j * this.getViewportHeight());
    wait(scrollTimeout);
  }
  Object metrics = this.evaluate(FileUtil.getJsScript(ALL_METRICS));
  this.sendCommand("Emulation.setDeviceMetricsOverride", metrics);
  Object result = this.sendCommand("Page.captureScreenshot", ImmutableMap.of("format", "png", "fromSurface", true));
  String base64EncodedPng = (String) ((Map<String, ?>) result).get("data");
  InputStream in = new ByteArrayInputStream(OutputType.BYTES.convertFromBase64Png(base64EncodedPng));
  BufferedImage bImageFromConvert;
  try {
    bImageFromConvert = ImageIO.read(in);
  } catch (IOException e) {
    throw new RuntimeException("Error while converting results from bytes to BufferedImage");
  }
  return bImageFromConvert;
}

代码示例来源:origin: assertthat/selenium-shutterbug

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;
  try {
    CommandInfo cmd = new CommandInfo("/session/:sessionId/chromium/send_command_and_get_result", HttpMethod.POST);
    Method defineCommand = HttpCommandExecutor.class.getDeclaredMethod("defineCommand", String.class, CommandInfo.class);
    defineCommand.setAccessible(true);
    defineCommand.invoke(((RemoteWebDriver) this.driver).getCommandExecutor(), "sendCommand", cmd);
  } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
    throw new RuntimeException(e);
  }
  int verticalIterations = (int) Math.ceil(((double) this.getDocHeight()) / this.getViewportHeight());
  for (int j = 0; j < verticalIterations; j++) {
    this.scrollTo(0, j * this.getViewportHeight());
    wait(scrollTimeout);
  }
  Object metrics = this.evaluate(FileUtil.getJsScript(ALL_METRICS));
  this.sendCommand("Emulation.setDeviceMetricsOverride", metrics);
  Object result = this.sendCommand("Page.captureScreenshot", ImmutableMap.of("format", "png", "fromSurface", true));
  String base64EncodedPng = (String) ((Map<String, ?>) result).get("data");
  InputStream in = new ByteArrayInputStream(OutputType.BYTES.convertFromBase64Png(base64EncodedPng));
  BufferedImage bImageFromConvert;
  try {
    bImageFromConvert = ImageIO.read(in);
  } catch (IOException e) {
    throw new RuntimeException("Error while converting results from bytes to BufferedImage");
  }
  return bImageFromConvert;
}

代码示例来源:origin: org.jboss.arquillian.extension/arquillian-drone-webdriver

/**
 * Creates the {@link ReusableRemoteWebDriver} from valid {@link RemoteWebDriver} instance.
 *
 * @param remoteWebDriver
 *     valid {@link RemoteWebDriver} instance.
 *
 * @return the {@link RemoteWebDriver} wrapped as {@link ReusableRemoteWebDriver}
 */
public static RemoteWebDriver fromRemoteWebDriver(RemoteWebDriver remoteWebDriver) {
  RemoteWebDriver driver = new ReusableRemoteWebDriver(remoteWebDriver.getCommandExecutor(),
    remoteWebDriver.getCapabilities(), remoteWebDriver.getSessionId());
  try {
    checkReusability(remoteWebDriver.getSessionId(), driver);
    return driver;
  } catch (UnableReuseSessionException e) {
    throw new IllegalStateException("Reusing RemoteWebDriver session unexpectedly failed", e);
  }
}

代码示例来源:origin: arquillian/arquillian-extension-drone

/**
 * Creates the {@link ReusableRemoteWebDriver} from valid {@link RemoteWebDriver} instance.
 *
 * @param remoteWebDriver
 *     valid {@link RemoteWebDriver} instance.
 *
 * @return the {@link RemoteWebDriver} wrapped as {@link ReusableRemoteWebDriver}
 */
public static RemoteWebDriver fromRemoteWebDriver(RemoteWebDriver remoteWebDriver) {
  RemoteWebDriver driver = new ReusableRemoteWebDriver(remoteWebDriver.getCommandExecutor(),
    remoteWebDriver.getCapabilities(), remoteWebDriver.getSessionId());
  try {
    checkReusability(remoteWebDriver.getSessionId(), driver);
    return driver;
  } catch (UnableReuseSessionException e) {
    throw new IllegalStateException("Reusing RemoteWebDriver session unexpectedly failed", e);
  }
}

相关文章