test_webdriver 0.0.6

Pub Build Status

test_webdriver provides simple utility functions to setup a test environment with a webdriver and pageloader. It makes it easier to receive pageobjects within the testcases.

Writing Tests #

Tests which require pageobjects and a running webdriver should be within a suite block.

import 'package:test_webdriver/test_webdriver.dart';

void main() {
  group('My Test-Suite', suite(() {
    test('handle login', withPO((LoginPO po) async {
      expect(await po.handleLogin('test', 'test'), isTrue);
      expect(await driver.title, contains('Dashboard of'));

There are wrapper functions which inject objects into their body function using the current suite:

  • withPO injects a pageobject into the body.
  • withDriver injects the WebDriver into the body.

These helpers are available within the body function of the previous named wrappers:

  • driver returns the WebDriver
  • object looks up a PageObject

Timeouts #

Timeouts are provided by the default timeout settings within the test package. For further details see test README.md

test('should wait until object is available', withPO((DelayedPO po) async {
  expect(await po.element.innerText, 'test');
}), timeout: new Timeout(const Duration(seconds: 6)));

In order for this to work, the test_webdriver waits for pageobject by default. To prevent this waiting mechanism and force an instant check use useWaitFor: false within withPO.

test('should wait until object is available', withPO((DelayedPO po) async {
  expect(await po.element.innerText, 'test');
}, useWaitFor: false));

In case the timeout of fetching the pageobject should differ to the timeout of the test case, use the specific timeout settings provided by withPO.

test('should wait until object is available', withPO((DelayedPO po) async {
  expect(await po.element.innerText, 'test');
}, timeout: const Duration(seconds: 2)), timeout: new Timeout.factor(2));

Running Tests #

The package doesn't ship with a selenium server, therefore the actual selenium server (ex. chromedriver) needs to be started before running the tests. In order to run the suite pass the environment variable DRIVER_URI to the test process.

DRIVER_URI=http://localhost:9515/ pub run test

Setting up chrome headless #

To run chrome in headless mode setup the proper configuration in dart_webdriver.yaml:

    args: ['--headless']

0.0.6 #

  • Add suiteSetUp for initiators within the parent suite
  • Add suiteTearDown for tear down callbacks within the parent suite
  • Add Suite.storage to provide a key-value-storage within a suite shared across parent, child suites

0.0.5 #

  • Print PageObject name within exception if PageLoaderException occurs

0.0.4+1 #

  • Fix population of PageLoaderException
  • Ignore SocketException when Suite executes tearDownAll (appears when the driver is no longer reachable)

0.0.4 #

  • Only catch StateError in withPO (populate invalid PageObject exceptions PageLoaderException correctly)
  • Support multiple PageObjects arguments in withPO
  • Add forceSuite parameter to withPO to `

0.0.3 #

  • Support nested suites calls to share only one suite

0.0.2 #

  • Support waitFor functionality within withPO
  • Support capabilities configuration within configuration. Includes optional configuration of headless mode instead of explicit set (see README.md)
  • Provide timeout settings

0.0.1 #

  • Initial release

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  test_webdriver: ^0.0.6

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:test_webdriver/test_webdriver.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0