Java Code Examples for org.openqa.selenium.remote.SessionId#toString()

The following examples show how to use org.openqa.selenium.remote.SessionId#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteSession.java    From selenium with Apache License 2.0 6 votes vote down vote up
protected RemoteSession(
    Dialect downstream,
    Dialect upstream,
    HttpHandler codec,
    SessionId id,
    Map<String, Object> capabilities) {
  this.downstream = Require.nonNull("Downstream dialect", downstream);
  this.upstream = Require.nonNull("Upstream dialect", upstream);
  this.codec = Require.nonNull("Codec", codec);
  this.id = Require.nonNull("Session id", id);
  this.capabilities = Require.nonNull("Capabilities", capabilities);

  File tempRoot = new File(StandardSystemProperty.JAVA_IO_TMPDIR.value(), id.toString());
  Require.stateCondition(tempRoot.mkdirs(), "Could not create directory %s", tempRoot);
  this.filesystem = TemporaryFilesystem.getTmpFsBasedOn(tempRoot);

  CommandExecutor executor = new ActiveSessionCommandExecutor(this);
  this.driver = new Augmenter().augment(new RemoteWebDriver(
      executor,
      new ImmutableCapabilities(getCapabilities())));
}
 
Example 2
Source File: AbstractHttpCommandCodec.java    From selenium with Apache License 2.0 5 votes vote down vote up
private String getParameter(
  String parameterName,
  String commandName,
  SessionId sessionId,
  Map<String, ?> parameters) {
  if ("sessionId".equals(parameterName)) {
    Require.argument("Session id", sessionId).nonNull("Session ID may not be null for command %s", commandName);
    return sessionId.toString();
  }

  Object value = parameters.get(parameterName);
  Require.argument("Parameter", value).nonNull(
      "Missing required parameter \"%s\" for command %s", parameterName, commandName);
  return Urls.urlEncode(String.valueOf(value));
}
 
Example 3
Source File: JsonTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldBeAbleToConvertASelenium3CommandToASelenium2Command() {
  SessionId expectedId = new SessionId("thisisakey");

  // In selenium 2, the sessionId is an object. In selenium 3, it's a straight string.
  String raw = "{\"sessionId\": \"" + expectedId.toString() + "\", " +
               "\"name\": \"some command\"," +
               "\"parameters\": {}}";

  Command converted = new Json().toType(raw, Command.class);

  assertThat(converted.getSessionId()).isEqualTo(expectedId);
}
 
Example 4
Source File: RedisBackedSessionMap.java    From selenium with Apache License 2.0 4 votes vote down vote up
private String uriKey(SessionId id) {
  Require.nonNull("Session ID", id);

  return "session:" + id.toString() + ":uri";
}
 
Example 5
Source File: RedisBackedSessionMap.java    From selenium with Apache License 2.0 4 votes vote down vote up
private String capabilitiesKey(SessionId id) {
  Require.nonNull("Session ID", id);

  return "session:" + id.toString() + ":capabilities";
}