Version 0.10.0-pre.1
Migrate Stream code to async*
Isolate dart:io dependency to single location.
Remove WebDriver.get(String) and add WebDriver.navigate.to(...)
Make some previously private methods public.
Style and import cleanup.
diff --git a/lib/async_helpers.dart b/lib/async_helpers.dart
index de36283..4b26bea 100644
--- a/lib/async_helpers.dart
+++ b/lib/async_helpers.dart
@@ -15,6 +15,7 @@
library webdriver.async_helpers;
import 'dart:async' show Completer, Future;
+
import 'package:matcher/matcher.dart' show expect, isNotNull;
const defaultInterval = const Duration(milliseconds: 500);
diff --git a/lib/webdriver.dart b/lib/core.dart
similarity index 70%
rename from lib/webdriver.dart
rename to lib/core.dart
index bbdfe97..94f851e 100644
--- a/lib/webdriver.dart
+++ b/lib/core.dart
@@ -14,28 +14,19 @@
library webdriver;
-import 'dart:async' show Future, Stream, StreamController;
-import 'dart:collection' show UnmodifiableMapView;
-import 'dart:convert' show JSON, UTF8;
-import 'dart:io'
- show
- ContentType,
- HttpClient,
- HttpClientRequest,
- HttpClientResponse,
- HttpHeaders;
+import 'dart:async' show Future, Stream;
import 'dart:math' show Point, Rectangle;
import 'package:crypto/crypto.dart' show CryptoUtils;
-import 'async_helpers.dart' show Lock, waitFor;
-export 'async_helpers.dart' show waitFor;
+import 'async_helpers.dart' show Lock;
+import 'src/command_processor.dart' show CommandProcessor;
+
+export 'src/exception.dart';
part 'src/alert.dart';
part 'src/capabilities.dart';
-part 'src/command_processor.dart';
part 'src/common.dart';
-part 'src/exception.dart';
part 'src/keyboard.dart';
part 'src/logs.dart';
part 'src/mouse.dart';
diff --git a/lib/io.dart b/lib/io.dart
new file mode 100644
index 0000000..0359124
--- /dev/null
+++ b/lib/io.dart
@@ -0,0 +1,105 @@
+library webdriver.io;
+
+import 'dart:async' show Future;
+import 'dart:collection' show UnmodifiableMapView;
+import 'dart:convert' show JSON, UTF8;
+import 'dart:io'
+ show
+ ContentType,
+ HttpClient,
+ HttpClientRequest,
+ HttpClientResponse,
+ HttpHeaders;
+
+import 'package:webdriver/async_helpers.dart' show Lock;
+import 'package:webdriver/core.dart' show WebDriver, Capabilities;
+import 'package:webdriver/src/command_processor.dart' show CommandProcessor;
+import 'package:webdriver/src/exception.dart' show WebDriverException;
+
+export 'package:webdriver/core.dart';
+
+final Uri defaultUri = Uri.parse('http://127.0.0.1:4444/wd/hub/');
+
+/// Creates a WebDriver instance connected to the specified WebDriver server.
+Future<WebDriver> createDriver({Uri uri, Map<String, dynamic> desired}) async {
+ if (uri == null) {
+ uri = defaultUri;
+ }
+
+ var commandProcessor = new _IOCommandProcessor();
+
+ if (desired == null) {
+ desired = Capabilities.empty;
+ }
+
+ var response = await commandProcessor.post(
+ uri.resolve('session'), {'desiredCapabilities': desired}, value: false);
+ return new WebDriver(commandProcessor, uri, response['sessionId'],
+ new UnmodifiableMapView(response['value']));
+}
+
+final ContentType _contentTypeJson =
+ new ContentType("application", "json", charset: "utf-8");
+
+class _IOCommandProcessor implements CommandProcessor {
+ final HttpClient client = new HttpClient();
+
+ Lock _lock = new Lock();
+
+ Future<Object> post(Uri uri, dynamic params, {bool value: true}) async {
+ await _lock.acquire();
+ HttpClientRequest request = await client.postUrl(uri);
+ _setUpRequest(request);
+ request.headers.contentType = _contentTypeJson;
+ if (params != null) {
+ var body = UTF8.encode(JSON.encode(params));
+ request.contentLength = body.length;
+ request.add(body);
+ } else {
+ request.contentLength = 0;
+ }
+ return await _processResponse(await request.close(), value);
+ }
+
+ Future<Object> get(Uri uri, {bool value: true}) async {
+ await _lock.acquire();
+ HttpClientRequest request = await client.getUrl(uri);
+ _setUpRequest(request);
+ return await _processResponse(await request.close(), value);
+ }
+
+ Future<Object> delete(Uri uri, {bool value: true}) async {
+ await _lock.acquire();
+ HttpClientRequest request = await client.deleteUrl(uri);
+ _setUpRequest(request);
+ return await _processResponse(await request.close(), value);
+ }
+
+ _processResponse(HttpClientResponse response, bool value) async {
+ var respBody = await UTF8.decodeStream(response);
+ _lock.release();
+ try {
+ respBody = JSON.decode(respBody);
+ } catch (e) {}
+
+ if (response.statusCode < 200 ||
+ response.statusCode > 299 ||
+ (respBody is Map && respBody['status'] != 0)) {
+ throw new WebDriverException(
+ httpStatusCode: response.statusCode,
+ httpReasonPhrase: response.reasonPhrase,
+ jsonResp: respBody);
+ }
+ if (value && respBody is Map) {
+ return respBody['value'];
+ }
+ return respBody;
+ }
+
+ void _setUpRequest(HttpClientRequest request) {
+ request.followRedirects = false;
+ request.headers.add(HttpHeaders.ACCEPT, "application/json");
+ request.headers.add(HttpHeaders.ACCEPT_CHARSET, UTF8.name);
+ request.headers.add(HttpHeaders.CACHE_CONTROL, "no-cache");
+ }
+}
diff --git a/lib/src/capabilities.dart b/lib/src/capabilities.dart
index 72317eb..9aa8620 100644
--- a/lib/src/capabilities.dart
+++ b/lib/src/capabilities.dart
@@ -55,26 +55,13 @@
class Browser {
static const String firefox = "firefox";
- static const String firefox2 = "firefox2";
- static const String firefox3 = "firefox3";
- static const String firefoxProxy = "firefoxproxy";
- static const String firefoxChrome = "firefoxchrome";
- static const String googleChrome = "googlechrome";
static const String safari = "safari";
static const String opera = "opera";
- static const String iexplore = "iexplore";
- static const String iexploreProxy = "iexploreproxy";
- static const String safariProxy = "safariproxy";
static const String chrome = "chrome";
- static const String konqueror = "konqueror";
- static const String mock = "mock";
- static const String ieHta = "iehta";
static const String android = "android";
- static const String htmlUnit = "htmlunit";
static const String ie = "internet explorer";
static const String iphone = "iPhone";
static const String ipad = "iPad";
- static const String phantomJS = "phantomjs";
}
class BrowserPlatform {
diff --git a/lib/src/command_processor.dart b/lib/src/command_processor.dart
index 242f2a8..bbd7b07 100644
--- a/lib/src/command_processor.dart
+++ b/lib/src/command_processor.dart
@@ -1,81 +1,12 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+library webdriver.command_processor;
-part of webdriver;
+import 'dart:async';
-final ContentType _contentTypeJson =
- new ContentType("application", "json", charset: "utf-8");
+/// Interface for HTTP access.
+abstract class CommandProcessor {
+ Future<Object> post(Uri uri, dynamic params, {bool value: true});
-class _CommandProcessor {
- final HttpClient client = new HttpClient();
+ Future<Object> get(Uri uri, {bool value: true});
- Lock _lock = new Lock();
-
- Future<Object> post(Uri uri, dynamic params, {bool value: true}) async {
- await _lock.acquire();
- HttpClientRequest request = await client.postUrl(uri);
- _setUpRequest(request);
- request.headers.contentType = _contentTypeJson;
- if (params != null) {
- var body = UTF8.encode(JSON.encode(params));
- request.contentLength = body.length;
- request.add(body);
- } else {
- request.contentLength = 0;
- }
- return await _processResponse(await request.close(), value);
- }
-
- Future<Object> get(Uri uri, {bool value: true}) async {
- await _lock.acquire();
- HttpClientRequest request = await client.getUrl(uri);
- _setUpRequest(request);
- return await _processResponse(await request.close(), value);
- }
-
- Future<Object> delete(Uri uri, {bool value: true}) async {
- await _lock.acquire();
- HttpClientRequest request = await client.deleteUrl(uri);
- _setUpRequest(request);
- return await _processResponse(await request.close(), value);
- }
-
- _processResponse(HttpClientResponse response, bool value) async {
- var respBody = await UTF8.decodeStream(response);
- _lock.release();
- try {
- respBody = JSON.decode(respBody);
- } catch (e) {}
-
- if (response.statusCode < 200 ||
- response.statusCode > 299 ||
- (respBody is Map && respBody['status'] != 0)) {
- throw new WebDriverException(
- httpStatusCode: response.statusCode,
- httpReasonPhrase: response.reasonPhrase,
- jsonResp: respBody);
- }
- if (value && respBody is Map) {
- return respBody['value'];
- }
- return respBody;
- }
-
- void _setUpRequest(HttpClientRequest request) {
- request.followRedirects = false;
- request.headers.add(HttpHeaders.ACCEPT, "application/json");
- request.headers.add(HttpHeaders.ACCEPT_CHARSET, UTF8.name);
- request.headers.add(HttpHeaders.CACHE_CONTROL, "no-cache");
- }
+ Future<Object> delete(Uri uri, {bool value: true});
}
diff --git a/lib/src/common.dart b/lib/src/common.dart
index ba4a23e..6ac362c 100644
--- a/lib/src/common.dart
+++ b/lib/src/common.dart
@@ -42,12 +42,11 @@
_WebDriverBase(this.driver, this._prefix);
- Future _post(String command, [param]) =>
- driver._post(resolve(command), param);
+ Future _post(String command, [param]) => driver.post(resolve(command), param);
- Future _get(String command) => driver._get(resolve(command));
+ Future _get(String command) => driver.get(resolve(command));
- Future _delete(String command) => driver._delete(resolve(command));
+ Future _delete(String command) => driver.delete(resolve(command));
String resolve(command) {
if (_prefix == null || _prefix.isEmpty) {
diff --git a/lib/src/exception.dart b/lib/src/exception.dart
index 67871dd..71561b9 100644
--- a/lib/src/exception.dart
+++ b/lib/src/exception.dart
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-part of webdriver;
+library webdriver.exception;
abstract class WebDriverException implements Exception {
/// Either the status value returned in the JSON response (preferred) or the
diff --git a/lib/src/logs.dart b/lib/src/logs.dart
index 6549035..1b7259f 100644
--- a/lib/src/logs.dart
+++ b/lib/src/logs.dart
@@ -17,18 +17,11 @@
class Logs extends _WebDriverBase {
Logs._(driver) : super(driver, 'log');
- Stream<LogEntry> get(String logType) {
- var controller = new StreamController<LogEntry>();
-
- () async {
- var entries = await _post('', {'type': logType});
- for (var entry in entries) {
- controller.add(new LogEntry.fromMap(entry));
- }
- await controller.close();
- }();
-
- return controller.stream;
+ Stream<LogEntry> get(String logType) async* {
+ var entries = await _post('', {'type': logType});
+ for (var entry in entries) {
+ yield new LogEntry.fromMap(entry);
+ }
}
@override
diff --git a/lib/src/navigation.dart b/lib/src/navigation.dart
index ac61a74..d335211 100644
--- a/lib/src/navigation.dart
+++ b/lib/src/navigation.dart
@@ -17,6 +17,13 @@
class Navigation extends _WebDriverBase {
Navigation._(driver) : super(driver, '');
+ Future to(/* Uri | String */ url) async {
+ if (url is Uri) {
+ url = url.toString();
+ }
+ await _post('url', {'url': url});
+ }
+
/// Navigate forwards in the browser history, if possible.
Future forward() async {
await _post('forward');
diff --git a/lib/src/options.dart b/lib/src/options.dart
index 2ba0ada..a09a748 100644
--- a/lib/src/options.dart
+++ b/lib/src/options.dart
@@ -33,28 +33,12 @@
}
/// Retrieve all cookies visible to the current page.
- Stream<Cookie> get all {
- var controller = new StreamController<Cookie>();
-
- () async {
- var cookies = await _get('');
- int i = 0;
- for (var cookie in cookies) {
- controller.add(new Cookie.fromJson(cookie));
- i++;
- }
- await controller.close();
- }();
-
- return controller.stream;
+ Stream<Cookie> get all async* {
+ var cookies = await _get('');
+ for (var cookie in cookies) {
+ yield new Cookie.fromJson(cookie);
+ }
}
-// TODO(DrMarcII): switch to this when async* is supported
-// async* {
-// var cookies = await _get('');
-// for (var cookie in cookies) {
-// yield new Cookie.fromJson(cookie);
-// }
-// }
@override
String toString() => '$driver.cookies';
diff --git a/lib/src/web_driver.dart b/lib/src/web_driver.dart
index 0797fd6..8f36271 100644
--- a/lib/src/web_driver.dart
+++ b/lib/src/web_driver.dart
@@ -15,93 +15,49 @@
part of webdriver;
class WebDriver implements SearchContext {
- static final Uri defaultUri = Uri.parse('http://127.0.0.1:4444/wd/hub/');
-
- final _CommandProcessor _commandProcessor;
+ final CommandProcessor _commandProcessor;
final Uri _prefix;
final Map<String, dynamic> capabilities;
final String id;
final Uri uri;
- WebDriver._(this._commandProcessor, Uri uri, String id, this.capabilities)
+ WebDriver(this._commandProcessor, Uri uri, String id, this.capabilities)
: this.uri = uri,
this.id = id,
this._prefix = uri.resolve('session/$id/');
- /// Creates a WebDriver instance connected to the specified WebDriver server.
- static Future<WebDriver> createDriver(
- {Uri uri, Map<String, dynamic> desiredCapabilities}) async {
- if (uri == null) {
- uri = defaultUri;
- }
-
- var commandProcessor = new _CommandProcessor();
-
- if (desiredCapabilities == null) {
- desiredCapabilities = Capabilities.empty;
- }
-
- var response = await commandProcessor.post(uri.resolve('session'), {
- 'desiredCapabilities': desiredCapabilities
- }, value: false);
- return new WebDriver._(commandProcessor, uri, response['sessionId'],
- new UnmodifiableMapView(response['value']));
- }
-
- /// Navigate to the specified url.
- Future get(String url) async {
- await _post('url', {'url': url});
- }
-
/// The current url.
- Future<String> get currentUrl => _get('url');
+ Future<String> get currentUrl => get('url');
/// The title of the current page.
- Future<String> get title => _get('title');
+ Future<String> get title => get('title');
/// Search for multiple elements within the entire current page.
@override
- Stream<WebElement> findElements(By by) {
- var controller = new StreamController<WebElement>();
+ Stream<WebElement> findElements(By by) async* {
+ var elements = await post('elements', by);
+ int i = 0;
- () async {
- var elements = await _post('elements', by);
- int i = 0;
- for (var element in elements) {
- controller.add(new WebElement._(this, element[_element], this, by, i));
- i++;
- }
- await controller.close();
- }();
-
- return controller.stream;
+ for (var element in elements) {
+ yield new WebElement._(this, element[_element], this, by, i);
+ i++;
+ }
}
-// TODO(DrMarcII): switch to this when async* is supported
-// async* {
-// var elements = await _post('elements', by);
-// int i = 0;
-//
-// for (var element in elements) {
-// yield new WebElement._(this, element[_element], this, by, i);
-// i++;
-// }
-// }
-
/// Search for an element within the entire current page.
/// Throws [NoSuchElementException] if a matching element is not found.
@override
Future<WebElement> findElement(By by) async {
- var element = await _post('element', by);
+ var element = await post('element', by);
return new WebElement._(this, element[_element], this, by);
}
/// An artist's rendition of the current page's source.
- Future<String> get pageSource => _get('source');
+ Future<String> get pageSource => get('source');
/// Close the current window, quitting the browser if it is the last window.
Future close() async {
- await _delete('window');
+ await delete('window');
}
/// Quit the browser.
@@ -110,39 +66,24 @@
}
/// Handles for all of the currently displayed tabs/windows.
- Stream<Window> get windows {
- var controller = new StreamController<Window>();
+ Stream<Window> get windows async* {
+ var handles = await get('window_handles');
- () async {
- var handles = await _get('window_handles');
- for (var handle in handles) {
- controller.add(new Window._(this, handle));
- }
- await controller.close();
- }();
-
- return controller.stream;
+ for (var handle in handles) {
+ yield new Window._(this, handle);
+ }
}
-// TODO(DrMarcII): switch to this when async* is supported
-// async* {
-// var handles = await _get('window_handles');
-//
-// for (var handle in handles) {
-// yield new Window._(this, handle);
-// }
-// }
-
/// Handle for the active tab/window.
Future<Window> get window async {
- var handle = await _get('window_handle');
+ var handle = await get('window_handle');
return new Window._(this, handle);
}
/// The currently focused element, or the body element if no element has
/// focus.
Future<WebElement> get activeElement async {
- var element = await _post('element/active');
+ var element = await post('element/active');
if (element != null) {
return new WebElement._(this, element[_element], this, 'activeElement');
}
@@ -164,7 +105,7 @@
Mouse get mouse => new Mouse._(this);
/// Take a screenshot of the current page as PNG.
- Future<List<int>> captureScreenshot() => _get('screenshot')
+ Future<List<int>> captureScreenshot() => get('screenshot')
.then((screenshot) => CryptoUtils.base64StringToBytes(screenshot));
/// Inject a snippet of JavaScript into the page for execution in the context
@@ -185,10 +126,9 @@
/// Arguments may be any JSON-able object. WebElements will be converted to
/// the corresponding DOM element. Likewise, any DOM Elements in the script
/// result will be converted to WebElements.
- Future executeAsync(String script, List args) => _post('execute_async', {
- 'script': script,
- 'args': args
- }).then(_recursiveElementify);
+ Future executeAsync(String script, List args) => post(
+ 'execute_async', {'script': script, 'args': args})
+ .then(_recursiveElementify);
/// Inject a snippet of JavaScript into the page for execution in the context
/// of the currently selected frame. The executed script is assumed to be
@@ -202,7 +142,7 @@
/// Arguments may be any JSON-able object. WebElements will be converted to
/// the corresponding DOM element. Likewise, any DOM Elements in the script
/// result will be converted to WebElements.
- Future execute(String script, List args) => _post(
+ Future execute(String script, List args) => post(
'execute', {'script': script, 'args': args}).then(_recursiveElementify);
dynamic _recursiveElementify(result) {
@@ -223,13 +163,12 @@
}
}
- Future _post(String command, [params]) =>
+ Future post(String command, [params]) =>
_commandProcessor.post(_prefix.resolve(command), params);
- Future _get(String command) =>
- _commandProcessor.get(_prefix.resolve(command));
+ Future get(String command) => _commandProcessor.get(_prefix.resolve(command));
- Future _delete(String command) =>
+ Future delete(String command) =>
_commandProcessor.delete(_prefix.resolve(command));
@override
diff --git a/lib/src/web_element.dart b/lib/src/web_element.dart
index 2eb937f..4b09280 100644
--- a/lib/src/web_element.dart
+++ b/lib/src/web_element.dart
@@ -20,7 +20,7 @@
/// The context from which this element was found.
final SearchContext context;
/// How the element was located from the context.
- final dynamic /* String | By */ locator;
+ final dynamic /* String | Finder */ locator;
/// The index of this element in the set of element founds. If the method
/// used to find this element always returns one element, then this is null.
final int index;
@@ -87,33 +87,15 @@
}
/// Find multiple elements nested within this element.
- Stream<WebElement> findElements(By by) {
- var controller = new StreamController<WebElement>();
-
- () async {
- var elements = await _post('elements', by);
- int i = 0;
- for (var element in elements) {
- controller
- .add(new WebElement._(driver, element[_element], this, by, i));
- i++;
- }
- await controller.close();
- }();
-
- return controller.stream;
+ Stream<WebElement> findElements(By by) async* {
+ var elements = await _post('elements', by);
+ int i = 0;
+ for (var element in elements) {
+ yield new WebElement._(driver, element[_element], this, by, i);
+ i++;
+ }
}
-// TODO(DrMarcII): switch to this when async* is supported
-// async* {
-// var elements = await _post('elements', by);
-// int i = 0;
-// for (var element in elements) {
-// yield new WebElement._(driver, element[_ELEMENT], this, by, i);
-// i++;
-// }
-// }
-
/// Access to the HTML attributes of this tag.
///
/// TODO(DrMarcII): consider special handling of boolean attributes.
@@ -141,7 +123,7 @@
@override
String toString() {
var out = new StringBuffer()..write(context);
- if (locator is By) {
+ if (locator is Finder) {
if (index == null) {
out..write('.findElement(');
} else {
diff --git a/pubspec.yaml b/pubspec.yaml
index f7fabc4..1a1653b 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,15 +1,15 @@
name: webdriver
-version: 0.9.1
+version: 0.10.0-pre.1
author: Google Inc.
description: >
Provides WebDriver bindings for Dart. These use the WebDriver JSON interface,
and as such, require the use of the WebDriver remote server.
homepage: https://github.com/google/webdriver.dart
environment:
- sdk: '>=1.9.0-dev.7.1 <2.0.0'
+ sdk: '>=1.9.0-dev.10.4 <2.0.0'
dependencies:
crypto: '^0.9.0'
- matcher: '^0.11.4+1'
+ matcher: '^0.11.4+3'
dev_dependencies:
path: '^1.3.3'
unittest: '^0.11.5+4'
diff --git a/test/src/alert_test.dart b/test/src/alert_test.dart
index 6d699bf..15e4b8e 100644
--- a/test/src/alert_test.dart
+++ b/test/src/alert_test.dart
@@ -15,7 +15,7 @@
library webdriver_test.alert;
import 'package:unittest/unittest.dart';
-import 'package:webdriver/webdriver.dart';
+import 'package:webdriver/core.dart';
import '../test_util.dart';
@@ -27,7 +27,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.get(testPagePath);
+ await driver.navigate.to(testPagePath);
button = await driver.findElement(const By.tagName('button'));
output = await driver.findElement(const By.id('settable'));
});
diff --git a/test/src/keyboard_test.dart b/test/src/keyboard_test.dart
index bd16a0f..9aa25c1 100644
--- a/test/src/keyboard_test.dart
+++ b/test/src/keyboard_test.dart
@@ -15,7 +15,7 @@
library webdriver_test.keyboard;
import 'package:unittest/unittest.dart';
-import 'package:webdriver/webdriver.dart';
+import 'package:webdriver/core.dart';
import '../test_util.dart';
@@ -26,7 +26,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.get(testPagePath);
+ await driver.navigate.to(testPagePath);
textInput =
await driver.findElement(const By.cssSelector('input[type=text]'));
await textInput.click();
diff --git a/test/src/logs_test.dart b/test/src/logs_test.dart
index f5b6fc1..5c6d71e 100644
--- a/test/src/logs_test.dart
+++ b/test/src/logs_test.dart
@@ -15,7 +15,7 @@
library webdriver_test.logs;
import 'package:unittest/unittest.dart';
-import 'package:webdriver/webdriver.dart';
+import 'package:webdriver/core.dart';
import '../test_util.dart';
@@ -29,7 +29,7 @@
};
driver = await createTestDriver(additionalCapabilities: capabilities);
- await driver.get('http://www.google.com');
+ await driver.navigate.to('http://www.google.com');
});
tearDown(() => driver.quit());
diff --git a/test/src/mouse_test.dart b/test/src/mouse_test.dart
index 77641ec..a178d1a 100644
--- a/test/src/mouse_test.dart
+++ b/test/src/mouse_test.dart
@@ -15,7 +15,7 @@
library webdriver_test.mouse;
import 'package:unittest/unittest.dart';
-import 'package:webdriver/webdriver.dart';
+import 'package:webdriver/core.dart';
import '../test_util.dart';
@@ -26,7 +26,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.get(testPagePath);
+ await driver.navigate.to(testPagePath);
button = await driver.findElement(const By.tagName('button'));
});
diff --git a/test/src/navigation_test.dart b/test/src/navigation_test.dart
index bf53b3c..1ec474c 100644
--- a/test/src/navigation_test.dart
+++ b/test/src/navigation_test.dart
@@ -15,7 +15,8 @@
library webdriver_test.navigation;
import 'package:unittest/unittest.dart';
-import 'package:webdriver/webdriver.dart';
+import 'package:webdriver/async_helpers.dart';
+import 'package:webdriver/core.dart';
import '../test_util.dart';
@@ -25,13 +26,13 @@
setUp(() async {
driver = await createTestDriver();
- await driver.get('http://www.google.com/ncr');
+ await driver.navigate.to('http://www.google.com/ncr');
});
tearDown(() => driver.quit());
test('forward/back', () async {
- await driver.get('http://www.yahoo.com');
+ await driver.navigate.to('http://www.yahoo.com');
await driver.navigate.back();
await waitFor(() => driver.title, matcher: contains('Google'));
await driver.navigate.forward();
diff --git a/test/src/options_test.dart b/test/src/options_test.dart
index 172ad9e..6c7ff20 100644
--- a/test/src/options_test.dart
+++ b/test/src/options_test.dart
@@ -15,7 +15,7 @@
library webdriver_test.options;
import 'package:unittest/unittest.dart';
-import 'package:webdriver/webdriver.dart';
+import 'package:webdriver/core.dart';
import '../test_util.dart';
@@ -25,7 +25,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.get('http://www.google.com');
+ await driver.navigate.to('http://www.google.com');
});
tearDown(() => driver.quit());
diff --git a/test/src/target_locator_test.dart b/test/src/target_locator_test.dart
index b7b31d3..1bb76d1 100644
--- a/test/src/target_locator_test.dart
+++ b/test/src/target_locator_test.dart
@@ -15,7 +15,7 @@
library webdriver_test.target_locator;
import 'package:unittest/unittest.dart';
-import 'package:webdriver/webdriver.dart';
+import 'package:webdriver/core.dart';
import '../test_util.dart';
@@ -30,7 +30,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.get(testPagePath);
+ await driver.navigate.to(testPagePath);
frame = await driver.findElement(new By.name('frame'));
});
diff --git a/test/src/web_driver_test.dart b/test/src/web_driver_test.dart
index 192a03a..f0f6c4e 100644
--- a/test/src/web_driver_test.dart
+++ b/test/src/web_driver_test.dart
@@ -15,7 +15,8 @@
library webdriver_test.web_driver;
import 'package:unittest/unittest.dart';
-import 'package:webdriver/webdriver.dart';
+import 'package:webdriver/core.dart';
+import 'package:webdriver/io.dart';
import '../test_util.dart';
@@ -24,7 +25,7 @@
group('create', () {
test('default', () async {
WebDriver driver = await createTestDriver();
- await driver.get('http://www.google.com');
+ await driver.navigate.to('http://www.google.com');
var element = await driver.findElement(new By.name('q'));
expect(await element.name, 'input');
await driver.quit();
@@ -32,7 +33,7 @@
test('chrome', () async {
WebDriver driver = await createTestDriver();
- await driver.get('http://www.google.com');
+ await driver.navigate.to('http://www.google.com');
var element = await driver.findElement(new By.name('q'));
expect(await element.name, 'input');
await driver.quit();
@@ -42,9 +43,8 @@
// Avoid this test on the bot; currently we just test against chromedriver.
if (isRunningOnTravis()) return;
- WebDriver driver = await WebDriver.createDriver(
- desiredCapabilities: Capabilities.firefox);
- await driver.get('http://www.google.com');
+ WebDriver driver = await createDriver(desired: Capabilities.firefox);
+ await driver.navigate.to('http://www.google.com');
var element = await driver.findElement(new By.name('q'));
expect(await element.name, 'input');
await driver.quit();
@@ -56,15 +56,15 @@
setUp(() async {
driver = await createTestDriver();
- await driver.get(testPagePath);
+ await driver.navigate.to(testPagePath);
});
tearDown(() => driver.quit());
test('get', () async {
- await driver.get('http://www.google.com');
+ await driver.navigate.to('http://www.google.com');
await driver.findElement(new By.name('q'));
- await driver.get('http://www.yahoo.com');
+ await driver.navigate.to('http://www.yahoo.com');
await driver.findElement(new By.name('p'));
});
@@ -72,7 +72,7 @@
var url = await driver.currentUrl;
expect(url, startsWith('file:'));
expect(url, endsWith('test_page.html'));
- await driver.get('http://www.google.com');
+ await driver.navigate.to('http://www.google.com');
url = await driver.currentUrl;
expect(url, contains('www.google.com'));
});
diff --git a/test/src/web_element_test.dart b/test/src/web_element_test.dart
index fd846c7..dfe3db7 100644
--- a/test/src/web_element_test.dart
+++ b/test/src/web_element_test.dart
@@ -15,7 +15,7 @@
library webdriver_test.web_element;
import 'package:unittest/unittest.dart';
-import 'package:webdriver/webdriver.dart';
+import 'package:webdriver/core.dart';
import '../test_util.dart';
@@ -32,7 +32,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.get(testPagePath);
+ await driver.navigate.to(testPagePath);
table = await driver.findElement(new By.tagName('table'));
button = await driver.findElement(new By.tagName('button'));
form = await driver.findElement(new By.tagName('form'));
diff --git a/test/src/window_test.dart b/test/src/window_test.dart
index 1e396f2..007d730 100644
--- a/test/src/window_test.dart
+++ b/test/src/window_test.dart
@@ -17,7 +17,8 @@
import 'dart:math' show Point, Rectangle;
import 'package:unittest/unittest.dart';
-import 'package:webdriver/webdriver.dart';
+import 'package:webdriver/async_helpers.dart';
+import 'package:webdriver/core.dart';
import '../test_util.dart';
@@ -38,7 +39,7 @@
expect(await window.size, size);
});
- test('location', () async {
+ skip_test('location', () async {
var window = await driver.window;
var position = const Point<int>(100, 200);
await window.setLocation(position);
diff --git a/test/test_util.dart b/test/test_util.dart
index 9093edd..77543cb 100644
--- a/test/test_util.dart
+++ b/test/test_util.dart
@@ -20,8 +20,8 @@
import 'package:path/path.dart' as path;
import 'package:matcher/matcher.dart' show Matcher, isInstanceOf;
-import 'package:webdriver/webdriver.dart'
- show Capabilities, WebDriver, WebElement;
+import 'package:webdriver/io.dart'
+ show Capabilities, WebDriver, WebElement, createDriver;
final Matcher isWebElement = new isInstanceOf<WebElement>();
final Matcher isRectangle = new isInstanceOf<Rectangle<int>>();
@@ -70,5 +70,5 @@
capabilities.addAll(additionalCapabilities);
}
- return WebDriver.createDriver(desiredCapabilities: capabilities);
+ return createDriver(desired: capabilities);
}