Adds support for creating Firefox instances for use in tests. (#153)
* Refactor tests to allow passing of WebDriver creation function. Allows same test to be used for Firefox and Chrome.
* Ran dartfmt over test dir.
* Adds Firefox test (not yet working) and option to run against Firefox.
* Create useful Firefox test.
* Dartfmt
* Add support for running Firefox in Travis.
* Update travis.yml to not specify entire firefox path.
diff --git a/.travis.yml b/.travis.yml
index eee6283..9c6c024 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,6 +9,7 @@
- google-chrome
packages:
- google-chrome-stable
+ firefox: latest
dart:
- dev
@@ -24,6 +25,7 @@
- export CHROMEDRIVER_BINARY=/usr/bin/google-chrome
- export CHROMEDRIVER_ARGS=--no-sandbox
- /usr/bin/google-chrome --version
+ - firefox --version
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
@@ -32,6 +34,9 @@
- wget http://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- export PATH=$PATH:$PWD
+ - wget https://github.com/mozilla/geckodriver/releases/download/v0.17.0/geckodriver-v0.17.0-linux64.tar.gz
+ - tar -xvzf geckodriver-v0.17.0-linux64.tar.gz
+ - export PATH=$PATH:$PWD
- ./tool/travis-setup.sh
script:
diff --git a/test/firefox_creation_test.dart b/test/firefox_creation_test.dart
new file mode 100644
index 0000000..41632ae
--- /dev/null
+++ b/test/firefox_creation_test.dart
@@ -0,0 +1,30 @@
+// Copyright 2017 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.
+
+import 'package:test/test.dart';
+
+import 'sync/sync_io_config.dart' as config;
+
+void main() {
+ group('Firefox creation ', () {
+ test('fails as expected', () {
+ try {
+ final driver = config.createFirefoxTestDriver();
+ fail('Still using JSON wire spec, should not parse correctly.');
+ } catch (e) {
+ // Expected.
+ }
+ });
+ }, timeout: new Timeout(new Duration(minutes: 1)));
+}
diff --git a/test/sync/sync_io_config.dart b/test/sync/sync_io_config.dart
index 5a30721..306d245 100644
--- a/test/sync/sync_io_config.dart
+++ b/test/sync/sync_io_config.dart
@@ -24,6 +24,20 @@
typedef WebDriver createTestDriver(
{Map<String, dynamic> additionalCapabilities});
+final Uri _defaultChromeUri = Uri.parse('http://127.0.0.1:4444/wd/hub/');
+final Uri _defaultFirefoxUri = Uri.parse('http://127.0.0.1:4445/');
+
+/// TODO(staats): this needs to be the W3C spec.
+WebDriver createFirefoxTestDriver(
+ {Map<String, dynamic> additionalCapabilities}) {
+ final capabilities = Capabilities.firefox;
+
+ if (additionalCapabilities != null) {
+ capabilities.addAll(additionalCapabilities);
+ }
+ return createDriver(uri: _defaultFirefoxUri, desired: capabilities);
+}
+
WebDriver createChromeTestDriver(
{Map<String, dynamic> additionalCapabilities}) {
var capabilities = Capabilities.chrome;
@@ -47,5 +61,5 @@
capabilities.addAll(additionalCapabilities);
}
- return createDriver(desired: additionalCapabilities);
+ return createDriver(uri: _defaultChromeUri, desired: additionalCapabilities);
}
diff --git a/tool/travis.sh b/tool/travis.sh
index ebd46dd..14d05e4 100755
--- a/tool/travis.sh
+++ b/tool/travis.sh
@@ -25,7 +25,11 @@
# Start chromedriver.
chromedriver --port=4444 --url-base=wd/hub &
-PID=$!
+PIDC=$!
+
+# Start geckodriver (Firefox).
+geckodriver --port=4445 &
+PIDG=$!
# Run tests.
pub run test -r expanded -p vm -j 1
@@ -34,7 +38,8 @@
STATUS=$TEST_STATUS
fi
-# Exit chromedriver.
-kill $PID
+# Exit chromedriver and geckodriver.
+kill $PIDC
+kill $PIDG
exit $STATUS