Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 3.1.0-wip
## 3.1.0

* Add a `reason` argument to `Clock.waitFor`.
* Explicitly close http clients on quit.

## 3.0.4

Expand Down
2 changes: 2 additions & 0 deletions lib/async_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Future<WebDriver> createDriver(
final session = await client.send(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this should have probably been using try {} finally {} to make sure that client is closed even if send causes an exception. Otherwise you might end up with the same 15s timeout.

Not that it matters for typical usage - but it is cleaner that way.

handler.session.buildCreateRequest(desired: desired),
handler.session.parseCreateResponse);
client.close();

if (session.spec != WebDriverSpec.JsonWire &&
session.spec != WebDriverSpec.W3c) {
Expand Down Expand Up @@ -90,6 +91,7 @@ Future<WebDriver> fromExistingSession(

final session = await client.send(handler.session.buildInfoRequest(sessionId),
(response) => handler.session.parseInfoResponse(response, sessionId));
client.close();

if (session.spec != WebDriverSpec.JsonWire &&
session.spec != WebDriverSpec.W3c) {
Expand Down
12 changes: 8 additions & 4 deletions lib/src/async/web_driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,14 @@ class WebDriver implements SearchContext {
_handler.core.parsePageSourceResponse);

/// Quits the browser.
Future<void> quit({bool closeSession = true}) => closeSession
? _client.send(_handler.core.buildDeleteSessionRequest(),
_handler.core.parseDeleteSessionResponse)
: Future.value();
Future<void> quit({bool closeSession = true}) async {
if (!closeSession) {
return;
}
await _client.send(_handler.core.buildDeleteSessionRequest(),
_handler.core.parseDeleteSessionResponse);
_client.close();
}

/// Closes the current window.
///
Expand Down
2 changes: 2 additions & 0 deletions lib/src/common/request_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,6 @@ abstract class AsyncRequestClient extends RequestClient {
}

Future<WebDriverResponse> sendRaw(WebDriverRequest request);

void close() {}
}
3 changes: 3 additions & 0 deletions lib/src/request/async_io_request_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,7 @@ class AsyncIoRequestClient extends AsyncRequestClient {

@override
String toString() => 'AsyncIo';

@override
void close() => client.close(force: true);
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: webdriver
version: 3.1.0-wip
version: 3.1.0
description: >-
Provides WebDriver bindings for Dart. Supports WebDriver JSON interface and
W3C spec. Requires the use of WebDriver remote server.
Expand Down
Loading