test_webdriver 0.0.6

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 54

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.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:


dependencies:
  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';
  
Version Uploaded Documentation Archive
0.0.6 Mar 10, 2018 Go to the documentation of test_webdriver 0.0.6 Download test_webdriver 0.0.6 archive
0.0.5 Mar 9, 2018 Go to the documentation of test_webdriver 0.0.5 Download test_webdriver 0.0.5 archive
0.0.4+1 Mar 9, 2018 Go to the documentation of test_webdriver 0.0.4+1 Download test_webdriver 0.0.4+1 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

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
8 / 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]
54
Learn more about scoring.

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.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Strong-mode analysis of lib/test_webdriver.dart gave the following hint:

    line: 79 col: 48
    'isInstanceOf' is deprecated and shouldn't be used.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
meta ^1.1.2 1.1.5
pageloader ^2.2.6 2.2.6 3.0.0-alpha
test ^0.12.25 0.12.42 1.0.0
webdriver ^1.2.3 1.2.3 2.0.0-beta
yaml ^2.1.11 2.1.14
Transitive dependencies
analyzer 0.32.1
archive 1.0.33 2.0.0
args 1.4.3
async 2.0.7
boolean_selector 1.0.3
charcode 1.1.1
collection 1.14.10
convert 2.0.1
crypto 2.0.5
csslib 0.14.4
front_end 0.1.1
glob 1.1.5
html 0.13.3+1
http 0.11.3+16
http_multi_server 2.0.5
http_parser 3.1.2
io 0.3.2+1
js 0.6.1
json_rpc_2 2.0.8
kernel 0.3.1
logging 0.11.3+1
matcher 0.12.3
mime 0.9.6+1
multi_server_socket 1.0.1
node_preamble 1.4.2
package_config 1.0.3
package_resolver 1.0.3
path 1.6.1
plugin 0.2.0+2
pool 1.3.5
pub_semver 1.4.1
shelf_packages_handler 1.0.3
shelf_static 0.2.7+1
shelf_web_socket 0.2.2+2
source_map_stack_trace 1.1.4
source_maps 0.10.5
source_span 1.4.0
stack_trace 1.9.2
stream_channel 1.6.7+1
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
vm_service_client 0.2.4+3
watcher 0.9.7+8
web_socket_channel 1.0.8
Dev dependencies
metatest ^0.2.0
mockito ^2.2.0
shelf ^0.7.2 0.7.3+1