A number of clean-up commits (#201)
* Improve typing in a number of places
* Update Dart SDK headers to new values
* Update to latest version of pkg:matcher, pkg:test
* Support latest version of pkg:archive
* Bump dependency on pkg:test
Cleanup other `^` dependencies while we're at it
diff --git a/lib/async_io.dart b/lib/async_io.dart
index a9015da..f13d7d7 100644
--- a/lib/async_io.dart
+++ b/lib/async_io.dart
@@ -121,8 +121,8 @@
void _setUpRequest(HttpClientRequest request) {
request.followRedirects = true;
- request.headers.add(HttpHeaders.ACCEPT, 'application/json');
- request.headers.add(HttpHeaders.ACCEPT_CHARSET, utf8.name);
- request.headers.add(HttpHeaders.CACHE_CONTROL, 'no-cache');
+ request.headers.add(HttpHeaders.acceptHeader, 'application/json');
+ request.headers.add(HttpHeaders.acceptCharsetHeader, utf8.name);
+ request.headers.add(HttpHeaders.cacheControlHeader, 'no-cache');
}
}
diff --git a/lib/html.dart b/lib/html.dart
index 29856eb..300406e 100644
--- a/lib/html.dart
+++ b/lib/html.dart
@@ -81,7 +81,7 @@
sendData: sendData,
mimeType: 'application/json');
} on ProgressEvent catch (e) {
- request = e.target;
+ request = e.target as HttpRequest;
} finally {
_lock.release();
}
diff --git a/lib/src/async/alert.dart b/lib/src/async/alert.dart
index 70ffc0d..fe1da2b 100644
--- a/lib/src/async/alert.dart
+++ b/lib/src/async/alert.dart
@@ -19,7 +19,7 @@
/// The text of the JavaScript alert(), confirm(), or prompt() dialog.
final String text;
- Alert._(this.text, driver) : super(driver, '');
+ Alert._(this.text, WebDriver driver) : super(driver, '');
/// Accepts the currently displayed alert (may not be the alert for which this
/// object was created).
diff --git a/lib/src/async/common.dart b/lib/src/async/common.dart
index aeafb1f..a4ce80d 100644
--- a/lib/src/async/common.dart
+++ b/lib/src/async/common.dart
@@ -19,7 +19,7 @@
/// Simple class to provide access to indexed properties such as WebElement
/// attributes or css styles.
class Attributes extends _WebDriverBase {
- Attributes._(driver, command) : super(driver, command);
+ Attributes._(WebDriver driver, String command) : super(driver, command);
Future<String> operator [](String name) => _get<String>(name);
}
diff --git a/lib/src/async/exception.dart b/lib/src/async/exception.dart
index 044609c..16b04a7 100644
--- a/lib/src/async/exception.dart
+++ b/lib/src/async/exception.dart
@@ -25,8 +25,8 @@
factory WebDriverException(
{int httpStatusCode, String httpReasonPhrase, dynamic jsonResp}) {
if (jsonResp is Map) {
- var status = jsonResp['status'];
- var message = jsonResp['value']['message'];
+ var status = jsonResp['status'] as int;
+ var message = jsonResp['value']['message'] as String;
switch (status) {
case 0:
@@ -82,7 +82,7 @@
}
}
if (jsonResp != null) {
- return new InvalidRequestException(httpStatusCode, jsonResp);
+ return new InvalidRequestException(httpStatusCode, jsonResp as String);
}
return new InvalidRequestException(httpStatusCode, httpReasonPhrase);
}
@@ -103,118 +103,121 @@
}
class InvalidRequestException extends WebDriverException {
- const InvalidRequestException(statusCode, message)
+ const InvalidRequestException(int statusCode, String message)
: super._(statusCode, message);
}
class UnknownException extends WebDriverException {
- const UnknownException(statusCode, message) : super._(statusCode, message);
+ const UnknownException(int statusCode, String message)
+ : super._(statusCode, message);
}
class NoSuchDriverException extends WebDriverException {
- const NoSuchDriverException(statusCode, message)
+ const NoSuchDriverException(int statusCode, String message)
: super._(statusCode, message);
}
class NoSuchElementException extends WebDriverException {
- const NoSuchElementException(statusCode, message)
+ const NoSuchElementException(int statusCode, String message)
: super._(statusCode, message);
}
class NoSuchFrameException extends WebDriverException {
- const NoSuchFrameException(statusCode, message)
+ const NoSuchFrameException(int statusCode, String message)
: super._(statusCode, message);
}
class UnknownCommandException extends WebDriverException {
- const UnknownCommandException(statusCode, message)
+ const UnknownCommandException(int statusCode, String message)
: super._(statusCode, message);
}
class StaleElementReferenceException extends WebDriverException {
- const StaleElementReferenceException(statusCode, message)
+ const StaleElementReferenceException(int statusCode, String message)
: super._(statusCode, message);
}
class ElementNotVisibleException extends WebDriverException {
- const ElementNotVisibleException(statusCode, message)
+ const ElementNotVisibleException(int statusCode, String message)
: super._(statusCode, message);
}
class InvalidElementStateException extends WebDriverException {
- const InvalidElementStateException(statusCode, message)
+ const InvalidElementStateException(int statusCode, String message)
: super._(statusCode, message);
}
class ElementIsNotSelectableException extends WebDriverException {
- const ElementIsNotSelectableException(statusCode, message)
+ const ElementIsNotSelectableException(int statusCode, String message)
: super._(statusCode, message);
}
class JavaScriptException extends WebDriverException {
- const JavaScriptException(statusCode, message) : super._(statusCode, message);
+ const JavaScriptException(int statusCode, String message)
+ : super._(statusCode, message);
}
class XPathLookupException extends WebDriverException {
- const XPathLookupException(statusCode, message)
+ const XPathLookupException(int statusCode, String message)
: super._(statusCode, message);
}
class TimeoutException extends WebDriverException {
- const TimeoutException(statusCode, message) : super._(statusCode, message);
+ const TimeoutException(int statusCode, String message)
+ : super._(statusCode, message);
}
class NoSuchWindowException extends WebDriverException {
- const NoSuchWindowException(statusCode, message)
+ const NoSuchWindowException(int statusCode, String message)
: super._(statusCode, message);
}
class InvalidCookieDomainException extends WebDriverException {
- const InvalidCookieDomainException(statusCode, message)
+ const InvalidCookieDomainException(int statusCode, String message)
: super._(statusCode, message);
}
class UnableToSetCookieException extends WebDriverException {
- const UnableToSetCookieException(statusCode, message)
+ const UnableToSetCookieException(int statusCode, String message)
: super._(statusCode, message);
}
class UnexpectedAlertOpenException extends WebDriverException {
- const UnexpectedAlertOpenException(statusCode, message)
+ const UnexpectedAlertOpenException(int statusCode, String message)
: super._(statusCode, message);
}
class NoSuchAlertException extends WebDriverException {
- const NoSuchAlertException(statusCode, message)
+ const NoSuchAlertException(int statusCode, String message)
: super._(statusCode, message);
}
class InvalidElementCoordinatesException extends WebDriverException {
- const InvalidElementCoordinatesException(statusCode, message)
+ const InvalidElementCoordinatesException(int statusCode, String message)
: super._(statusCode, message);
}
class IMENotAvailableException extends WebDriverException {
- const IMENotAvailableException(statusCode, message)
+ const IMENotAvailableException(int statusCode, String message)
: super._(statusCode, message);
}
class IMEEngineActivationFailedException extends WebDriverException {
- const IMEEngineActivationFailedException(statusCode, message)
+ const IMEEngineActivationFailedException(int statusCode, String message)
: super._(statusCode, message);
}
class InvalidSelectorException extends WebDriverException {
- const InvalidSelectorException(statusCode, message)
+ const InvalidSelectorException(int statusCode, String message)
: super._(statusCode, message);
}
class SessionNotCreatedException extends WebDriverException {
- const SessionNotCreatedException(statusCode, message)
+ const SessionNotCreatedException(int statusCode, String message)
: super._(statusCode, message);
}
class MoveTargetOutOfBoundsException extends WebDriverException {
- const MoveTargetOutOfBoundsException(statusCode, message)
+ const MoveTargetOutOfBoundsException(int statusCode, String message)
: super._(statusCode, message);
}
diff --git a/lib/src/async/keyboard.dart b/lib/src/async/keyboard.dart
index 4994c3e..cc3a7ac 100644
--- a/lib/src/async/keyboard.dart
+++ b/lib/src/async/keyboard.dart
@@ -72,7 +72,7 @@
static const String command = '\uE03D';
static const String meta = command;
- Keyboard._(driver) : super(driver, '');
+ Keyboard._(WebDriver driver) : super(driver, '');
/// Simulate pressing many keys at once as a 'chord'.
Future sendChord(Iterable<String> chordToSend) async {
diff --git a/lib/src/async/logs.dart b/lib/src/async/logs.dart
index 46f4e43..b78ccd0 100644
--- a/lib/src/async/logs.dart
+++ b/lib/src/async/logs.dart
@@ -15,7 +15,7 @@
part of webdriver.core;
class Logs extends _WebDriverBase {
- Logs._(driver) : super(driver, 'log');
+ Logs._(WebDriver driver) : super(driver, 'log');
Stream<LogEntry> get(String logType) async* {
var entries = await _post('', {'type': logType});
diff --git a/lib/src/async/mouse.dart b/lib/src/async/mouse.dart
index 655a1ae..d7e1595 100644
--- a/lib/src/async/mouse.dart
+++ b/lib/src/async/mouse.dart
@@ -36,7 +36,7 @@
}
class Mouse extends _WebDriverBase {
- Mouse._(driver) : super(driver, '');
+ Mouse._(WebDriver driver) : super(driver, '');
/// Click any mouse button (at the coordinates set by the last moveTo).
Future click([MouseButton button]) async {
diff --git a/lib/src/async/navigation.dart b/lib/src/async/navigation.dart
index 5ac422d..1144a16 100644
--- a/lib/src/async/navigation.dart
+++ b/lib/src/async/navigation.dart
@@ -15,7 +15,7 @@
part of webdriver.core;
class Navigation extends _WebDriverBase {
- Navigation._(driver) : super(driver, '');
+ Navigation._(WebDriver driver) : super(driver, '');
/// Navigate forwards in the browser history, if possible.
Future forward() async {
diff --git a/lib/src/async/options.dart b/lib/src/async/options.dart
index 6ad5321..29ef937 100644
--- a/lib/src/async/options.dart
+++ b/lib/src/async/options.dart
@@ -15,7 +15,7 @@
part of webdriver.core;
class Cookies extends _WebDriverBase {
- Cookies._(driver) : super(driver, 'cookie');
+ Cookies._(WebDriver driver) : super(driver, 'cookie');
/// Set a cookie.
Future add(Cookie cookie) async {
@@ -79,10 +79,10 @@
json['expiry'].toInt() * 1000,
isUtc: true);
}
- return new Cookie(json['name'], json['value'],
- path: json['path'],
- domain: json['domain'],
- secure: json['secure'],
+ return new Cookie(json['name'] as String, json['value'] as String,
+ path: json['path'] as String,
+ domain: json['domain'] as String,
+ secure: json['secure'] as bool,
expiry: expiry);
}
@@ -108,7 +108,7 @@
}
class Timeouts extends _WebDriverBase {
- Timeouts._(driver) : super(driver, 'timeouts');
+ Timeouts._(WebDriver driver) : super(driver, 'timeouts');
Future _set(String type, Duration duration) async {
await _post('', {'type': type, 'ms': duration.inMilliseconds});
diff --git a/lib/src/async/target_locator.dart b/lib/src/async/target_locator.dart
index 53ee770..b60a85a 100644
--- a/lib/src/async/target_locator.dart
+++ b/lib/src/async/target_locator.dart
@@ -15,7 +15,7 @@
part of webdriver.core;
class TargetLocator extends _WebDriverBase {
- TargetLocator._(driver) : super(driver, '');
+ TargetLocator._(WebDriver driver) : super(driver, '');
/// Change focus to another frame on the page.
/// If [frame] is a:
diff --git a/lib/src/async/web_driver.dart b/lib/src/async/web_driver.dart
index d08e26a..f6003bb 100644
--- a/lib/src/async/web_driver.dart
+++ b/lib/src/async/web_driver.dart
@@ -200,7 +200,8 @@
dynamic _recursiveElementify(result) {
if (result is Map) {
if (result.length == 1 && result.containsKey(_element)) {
- return new WebElement(this, result[_element], this, 'javascript');
+ return new WebElement(
+ this, result[_element] as String, this, 'javascript');
} else {
var newResult = {};
result.forEach((key, value) {
diff --git a/lib/src/async/web_element.dart b/lib/src/async/web_element.dart
index 5c54f10..82062d3 100644
--- a/lib/src/async/web_element.dart
+++ b/lib/src/async/web_element.dart
@@ -27,7 +27,8 @@
/// used to find this element always returns one element, then this is null.
final int index;
- WebElement(driver, this.id, [this.context, this.locator, this.index])
+ WebElement(WebDriver driver, this.id,
+ [this.context, this.locator, this.index])
: super(driver, 'element/$id');
/// Click on this element.
diff --git a/lib/src/async/window.dart b/lib/src/async/window.dart
index 317ce6e..43349fe 100644
--- a/lib/src/async/window.dart
+++ b/lib/src/async/window.dart
@@ -17,7 +17,7 @@
class Window extends _WebDriverBase {
final String handle;
- Window._(driver, this.handle) : super(driver, 'window/$handle');
+ Window._(WebDriver driver, this.handle) : super(driver, 'window/$handle');
/// The size of this window.
Future<Rectangle<int>> get size async {
diff --git a/lib/src/sync/command_processor.dart b/lib/src/sync/command_processor.dart
index 5513f25..4eee399 100644
--- a/lib/src/sync/command_processor.dart
+++ b/lib/src/sync/command_processor.dart
@@ -76,7 +76,7 @@
void _setUpRequest(SyncHttpClientRequest request) {
// TODO(staats): Follow redirects.
- request.headers.add(HttpHeaders.ACCEPT, 'application/json');
- request.headers.add(HttpHeaders.CACHE_CONTROL, 'no-cache');
+ request.headers.add(HttpHeaders.acceptHeader, 'application/json');
+ request.headers.add(HttpHeaders.cacheControlHeader, 'no-cache');
}
}
diff --git a/lib/src/sync/common_spec/cookies.dart b/lib/src/sync/common_spec/cookies.dart
index 6aa78df..865ab95 100644
--- a/lib/src/sync/common_spec/cookies.dart
+++ b/lib/src/sync/common_spec/cookies.dart
@@ -83,10 +83,10 @@
json['expiry'].toInt() * 1000,
isUtc: true);
}
- return new Cookie(json['name'], json['value'],
- path: json['path'],
- domain: json['domain'],
- secure: json['secure'],
+ return new Cookie(json['name'] as String, json['value'] as String,
+ path: json['path'] as String,
+ domain: json['domain'] as String,
+ secure: json['secure'] as bool,
expiry: expiry);
}
diff --git a/lib/src/sync/json_wire_spec/exception.dart b/lib/src/sync/json_wire_spec/exception.dart
index 8a3e414..0fb402e 100644
--- a/lib/src/sync/json_wire_spec/exception.dart
+++ b/lib/src/sync/json_wire_spec/exception.dart
@@ -30,8 +30,8 @@
factory JsonWireWebDriverException(
{int httpStatusCode, String httpReasonPhrase, dynamic jsonResp}) {
if (jsonResp is Map) {
- final status = jsonResp['status'];
- final message = jsonResp['value']['message'];
+ final status = jsonResp['status'] as int;
+ final message = jsonResp['value']['message'] as String;
switch (status) {
case 0:
@@ -108,118 +108,121 @@
}
class InvalidRequestException extends JsonWireWebDriverException {
- const InvalidRequestException(statusCode, message)
+ const InvalidRequestException(int statusCode, String message)
: super._(statusCode, message);
}
class UnknownException extends JsonWireWebDriverException {
- const UnknownException(statusCode, message) : super._(statusCode, message);
+ const UnknownException(int statusCode, String message)
+ : super._(statusCode, message);
}
class NoSuchDriverException extends JsonWireWebDriverException {
- const NoSuchDriverException(statusCode, message)
+ const NoSuchDriverException(int statusCode, String message)
: super._(statusCode, message);
}
class NoSuchElementException extends JsonWireWebDriverException {
- const NoSuchElementException(statusCode, message)
+ const NoSuchElementException(int statusCode, String message)
: super._(statusCode, message);
}
class NoSuchFrameException extends JsonWireWebDriverException {
- const NoSuchFrameException(statusCode, message)
+ const NoSuchFrameException(int statusCode, String message)
: super._(statusCode, message);
}
class UnknownCommandException extends JsonWireWebDriverException {
- const UnknownCommandException(statusCode, message)
+ const UnknownCommandException(int statusCode, String message)
: super._(statusCode, message);
}
class StaleElementReferenceException extends JsonWireWebDriverException {
- const StaleElementReferenceException(statusCode, message)
+ const StaleElementReferenceException(int statusCode, String message)
: super._(statusCode, message);
}
class ElementNotVisibleException extends JsonWireWebDriverException {
- const ElementNotVisibleException(statusCode, message)
+ const ElementNotVisibleException(int statusCode, String message)
: super._(statusCode, message);
}
class InvalidElementStateException extends JsonWireWebDriverException {
- const InvalidElementStateException(statusCode, message)
+ const InvalidElementStateException(int statusCode, String message)
: super._(statusCode, message);
}
class ElementIsNotSelectableException extends JsonWireWebDriverException {
- const ElementIsNotSelectableException(statusCode, message)
+ const ElementIsNotSelectableException(int statusCode, String message)
: super._(statusCode, message);
}
class JavaScriptException extends JsonWireWebDriverException {
- const JavaScriptException(statusCode, message) : super._(statusCode, message);
+ const JavaScriptException(int statusCode, String message)
+ : super._(statusCode, message);
}
class XPathLookupException extends JsonWireWebDriverException {
- const XPathLookupException(statusCode, message)
+ const XPathLookupException(int statusCode, String message)
: super._(statusCode, message);
}
class TimeoutException extends JsonWireWebDriverException {
- const TimeoutException(statusCode, message) : super._(statusCode, message);
+ const TimeoutException(int statusCode, String message)
+ : super._(statusCode, message);
}
class NoSuchWindowException extends JsonWireWebDriverException {
- const NoSuchWindowException(statusCode, message)
+ const NoSuchWindowException(int statusCode, String message)
: super._(statusCode, message);
}
class InvalidCookieDomainException extends JsonWireWebDriverException {
- const InvalidCookieDomainException(statusCode, message)
+ const InvalidCookieDomainException(int statusCode, String message)
: super._(statusCode, message);
}
class UnableToSetCookieException extends JsonWireWebDriverException {
- const UnableToSetCookieException(statusCode, message)
+ const UnableToSetCookieException(int statusCode, String message)
: super._(statusCode, message);
}
class UnexpectedAlertOpenException extends JsonWireWebDriverException {
- const UnexpectedAlertOpenException(statusCode, message)
+ const UnexpectedAlertOpenException(int statusCode, String message)
: super._(statusCode, message);
}
class NoSuchAlertException extends JsonWireWebDriverException {
- const NoSuchAlertException(statusCode, message)
+ const NoSuchAlertException(int statusCode, String message)
: super._(statusCode, message);
}
class InvalidElementCoordinatesException extends JsonWireWebDriverException {
- const InvalidElementCoordinatesException(statusCode, message)
+ const InvalidElementCoordinatesException(int statusCode, String message)
: super._(statusCode, message);
}
class IMENotAvailableException extends JsonWireWebDriverException {
- const IMENotAvailableException(statusCode, message)
+ const IMENotAvailableException(int statusCode, String message)
: super._(statusCode, message);
}
class IMEEngineActivationFailedException extends JsonWireWebDriverException {
- const IMEEngineActivationFailedException(statusCode, message)
+ const IMEEngineActivationFailedException(int statusCode, String message)
: super._(statusCode, message);
}
class InvalidSelectorException extends JsonWireWebDriverException {
- const InvalidSelectorException(statusCode, message)
+ const InvalidSelectorException(int statusCode, String message)
: super._(statusCode, message);
}
class SessionNotCreatedException extends JsonWireWebDriverException {
- const SessionNotCreatedException(statusCode, message)
+ const SessionNotCreatedException(int statusCode, String message)
: super._(statusCode, message);
}
class MoveTargetOutOfBoundsException extends JsonWireWebDriverException {
- const MoveTargetOutOfBoundsException(statusCode, message)
+ const MoveTargetOutOfBoundsException(int statusCode, String message)
: super._(statusCode, message);
}
diff --git a/lib/src/sync/json_wire_spec/logs.dart b/lib/src/sync/json_wire_spec/logs.dart
index 74f9ed3..b7f2173 100644
--- a/lib/src/sync/json_wire_spec/logs.dart
+++ b/lib/src/sync/json_wire_spec/logs.dart
@@ -48,10 +48,11 @@
LogEntry.fromMap(Map map)
: this(
- map['message'],
- new DateTime.fromMillisecondsSinceEpoch(map['timestamp'].toInt(),
+ map['message'] as String,
+ new DateTime.fromMillisecondsSinceEpoch(
+ (map['timestamp'] as num).toInt(),
isUtc: true),
- map['level']);
+ map['level'] as String);
@override
String toString() => '$level[$timestamp]: $message';
diff --git a/lib/support/forwarder.dart b/lib/support/forwarder.dart
index 8aaf9f3..134a514 100644
--- a/lib/support/forwarder.dart
+++ b/lib/support/forwarder.dart
@@ -79,10 +79,10 @@
Future<Null> forward(HttpRequest request) async {
try {
if (!request.uri.path.startsWith(prefix)) {
- request.response.statusCode = HttpStatus.NOT_FOUND;
+ request.response.statusCode = HttpStatus.notFound;
return;
}
- request.response.statusCode = HttpStatus.OK;
+ request.response.statusCode = HttpStatus.ok;
request.response.headers.contentType = _contentTypeJson;
var endpoint = request.uri.path.replaceFirst(prefix, '');
diff --git a/pubspec.yaml b/pubspec.yaml
index a8b341b..918a488 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -8,12 +8,12 @@
interface and the W3C spec and require the use of the WebDriver remote server.
homepage: https://github.com/google/webdriver.dart
environment:
- sdk: '>=2.0.0-dev.23.0'
+ sdk: '>=2.0.0-dev.61.0 <2.0.0'
dependencies:
- archive: '^1.0.0'
- matcher: '^0.12.0'
- path: '^1.3.0'
- stack_trace: '^1.3.0'
- sync_http: "^0.1.1"
+ archive: '>=1.0.0 <3.0.0'
+ matcher: ^0.12.3
+ path: ^1.3.0
+ stack_trace: ^1.3.0
+ sync_http: ^0.1.1
dev_dependencies:
- test: '^0.12.3'
+ test: ^1.0.0
diff --git a/test/async_command_event_test.dart b/test/async_command_event_test.dart
index 398ccf2..eb51fe9 100644
--- a/test/async_command_event_test.dart
+++ b/test/async_command_event_test.dart
@@ -53,10 +53,10 @@
await waitFor(() => events, matcher: hasLength(2));
expect(events[1].method, 'GET');
expect(events[1].endPoint, contains('alert'));
- expect(events[1].exception, const isInstanceOf<WebDriverException>());
+ expect(events[1].exception, const TypeMatcher<WebDriverException>());
expect(events[1].result, isNull);
expect(events[1].startTime.isBefore(events[1].endTime), isTrue);
- expect(events[1].stackTrace, const isInstanceOf<Chain>());
+ expect(events[1].stackTrace, const TypeMatcher<Chain>());
});
test('handles normal operation', () async {
@@ -67,7 +67,7 @@
expect(events[1].exception, isNull);
expect(events[1].result, hasLength(0));
expect(events[1].startTime.isBefore(events[1].endTime), isTrue);
- expect(events[1].stackTrace, const isInstanceOf<Chain>());
+ expect(events[1].stackTrace, const TypeMatcher<Chain>());
});
}, testOn: '!js');
}
diff --git a/test/async_web_driver_test.dart b/test/async_web_driver_test.dart
index 4387a9e..cc2ea25 100644
--- a/test/async_web_driver_test.dart
+++ b/test/async_web_driver_test.dart
@@ -136,7 +136,7 @@
test('windows', () async {
var windows = await driver.windows.toList();
expect(windows, hasLength(isPositive));
- expect(windows, everyElement(const isInstanceOf<Window>()));
+ expect(windows, everyElement(const TypeMatcher<Window>()));
});
test('execute', () async {
@@ -162,19 +162,19 @@
test('captureScreenshot', () async {
var screenshot = await driver.captureScreenshot().toList();
expect(screenshot, hasLength(isPositive));
- expect(screenshot, everyElement(const isInstanceOf<int>()));
+ expect(screenshot, everyElement(const TypeMatcher<int>()));
});
test('captureScreenshotAsList', () async {
var screenshot = await driver.captureScreenshotAsList();
expect(screenshot, hasLength(isPositive));
- expect(screenshot, everyElement(const isInstanceOf<int>()));
+ expect(screenshot, everyElement(const TypeMatcher<int>()));
});
test('captureScreenshotAsBase64', () async {
var screenshot = await driver.captureScreenshotAsBase64();
expect(screenshot, hasLength(isPositive));
- expect(screenshot, const isInstanceOf<String>());
+ expect(screenshot, const TypeMatcher<String>());
});
test('future based event listeners work with script timeouts', () async {
diff --git a/test/support/async_test.dart b/test/support/async_test.dart
index aa7e2d7..bd9e104 100644
--- a/test/support/async_test.dart
+++ b/test/support/async_test.dart
@@ -35,7 +35,7 @@
test('release without acquiring fails', () {
var lock = new Lock();
- expect(() => lock.release(), throwsA(const isInstanceOf<StateError>()));
+ expect(() => lock.release(), throwsA(const TypeMatcher<StateError>()));
});
test('locking prevents acquisition of lock', () async {
diff --git a/test/support/firefox_profile_test.dart b/test/support/firefox_profile_test.dart
index 830c770..e107d41 100644
--- a/test/support/firefox_profile_test.dart
+++ b/test/support/firefox_profile_test.dart
@@ -32,7 +32,7 @@
r'extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}\",\"e\":true,\'
r'"v\":\"40.0\",\"st\":1439535413000,\"mt\":1438968709000}}}");';
var option = new PrefsOption.parse(value);
- expect(option, const isInstanceOf<StringOption>());
+ expect(option, const TypeMatcher<StringOption>());
expect(option.asPrefString, value);
});
@@ -40,21 +40,21 @@
const value = r'user_pref("browser.cache.disk.parent_directory", '
r'"\\\\volume\\web\\cache\\mz");';
var option = new PrefsOption.parse(value);
- expect(option, const isInstanceOf<StringOption>());
+ expect(option, const TypeMatcher<StringOption>());
expect(option.asPrefString, value);
});
test('parse and serialize integer value', () {
const value = r'user_pref("browser.cache.frecency_experiment", 3);';
var option = new PrefsOption.parse(value);
- expect(option, const isInstanceOf<IntegerOption>());
+ expect(option, const TypeMatcher<IntegerOption>());
expect(option.asPrefString, value);
});
test('parse and serialize negative integer value', () {
const value = r'user_pref("browser.cache.frecency_experiment", -3);';
var option = new PrefsOption.parse(value);
- expect(option, const isInstanceOf<IntegerOption>());
+ expect(option, const TypeMatcher<IntegerOption>());
expect(option.asPrefString, value);
});
@@ -62,7 +62,7 @@
const value =
r'user_pref("browser.cache.disk.smart_size.first_run", true);';
var option = new PrefsOption.parse(value);
- expect(option, const isInstanceOf<BooleanOption>());
+ expect(option, const TypeMatcher<BooleanOption>());
expect(option.asPrefString, value);
});
@@ -70,7 +70,7 @@
const value =
r'user_pref("browser.cache.disk.smart_size.first_run", false);';
var option = new PrefsOption.parse(value);
- expect(option, const isInstanceOf<BooleanOption>());
+ expect(option, const TypeMatcher<BooleanOption>());
expect(option.asPrefString, value);
});
@@ -78,7 +78,7 @@
const value =
r'user_pref("browser.cache.disk.smart_size.first_run", True);';
var option = new PrefsOption.parse(value);
- expect(option, const isInstanceOf<BooleanOption>());
+ expect(option, const TypeMatcher<BooleanOption>());
expect(option.value, true);
});
diff --git a/test/support/forwarder_test.dart b/test/support/forwarder_test.dart
index da50e10..1a9fe4e 100644
--- a/test/support/forwarder_test.dart
+++ b/test/support/forwarder_test.dart
@@ -49,12 +49,12 @@
File file = new File(
path.join('test', 'support', 'forwarder_test_page.html'));
request.response
- ..statusCode = HttpStatus.OK
+ ..statusCode = HttpStatus.ok
..headers.set('Content-type', 'text/html');
file.openRead().pipe(request.response);
} else {
request.response
- ..statusCode = HttpStatus.NOT_FOUND
+ ..statusCode = HttpStatus.notFound
..close();
}
});
diff --git a/test/sync/command_event.dart b/test/sync/command_event.dart
index ceeaf17..96fbf3a 100644
--- a/test/sync/command_event.dart
+++ b/test/sync/command_event.dart
@@ -46,10 +46,10 @@
} catch (NoSuchAlertException) {}
expect(events[1].method, 'GET');
expect(events[1].endPoint, contains('alert'));
- expect(events[1].exception, const isInstanceOf<WebDriverException>());
+ expect(events[1].exception, const TypeMatcher<WebDriverException>());
expect(events[1].result, isNull);
expect(events[1].startTime.isBefore(events[1].endTime), isTrue);
- expect(events[1].stackTrace, const isInstanceOf<Chain>());
+ expect(events[1].stackTrace, const TypeMatcher<Chain>());
});
test('handles normal operation', () {
@@ -59,7 +59,7 @@
expect(events[1].exception, isNull);
expect(events[1].result, hasLength(0));
expect(events[1].startTime.isBefore(events[1].endTime), isTrue);
- expect(events[1].stackTrace, const isInstanceOf<Chain>());
+ expect(events[1].stackTrace, const TypeMatcher<Chain>());
});
}, timeout: const Timeout(const Duration(minutes: 2)));
}
diff --git a/test/sync/spec_inference_test.dart b/test/sync/spec_inference_test.dart
index 17cd858..cda92a3 100644
--- a/test/sync/spec_inference_test.dart
+++ b/test/sync/spec_inference_test.dart
@@ -43,7 +43,7 @@
button.findElement(const By.tagName('tr'));
throw 'Expected NoSuchElementException';
} catch (e) {
- expect(e, const isInstanceOf<json.NoSuchElementException>());
+ expect(e, const TypeMatcher<json.NoSuchElementException>());
expect(e.toString(), contains('Unable to locate element'));
}
});
@@ -56,7 +56,7 @@
button.findElement(const By.tagName('tr'));
throw 'Expected W3cWebDriverException';
} catch (e) {
- expect(e, const isInstanceOf<w3c.W3cWebDriverException>());
+ expect(e, const TypeMatcher<w3c.W3cWebDriverException>());
expect(e.toString(), contains('Unable to locate element'));
}
});
diff --git a/test/sync/sync_async_interop.dart b/test/sync/sync_async_interop.dart
index 4c189c3..c77f92a 100644
--- a/test/sync/sync_async_interop.dart
+++ b/test/sync/sync_async_interop.dart
@@ -37,27 +37,27 @@
test('sync to async driver works', () async {
final asyncDriver = driver.asyncDriver;
- expect(asyncDriver, const isInstanceOf<async_core.WebDriver>());
+ expect(asyncDriver, const TypeMatcher<async_core.WebDriver>());
await asyncDriver.get(config.testPagePath);
driver.findElement(const By.tagName('button'));
});
test('sync to async web element works', () async {
final asyncDriver = driver.asyncDriver;
- expect(asyncDriver, const isInstanceOf<async_core.WebDriver>());
+ expect(asyncDriver, const TypeMatcher<async_core.WebDriver>());
await asyncDriver.get(config.testPagePath);
final button = driver.findElement(const By.tagName('button'));
final asyncButton = button.asyncElement;
- expect(button, const isInstanceOf<WebElement>());
- expect(asyncButton, const isInstanceOf<async_core.WebElement>());
+ expect(button, const TypeMatcher<WebElement>());
+ expect(asyncButton, const TypeMatcher<async_core.WebElement>());
expect(asyncButton.id, button.id);
expect(await asyncButton.name, button.name);
});
test('sync to async web element finding works', () async {
final asyncDriver = driver.asyncDriver;
- expect(asyncDriver, const isInstanceOf<async_core.WebDriver>());
+ expect(asyncDriver, const TypeMatcher<async_core.WebDriver>());
await asyncDriver.get(config.testPagePath);
final table = driver.findElement(const By.tagName('table'));
diff --git a/test/sync/w3c_web_element.dart b/test/sync/w3c_web_element.dart
index 7ab2516..7b882a9 100644
--- a/test/sync/w3c_web_element.dart
+++ b/test/sync/w3c_web_element.dart
@@ -162,7 +162,7 @@
button.findElement(const By.tagName('tr'));
throw 'Expected Exception';
} catch (e) {
- expect(e, const isInstanceOf<W3cWebDriverException>());
+ expect(e, const TypeMatcher<W3cWebDriverException>());
expect((e as W3cWebDriverException).httpStatusCode, 404);
expect((e as W3cWebDriverException).error, 'no such element');
expect((e as W3cWebDriverException).message,
diff --git a/test/sync/web_driver.dart b/test/sync/web_driver.dart
index ba7cf2e..354773f 100644
--- a/test/sync/web_driver.dart
+++ b/test/sync/web_driver.dart
@@ -133,7 +133,7 @@
test('windows', () {
var windows = driver.windows.toList();
expect(windows, hasLength(isPositive));
- expect(windows, everyElement(const isInstanceOf<Window>()));
+ expect(windows, everyElement(const TypeMatcher<Window>()));
});
test('execute', () {
@@ -157,19 +157,19 @@
test('captureScreenshot', () {
var screenshot = driver.captureScreenshotAsList().toList();
expect(screenshot, hasLength(isPositive));
- expect(screenshot, everyElement(const isInstanceOf<int>()));
+ expect(screenshot, everyElement(const TypeMatcher<int>()));
});
test('captureScreenshotAsList', () {
var screenshot = driver.captureScreenshotAsList();
expect(screenshot, hasLength(isPositive));
- expect(screenshot, everyElement(const isInstanceOf<int>()));
+ expect(screenshot, everyElement(const TypeMatcher<int>()));
});
test('captureScreenshotAsBase64', () {
var screenshot = driver.captureScreenshotAsBase64();
expect(screenshot, hasLength(isPositive));
- expect(screenshot, const isInstanceOf<String>());
+ expect(screenshot, const TypeMatcher<String>());
});
test('event listeners work with script timeouts', () {
diff --git a/test/sync/web_element.dart b/test/sync/web_element.dart
index 7b67d2f..9e1ee0a 100644
--- a/test/sync/web_element.dart
+++ b/test/sync/web_element.dart
@@ -148,7 +148,7 @@
button.findElement(const By.tagName('tr'));
throw 'Expected NoSuchElementException';
} catch (e) {
- expect(e, const isInstanceOf<NoSuchElementException>());
+ expect(e, const TypeMatcher<NoSuchElementException>());
}
});
diff --git a/test/test_util.dart b/test/test_util.dart
index c15b3bc..b59d340 100644
--- a/test/test_util.dart
+++ b/test/test_util.dart
@@ -17,15 +17,15 @@
import 'dart:math' show Point, Rectangle;
import 'dart:io' show FileSystemEntity;
-import 'package:matcher/matcher.dart' show isInstanceOf, Matcher;
+import 'package:matcher/matcher.dart' show TypeMatcher, Matcher;
import 'package:path/path.dart' as path;
import 'package:webdriver/async_core.dart' as async_core;
import 'package:webdriver/sync_core.dart' as sync_core;
-final Matcher isWebElement = const isInstanceOf<async_core.WebElement>();
-final Matcher isSyncWebElement = const isInstanceOf<sync_core.WebElement>();
-final Matcher isRectangle = const isInstanceOf<Rectangle<int>>();
-final Matcher isPoint = const isInstanceOf<Point<int>>();
+final Matcher isWebElement = const TypeMatcher<async_core.WebElement>();
+final Matcher isSyncWebElement = const TypeMatcher<sync_core.WebElement>();
+final Matcher isRectangle = const TypeMatcher<Rectangle<int>>();
+final Matcher isPoint = const TypeMatcher<Point<int>>();
String get testPagePath {
String testPagePath = path.absolute('test', 'test_page.html');