fromExistingSessionSync function

WebDriver fromExistingSessionSync(
  1. AsyncRequestClient createRequestClient(
    1. Uri prefix
    ),
  2. String sessionId,
  3. WebDriverSpec spec, {
  4. Uri? uri,
  5. Map<String, dynamic>? capabilities,
})

Creates an async WebDriver from existing session with a sync function.

This will be helpful when you can't use async when creating WebDriver. For example in a consctructor.

This is intended for internal use! Please use fromExistingSessionSync from async_io.dart or async_html.dart.

Implementation

WebDriver fromExistingSessionSync(
    AsyncRequestClient Function(Uri prefix) createRequestClient,
    String sessionId,
    WebDriverSpec spec,
    {Uri? uri,
    Map<String, dynamic>? capabilities}) {
  uri ??= defaultUri;

  capabilities ??= Capabilities.empty;

  if (spec != WebDriverSpec.JsonWire && spec != WebDriverSpec.W3c) {
    throw 'Unexpected spec: $spec';
  }

  return WebDriver(uri, sessionId, UnmodifiableMapView(capabilities),
      createRequestClient(uri.resolve('session/$sessionId/')), spec);
}