org.openqa.selenium.remote.RemoteWebDriver类的使用及代码示例

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

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

RemoteWebDriver介绍

暂无

代码示例

代码示例来源:origin: galenframework/galen

@Override
public Browser openBrowser() {
  
  try {
    
    WebDriver driver = new RemoteWebDriver(new URL(gridUrl), this.createCapabilities());
    WebDriver augmentedDriver = new Augmenter().augment(driver);
    return new SeleniumBrowser(augmentedDriver);
  }
  catch (Exception ex) {
    throw new RuntimeException(ex);
  }
}

代码示例来源:origin: testcontainers/testcontainers-java

protected void assertBrowserNameIs(BrowserWebDriverContainer rule, String expectedName) {
  RemoteWebDriver driver = setupDriverFromRule(rule);
  String actual = driver.getCapabilities().getBrowserName();
  assertTrue(format("actual browser name is %s", actual),
    actual.equals(expectedName));
}

代码示例来源:origin: testcontainers/testcontainers-java

@Test
  public void testWebDriverToNginxContainerAccessViaContainerLink() {
    RemoteWebDriver driver = chrome.getWebDriver();

    driver.get("http://nginx/");

    assertEquals("Using selenium, an HTTP GET from the nginx server returns the index.html from the custom content directory", "This worked", driver.findElement(By.tagName("body")).getText());
  }
}

代码示例来源:origin: selenide/selenide

private WebDriver createRemoteDriver(Config config, Proxy proxy) {
 try {
  DesiredCapabilities capabilities = getDriverCapabilities(config, new Browser(config.browser(), false), proxy);
  RemoteWebDriver webDriver = new RemoteWebDriver(new URL(config.remote()), capabilities);
  webDriver.setFileDetector(new LocalFileDetector());
  return webDriver;
 } catch (MalformedURLException e) {
  throw new IllegalArgumentException("Invalid 'remote' parameter: " + config.remote(), e);
 }
}

代码示例来源:origin: testcontainers/testcontainers-java

@Test
  public void testContainerRunningAgainstExposedHostPort() {
    // useHostExposedPort {
    final String rootUrl =
      String.format("http://host.testcontainers.internal:%d/", localServerPort);

    final RemoteWebDriver webDriver = browser.getWebDriver();
    webDriver.get(rootUrl);
    // }

    final String pageSource = webDriver.getPageSource();
    assertTrue(pageSource.contains("Hello World!"));
  }
}

代码示例来源:origin: testcontainers/testcontainers-java

protected static void doSimpleExplore(BrowserWebDriverContainer rule) {
  RemoteWebDriver driver = setupDriverFromRule(rule);
  driver.get("http://en.wikipedia.org/wiki/Randomness");
  // Oh! The irony!
  assertTrue("Randomness' description has the word 'pattern'", driver.findElementByPartialLinkText("pattern").isDisplayed());
}

代码示例来源:origin: com.synaptix.redpepper/redpepper-automation

public RemoteWebDriver getRemoteDriver(boolean canTakeScreenShots) throws MalformedURLException {
  RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), DesiredCapabilities.firefox());
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  // if(canTakeScreenShots){
  // WebDriver augmentedDriver = new Augmenter().augment(driver);
  // File screenshot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
  // }
  return driver;
}

代码示例来源:origin: appium/java-client

/**
 * Start syslog messages broadcast via web socket.
 *
 * @param host the name of the host where Appium server is running
 * @param port the port of the host where Appium server is running
 */
default void startSyslogBroadcast(String host, int port) {
  execute(EXECUTE_SCRIPT, ImmutableMap.of("script", "mobile: startLogsBroadcast",
      "args", Collections.emptyList()));
  final URI endpointUri;
  try {
    endpointUri = new URI(String.format("ws://%s:%s/ws/session/%s/appium/device/syslog",
        host, port, ((RemoteWebDriver) this).getSessionId()));
  } catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
  }
  getSyslogClient().connect(endpointUri);
}

代码示例来源:origin: UKPLab/argument-reasoning-comprehension-task

public DebateFetcher(String chromeDriverFile)
    throws IOException
{
  service = new ChromeDriverService.Builder()
      .usingDriverExecutable(
          new File(chromeDriverFile))
      .usingAnyFreePort()
      .withEnvironment(ImmutableMap.of("DISPLAY", ":20")).build();
  service.start();
  DesiredCapabilities capabilities = DesiredCapabilities.chrome();
  driver = new RemoteWebDriver(service.getUrl(), capabilities);
}

代码示例来源:origin: org.rapidpm/testbench-ng-m-webdriver

static Function<RemoteWebDriver, String> formatRemoteWebDriverName() {
 return (webDriver) -> webDriver.getCapabilities().getBrowserName()
            + " "
            + webDriver.getCapabilities().getVersion()
            + " / "
            + webDriver.getCapabilities().getPlatform();
}

代码示例来源:origin: testcontainers/testcontainers-java

@Override
protected void containerIsStarted(InspectContainerResponse containerInfo) {
  driver = Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS,
      Timeouts.getWithTimeout(10, TimeUnit.SECONDS,
          () ->
            () -> new RemoteWebDriver(getSeleniumAddress(), capabilities)));
  if (vncRecordingContainer != null) {
    LOGGER.debug("Starting VNC recording");
    vncRecordingContainer.start();
  }
}

代码示例来源:origin: com.github.becauseQA/becauseQA-utils

@Override
public String toString() {
 Capabilities caps = getCapabilities();
 if (caps == null) {
  return super.toString();
 }
 return String.format("%s: %s on %s (%s)", getClass().getSimpleName(),
   caps.getBrowserName(), caps.getPlatform(), getSessionId());
}

代码示例来源:origin: net.serenity-bdd/core

public WebDriver newRemoteDriver(URL remoteUrl, Capabilities capabilities) {
  RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, capabilities);
  driverProperties.registerCapabilities("remote", driver.getCapabilities());
  return driver;
}

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

@Override
public SessionId getSessionId()
{
  return this.wrappedDriver.getSessionId();
}

代码示例来源:origin: com.github.becauseQA/becauseQA-utils

.setName(String.format("Forwarding %s on session %s to remote", driverCommand, sessionId));
try {
  log(sessionId, command.getName(), command, When.BEFORE);
  response = executor.execute(command);
  log(sessionId, command.getName(), command, When.AFTER);
  Object value = converter.apply(response.getValue());
  response.setValue(value);
} catch (NoSuchSessionException e) {
  throw e;
} catch (Exception e) {
  log(sessionId, command.getName(), command, When.EXCEPTION);
  String errorMessage = "Error communicating with the remote browser. " + "It may have died.";
  if (driverCommand.equals(DriverCommand.NEW_SESSION)) {
  if (getSessionId() != null) {
    ube.addInfo(WebDriverException.SESSION_ID, getSessionId().toString());
  if (getCapabilities() != null) {
    ube.addInfo("Capabilities", getCapabilities().toString());
  if (getSessionId() != null) {
    ex.addInfo(WebDriverException.SESSION_ID, getSessionId().toString());
  if (getCapabilities() != null) {
    ex.addInfo("Capabilities", getCapabilities().toString());

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

public BrowserTestRule(WebDriver driver)
{
  Capabilities capability = ((RemoteWebDriver) driver).getCapabilities();
  // We get the name of the current user Browser
  this.currentBrowserName = capability.getBrowserName();
  // We get the version of the current used Browser
  this.currentBrowserVersion = capability.getVersion();
}

代码示例来源:origin: testcontainers/testcontainers-java

@Override
public void stop() {
  if (driver != null) {
    try {
      driver.quit();
    } catch (Exception e) {
      LOGGER.debug("Failed to quit the driver", e);
    }
  }
  if (vncRecordingContainer != null) {
    try {
      vncRecordingContainer.stop();
    } catch (Exception e) {
      LOGGER.debug("Failed to stop vncRecordingContainer", e);
    }
  }
  super.stop();
}

代码示例来源:origin: la-team/light-admin

@Override
public void get(final String url) {
  webDriver.get(url);
}

代码示例来源:origin: org.seleniumhq.webdriver/webdriver-remote-client

private void amendElementValueIfNecessary(Response response) {
 if (!(response.getValue() instanceof RemoteWebElement))
  return;
 // Ensure that the parent is set properly
 RemoteWebElement existingElement = (RemoteWebElement) response.getValue();
 existingElement.setParent(this);
 if (!getCapabilities().isJavascriptEnabled())
  return;
 if (response.getValue() instanceof RenderedRemoteWebElement)
  return;  // Good, nothing to do
 RenderedRemoteWebElement replacement = new RenderedRemoteWebElement();
 replacement.setId(existingElement.getId());
 replacement.setParent(this);
 response.setValue(replacement);
}

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

/**
 * Returns device information from Grid Hub using STF service.
 * 
 * @param drv
 *            - driver
 * @return remote device information
 */
@SuppressWarnings("unchecked")
private RemoteDevice getDeviceInfo(RemoteWebDriver drv) {
  return getDeviceInfo((Map<String, Object>) drv.getCapabilities().getCapability(SpecialKeywords.SLOT_CAPABILITIES));
}

相关文章