fromExistingSessionSync function

AppiumWebDriver 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 constructor.

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

Implementation

AppiumWebDriver 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 AppiumWebDriver(uri, sessionId, UnmodifiableMapView(capabilities),
      createRequestClient(uri.resolve('session/$sessionId/')), spec);
}