createDriver function
Future<AppiumWebDriver>
createDriver(
- AsyncRequestClient createRequestClient(
- Uri prefix
- Uri? uri,
- required Map<
String, dynamic> desired, - WebDriverSpec spec = WebDriverSpec.Auto,
Creates a new async WebDriver.
This is intended for internal use! Please use createDriver from async_io.dart.
Implementation
Future<AppiumWebDriver> createDriver(
AsyncRequestClient Function(Uri prefix) createRequestClient,
{Uri? uri,
required Map<String, dynamic> desired,
WebDriverSpec spec = WebDriverSpec.Auto}) async {
uri ??= defaultUri;
// This client's prefix at root, it has no session prefix in it.
final client = createRequestClient(uri);
final handler = getHandler(spec);
final session = await client.send(
handler.session.buildCreateRequest(desired: addAppiumPrefix(desired)),
handler.session.parseCreateResponse);
if (session.spec != WebDriverSpec.JsonWire &&
session.spec != WebDriverSpec.W3c) {
throw 'Unexpected spec: ${session.spec}';
}
var newUri = updateUriWithDirectConnect(uri, session.capabilities!);
return AppiumWebDriver(
newUri,
session.id,
UnmodifiableMapView(session.capabilities!),
createRequestClient(newUri.resolve('session/${session.id}/')),
session.spec);
}