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

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

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

RemoteWebDriver.getSessionId介绍

暂无

代码示例

代码示例来源: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: appium/java-client

/**
 * Start logcat 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 startLogcatBroadcast(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/logcat",
        host, port, ((RemoteWebDriver) this).getSessionId()));
  } catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
  }
  getLogcatClient().connect(endpointUri);
}

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

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

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

private SessionId sessionIdOf(WebDriver driver) {
  if (driver instanceof RemoteWebDriver) {
    return ((RemoteWebDriver) driver).getSessionId();
  }
  return null;
}

代码示例来源:origin: com.infotel.seleniumRobot/core

public String getSessionId() {
  try {
    return ((RemoteWebDriver)driver).getSessionId().toString();
  } catch (ClassCastException e) {
    return UUID.randomUUID().toString();
  }
}

代码示例来源:origin: org.bitbucket.iamkenos/cissnei-selenium

public String getSessionId() {
  try {
    return ((RemoteWebDriver) webDriver).getSessionId().toString();
  } catch (Exception e) {
    LOGGER.error(e.getMessage());
    return EMPTY;
  }
}

代码示例来源:origin: com.infotel.seleniumRobot/grid-extensions

public String getSessionId() {
  try {
    return ((RemoteWebDriver)driver).getSessionId().toString();
  } catch (ClassCastException e) {
    return UUID.randomUUID().toString();
  }
}

代码示例来源:origin: com.applitools/eyes-selenium-java3

private String getSessionId() {
    // extract remote web driver information
    return driver.getSessionId().toString();
  }
}

代码示例来源:origin: bonigarcia/selenium-jupiter

public String getName() {
  String name = "";
  Optional<Method> testMethod = context.getTestMethod();
  if (testMethod.isPresent()) {
    name = testMethod.get().getName();
  }
  name += "_" + parameter.getName() + "_"
      + object.getClass().getSimpleName();
  if (RemoteWebDriver.class.isAssignableFrom(object.getClass())) {
    name += "_" + ((RemoteWebDriver) object).getSessionId();
  }
  return name;
}

代码示例来源: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: io.wcm.qa/io.wcm.qa.galenium.galenium

private void takeScreenshot(ITestResult result) {
 WebDriver driver = getDriver();
 if (driver != null && ((RemoteWebDriver)driver).getSessionId() != null) {
  GaleniumReportUtil.takeScreenshot(result, driver);
 }
}

代码示例来源:origin: org.jspringbot/jspringbot-selenium

public void fail() {
  if(failed) {
    return;
  }
  String sessionId = remoteWebDriver.getSessionId().toString();
  Map<String, Object> updates = new HashMap<String, Object>();
  updates.put("passed", false);
  Utils.addBuildNumberToUpdate(updates);
  this.sauceREST.updateJobInfo(sessionId, updates);
  failed = true;
}

代码示例来源:origin: io.wcm.qa/io.wcm.qa.galenium.listeners

private void takeScreenshot(ITestResult result) {
 WebDriver driver = getDriver();
 if (driver != null && ((RemoteWebDriver)driver).getSessionId() != null) {
  GaleniumReportUtil.takeScreenshot(result, driver);
 }
}

代码示例来源:origin: org.jspringbot/jspringbot-selenium

@Override
  public void close() {
    if(!failed) {
      String sessionId = remoteWebDriver.getSessionId().toString();
      Map<String, Object> updates = new HashMap<String, Object>();
      updates.put("passed", true);
      Utils.addBuildNumberToUpdate(updates);
      this.sauceREST.updateJobInfo(sessionId, updates);
      String authLink = this.sauceREST.getPublicJobLink(sessionId);
      System.out.println("Job link: " + authLink);
    }
  }
}

代码示例来源:origin: com.applitools/eyes-selenium-java3

@Override
protected String getAUTSessionId() {
  try {
    if (this.cachedAUTSessionId == null) {
      this.cachedAUTSessionId = driver.getRemoteWebDriver().getSessionId().toString();
    }
    return this.cachedAUTSessionId;
  } catch (Exception e) {
    logger.log("WARNING: Failed to get AUT session ID! (maybe driver is not available?). Error: "
        + e.getMessage());
    return "";
  }
}

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

public SessionId getSessionId() {
  WebDriver driver = getThreadLocalWebDriver(configuration, webDriverFactory,
                        inThisTestThread().getCurrentDriverName());
  if (driver instanceof RemoteWebDriver) {
    return ((RemoteWebDriver) driver).getSessionId();
  }
  return null;
}

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

public SessionId getSessionId() {
  WebDriver driver = getThreadLocalWebDriver(configuration, webDriverFactory,
                        inThisTestThread().getCurrentDriverName());
  if (driver instanceof RemoteWebDriver) {
    return ((RemoteWebDriver) driver).getSessionId();
  }
  return null;
}

代码示例来源:origin: paypal/SeLion

private String getSessionId() {
  logger.entering();
  String sessionId = Grid.driver().getSessionId().toString();
  logger.exiting(sessionId);
  return sessionId;
}

代码示例来源: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: org.uiautomation/ios-client

@Override
public JSONObject logElementTree(File screenshot, boolean translation) throws Exception {
 WebDriverLikeCommand command = WebDriverLikeCommand.TREE;
 Path
   p =
   new Path(command).withSession(getDriver().getSessionId()).withReference(getReference());
 return logElementTree(screenshot, translation, p, command, getDriver());
}

相关文章