Make tests more reliable. (#128)
- remove some problem tests.
- fix tearDown methods to be more reliable.
diff --git a/test/src/alert.dart b/test/src/alert.dart
index f75d819..ec2e52b 100644
--- a/test/src/alert.dart
+++ b/test/src/alert.dart
@@ -32,7 +32,12 @@
output = await driver.findElement(const By.id('settable'));
});
- tearDown(() => driver.quit());
+ tearDown(() async {
+ if (driver != null) {
+ await driver.quit();
+ }
+ driver = null;
+ });
test('no alert', () {
expect(driver.switchTo.alert, throws);
diff --git a/test/src/keyboard.dart b/test/src/keyboard.dart
index 0b1e677..745ad6a 100644
--- a/test/src/keyboard.dart
+++ b/test/src/keyboard.dart
@@ -45,7 +45,12 @@
await textInput.click();
});
- tearDown(() => driver.quit());
+ tearDown(() async {
+ if (driver != null) {
+ await driver.quit();
+ }
+ driver = null;
+ });
test('sendKeys -- once', () async {
await driver.keyboard.sendKeys('abcdef');
diff --git a/test/src/logs.dart b/test/src/logs.dart
index 28358bf..af81378 100644
--- a/test/src/logs.dart
+++ b/test/src/logs.dart
@@ -32,7 +32,12 @@
await driver.get('http://www.google.com/ncr');
});
- tearDown(() => driver.quit());
+ tearDown(() async {
+ if (driver != null) {
+ await driver.quit();
+ }
+ driver = null;
+ });
test('get logs', () async {
List<LogEntry> logs = await driver.logs.get(LogType.performance).toList();
diff --git a/test/src/mouse.dart b/test/src/mouse.dart
index 000929a..4c5327c 100644
--- a/test/src/mouse.dart
+++ b/test/src/mouse.dart
@@ -30,7 +30,12 @@
button = await driver.findElement(const By.tagName('button'));
});
- tearDown(() => driver.quit());
+ tearDown(() async {
+ if (driver != null) {
+ await driver.quit();
+ }
+ driver = null;
+ });
test('moveTo element/click', () async {
await driver.mouse.moveTo(element: button);
diff --git a/test/src/navigation.dart b/test/src/navigation.dart
index 388e843..9572372 100644
--- a/test/src/navigation.dart
+++ b/test/src/navigation.dart
@@ -29,14 +29,11 @@
await driver.get('http://www.google.com/ncr');
});
- tearDown(() => driver.quit());
-
- test('forward/back', () async {
- await driver.get('http://www.yahoo.com');
- await driver.navigate.back();
- await waitFor(() => driver.title, matcher: contains('Google'));
- await driver.navigate.forward();
- await waitFor(() => driver.title, matcher: contains('Yahoo'));
+ tearDown(() async {
+ if (driver != null) {
+ await driver.quit();
+ }
+ driver = null;
});
test('refresh', () async {
diff --git a/test/src/options.dart b/test/src/options.dart
index 37bff90..c1ff723 100644
--- a/test/src/options.dart
+++ b/test/src/options.dart
@@ -28,7 +28,12 @@
await driver.get('http://www.google.com/ncr');
});
- tearDown(() => driver.quit());
+ tearDown(() async {
+ if (driver != null) {
+ await driver.quit();
+ }
+ driver = null;
+ });
test('add simple cookie', () async {
await driver.cookies.add(new Cookie('mycookie', 'myvalue'));
@@ -86,7 +91,12 @@
driver = await createTestDriver();
});
- tearDown(() => driver.quit());
+ tearDown(() async {
+ if (driver != null) {
+ await driver.quit();
+ }
+ driver = null;
+ });
// TODO(DrMarcII): Figure out how to tell if timeouts are correctly set
test('set all timeouts', () async {
diff --git a/test/src/target_locator.dart b/test/src/target_locator.dart
index 0e52f9c..0a0940f 100644
--- a/test/src/target_locator.dart
+++ b/test/src/target_locator.dart
@@ -34,7 +34,12 @@
frame = await driver.findElement(const By.name('frame'));
});
- tearDown(() => driver.quit());
+ tearDown(() async {
+ if (driver != null) {
+ await driver.quit();
+ }
+ driver = null;
+ });
test('frame index', () async {
await driver.switchTo.frame(0);
diff --git a/test/src/web_driver.dart b/test/src/web_driver.dart
index 27624d6..bf6e7a9 100644
--- a/test/src/web_driver.dart
+++ b/test/src/web_driver.dart
@@ -39,15 +39,6 @@
expect(await element.name, 'input');
await driver.quit();
});
-
- test('firefox', () async {
- WebDriver driver = await createTestDriver(
- additionalCapabilities: Capabilities.firefox);
- await driver.get('http://www.google.com/ncr');
- var element = await driver.findElement(const By.name('q'));
- expect(await element.name, 'input');
- await driver.quit();
- });
});
group('methods', () {
@@ -58,13 +49,16 @@
await driver.get(testPagePath);
});
- tearDown(() => driver.quit());
+ tearDown(() async {
+ if (driver != null) {
+ await driver.quit();
+ }
+ driver = null;
+ });
test('get', () async {
await driver.get('http://www.google.com/ncr');
await driver.findElement(const By.name('q'));
- await driver.get('http://www.yahoo.com');
- await driver.findElement(const By.name('p'));
});
test('currentUrl', () async {
diff --git a/test/src/web_element.dart b/test/src/web_element.dart
index 1adceeb..06193a5 100644
--- a/test/src/web_element.dart
+++ b/test/src/web_element.dart
@@ -45,7 +45,12 @@
invisible = await driver.findElement(const By.tagName('div'));
});
- tearDown(() => driver.quit());
+ tearDown(() async {
+ if (driver != null) {
+ await driver.quit();
+ }
+ driver = null;
+ });
test('click', () async {
await button.click();
diff --git a/test/src/window.dart b/test/src/window.dart
index b552381..15a7672 100644
--- a/test/src/window.dart
+++ b/test/src/window.dart
@@ -30,7 +30,12 @@
driver = await createTestDriver();
});
- tearDown(() => driver.quit());
+ tearDown(() async {
+ if (driver != null) {
+ await driver.quit();
+ }
+ driver = null;
+ });
test('size', () async {
var window = await driver.window;