Merge pull request #58 from DrMarcII/master
Rename get, post, and delete methods on WebDriver.
diff --git a/lib/src/common.dart b/lib/src/common.dart
index 0abc4ff..1c3afc2 100644
--- a/lib/src/common.dart
+++ b/lib/src/common.dart
@@ -43,11 +43,11 @@
_WebDriverBase(this.driver, this._prefix);
Future _post(String command, [param]) =>
- driver.post(_resolve(command), param);
+ driver.postRequest(_resolve(command), param);
- Future _get(String command) => driver.get(_resolve(command));
+ Future _get(String command) => driver.getRequest(_resolve(command));
- Future _delete(String command) => driver.delete(_resolve(command));
+ Future _delete(String command) => driver.deleteRequest(_resolve(command));
String _resolve(command) {
if (_prefix == null || _prefix.isEmpty) {
diff --git a/lib/src/navigation.dart b/lib/src/navigation.dart
index ed6e0bd..5ac422d 100644
--- a/lib/src/navigation.dart
+++ b/lib/src/navigation.dart
@@ -17,13 +17,6 @@
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/web_driver.dart b/lib/src/web_driver.dart
index 5a40159..173b8fc 100644
--- a/lib/src/web_driver.dart
+++ b/lib/src/web_driver.dart
@@ -27,15 +27,23 @@
this._prefix = uri.resolve('session/$id/');
/// The current url.
- Future<String> get currentUrl => get('url');
+ Future<String> get currentUrl => getRequest('url');
+
+ /// navigate to the specified url
+ Future get(/* Uri | String */ url) async {
+ if (url is Uri) {
+ url = url.toString();
+ }
+ await postRequest('url', {'url': url as String});
+ }
/// The title of the current page.
- Future<String> get title => get('title');
+ Future<String> get title => getRequest('title');
/// Search for multiple elements within the entire current page.
@override
Stream<WebElement> findElements(By by) async* {
- var elements = await post('elements', by);
+ var elements = await postRequest('elements', by);
int i = 0;
for (var element in elements) {
@@ -48,16 +56,16 @@
/// 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 postRequest('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 => getRequest('source');
/// Close the current window, quitting the browser if it is the last window.
Future close() async {
- await delete('window');
+ await deleteRequest('window');
}
/// Quit the browser.
@@ -71,7 +79,7 @@
/// Handles for all of the currently displayed tabs/windows.
Stream<Window> get windows async* {
- var handles = await get('window_handles');
+ var handles = await getRequest('window_handles');
for (var handle in handles) {
yield new Window._(this, handle);
@@ -80,14 +88,14 @@
/// Handle for the active tab/window.
Future<Window> get window async {
- var handle = await get('window_handle');
+ var handle = await getRequest('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 postRequest('element/active');
if (element != null) {
return new WebElement._(this, element[_element], this, 'activeElement');
}
@@ -109,7 +117,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() => getRequest('screenshot')
.then((screenshot) => CryptoUtils.base64StringToBytes(screenshot));
/// Inject a snippet of JavaScript into the page for execution in the context
@@ -130,7 +138,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 executeAsync(String script, List args) => post(
+ Future executeAsync(String script, List args) => postRequest(
'execute_async', {'script': script, 'args': args})
.then(_recursiveElementify);
@@ -146,7 +154,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) => postRequest(
'execute', {'script': script, 'args': args}).then(_recursiveElementify);
dynamic _recursiveElementify(result) {
@@ -167,12 +175,13 @@
}
}
- Future post(String command, [params]) =>
+ Future postRequest(String command, [params]) =>
_commandProcessor.post(_prefix.resolve(command), params);
- Future get(String command) => _commandProcessor.get(_prefix.resolve(command));
+ Future getRequest(String command) =>
+ _commandProcessor.get(_prefix.resolve(command));
- Future delete(String command) =>
+ Future deleteRequest(String command) =>
_commandProcessor.delete(_prefix.resolve(command));
@override
diff --git a/pubspec.yaml b/pubspec.yaml
index 45f3102..3c7e064 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: webdriver
-version: 0.10.0-pre.2
-author: Google Inc.
+version: 0.10.0-pre.3
+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.
diff --git a/test/src/alert_test.dart b/test/src/alert_test.dart
index f17a259..d4a5297 100644
--- a/test/src/alert_test.dart
+++ b/test/src/alert_test.dart
@@ -27,7 +27,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.navigate.to(testPagePath);
+ await driver.get(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 458451b..364cb83 100644
--- a/test/src/keyboard_test.dart
+++ b/test/src/keyboard_test.dart
@@ -26,7 +26,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.navigate.to(testPagePath);
+ await driver.get(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 5a0ced7..ecbf1b5 100644
--- a/test/src/logs_test.dart
+++ b/test/src/logs_test.dart
@@ -29,7 +29,7 @@
};
driver = await createTestDriver(additionalCapabilities: capabilities);
- await driver.navigate.to('http://www.google.com');
+ await driver.get('http://www.google.com');
});
tearDown(() => driver.quit());
diff --git a/test/src/mouse_test.dart b/test/src/mouse_test.dart
index b49769b..7cb3660 100644
--- a/test/src/mouse_test.dart
+++ b/test/src/mouse_test.dart
@@ -26,7 +26,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.navigate.to(testPagePath);
+ await driver.get(testPagePath);
button = await driver.findElement(const By.tagName('button'));
});
diff --git a/test/src/navigation_test.dart b/test/src/navigation_test.dart
index 542d4b6..6eb2024 100644
--- a/test/src/navigation_test.dart
+++ b/test/src/navigation_test.dart
@@ -26,13 +26,13 @@
setUp(() async {
driver = await createTestDriver();
- await driver.navigate.to('http://www.google.com/ncr');
+ await driver.get('http://www.google.com/ncr');
});
tearDown(() => driver.quit());
test('forward/back', () async {
- await driver.navigate.to('http://www.yahoo.com');
+ await driver.get('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 cf99ce1..057bec9 100644
--- a/test/src/options_test.dart
+++ b/test/src/options_test.dart
@@ -25,7 +25,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.navigate.to('http://www.google.com');
+ await driver.get('http://www.google.com');
});
tearDown(() => driver.quit());
diff --git a/test/src/target_locator_test.dart b/test/src/target_locator_test.dart
index 86cc139..730e22b 100644
--- a/test/src/target_locator_test.dart
+++ b/test/src/target_locator_test.dart
@@ -30,7 +30,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.navigate.to(testPagePath);
+ await driver.get(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 e74f882..66611d5 100644
--- a/test/src/web_driver_test.dart
+++ b/test/src/web_driver_test.dart
@@ -24,7 +24,7 @@
group('create', () {
test('default', () async {
WebDriver driver = await createTestDriver();
- await driver.navigate.to('http://www.google.com');
+ await driver.get('http://www.google.com');
var element = await driver.findElement(new By.name('q'));
expect(await element.name, 'input');
await driver.quit();
@@ -32,7 +32,7 @@
test('chrome', () async {
WebDriver driver = await createTestDriver();
- await driver.navigate.to('http://www.google.com');
+ await driver.get('http://www.google.com');
var element = await driver.findElement(new By.name('q'));
expect(await element.name, 'input');
await driver.quit();
@@ -44,7 +44,7 @@
WebDriver driver = await createTestDriver(
additionalCapabilities: Capabilities.firefox);
- await driver.navigate.to('http://www.google.com');
+ await driver.get('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.navigate.to(testPagePath);
+ await driver.get(testPagePath);
});
tearDown(() => driver.quit());
test('get', () async {
- await driver.navigate.to('http://www.google.com');
+ await driver.get('http://www.google.com');
await driver.findElement(new By.name('q'));
- await driver.navigate.to('http://www.yahoo.com');
+ await driver.get('http://www.yahoo.com');
await driver.findElement(new By.name('p'));
});
@@ -72,7 +72,7 @@
var url = await driver.currentUrl;
expect(url, anyOf(startsWith('file:'), startsWith('http:')));
expect(url, endsWith('test_page.html'));
- await driver.navigate.to('http://www.google.com');
+ await driver.get('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 eb6c02c..7233deb 100644
--- a/test/src/web_element_test.dart
+++ b/test/src/web_element_test.dart
@@ -32,7 +32,7 @@
setUp(() async {
driver = await createTestDriver();
- await driver.navigate.to(testPagePath);
+ await driver.get(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'));