test_webdriver 0.0.4

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 63

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:

capabilities:
  chromeOptions:
    args: ['--headless']

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

1. Depend on it

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


dependencies:
  test_webdriver: "^0.0.4"

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';
        
Version Uploaded Documentation Archive
0.0.4 Jan 12, 2018 Go to the documentation of test_webdriver 0.0.4 Download test_webdriver 0.0.4 archive
0.0.3 Dec 19, 2017 Go to the documentation of test_webdriver 0.0.3 Download test_webdriver 0.0.3 archive
0.0.2 Dec 18, 2017 Go to the documentation of test_webdriver 0.0.2 Download test_webdriver 0.0.2 archive
0.0.1 Dec 17, 2017 Go to the documentation of test_webdriver 0.0.1 Download test_webdriver 0.0.1 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
26 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
63

Platforms

Detected platforms: other

Primary library: package:test_webdriver/test_webdriver.dart with components: io, mirrors.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use test_webdriver.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
pageloader ^2.2.6 2.2.6
test ^0.12.25 0.12.30+1
webdriver ^1.2.3 1.2.3 2.0.0-beta
yaml ^2.1.11 2.1.13
Transitive dependencies
analyzer 0.31.0+1
archive 1.0.33
args 1.3.0
async 2.0.3
barback 0.15.2+14
boolean_selector 1.0.2
charcode 1.1.1
cli_util 0.1.2+1
collection 1.14.5
convert 2.0.1
crypto 2.0.2+1
csslib 0.14.1
front_end 0.1.0-alpha.8
glob 1.1.5
html 0.13.2+2
http 0.11.3+16
http_multi_server 2.0.4
http_parser 3.1.1
io 0.3.2+1
isolate 1.1.0
js 0.6.1
kernel 0.3.0-alpha.5
logging 0.11.3+1
matcher 0.12.1+4
meta 1.1.2
mime 0.9.6
multi_server_socket 1.0.1
node_preamble 1.4.0
package_config 1.0.3
package_resolver 1.0.2
path 1.5.1
plugin 0.2.0+2
pool 1.3.4
pub_semver 1.3.2
shelf_packages_handler 1.0.3
shelf_static 0.2.7
shelf_web_socket 0.2.2
source_map_stack_trace 1.1.4
source_maps 0.10.4
source_span 1.4.0
stack_trace 1.9.1
stream_channel 1.6.3
string_scanner 1.0.2
term_glyph 1.0.0
typed_data 1.1.5
unittest 0.11.7 0.12.4+1
utf 0.9.0+4
watcher 0.9.7+7
web_socket_channel 1.0.6
Dev dependencies
metatest ^0.2.0
mockito ^2.2.0
shelf ^0.7.2 0.7.2