fromExistingSession function
Future<AppiumWebDriver>
fromExistingSession(
- AsyncRequestClient createRequestClient(
- Uri prefix
- String sessionId, {
- Uri? uri,
- WebDriverSpec spec = WebDriverSpec.Auto,
Creates a sync WebDriver from existing session.
This is intended for internal use! Please use fromExistingSession from sync_io.dart.
Implementation
Future<AppiumWebDriver> fromExistingSession(
AsyncRequestClient Function(Uri prefix) createRequestClient,
String sessionId,
{Uri? uri,
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.buildInfoRequest(sessionId),
handler.session.parseInfoResponse);
if (session.spec != WebDriverSpec.JsonWire &&
session.spec != WebDriverSpec.W3c) {
throw 'Unexpected spec: ${session.spec}';
}
var newUri = updateUriWithDirectConnect(uri, session.capabilities!);
return AppiumWebDriver(
newUri,
sessionId,
UnmodifiableMapView(session.capabilities!),
createRequestClient(newUri.resolve('session/$sessionId/')),
session.spec);
}