webdriver 2.1.1

  • Readme
  • Changelog
  • Installing
  • 89

webdriver #

Build Status pub package

Provides WebDriver bindings for Dart. These use the WebDriver JSON interface, and as such, require the use of the WebDriver remote server.

Installing #

  1. Depend on it

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

      webdriver: any

    If your package is an application package you should use any as the version constraint.

  2. Install it

    If you're using IntelliJ, choose:

    Control + Shift + A > Pub: Get Dependencies

    If you're using the Dart Editor, choose:

    Menu > Tools > Pub Install

    Or if you want to install from the command line, run:

    $ pub install
  3. Import it

    Now in your Dart code, you can use:

    import 'package:webdriver/io.dart';
    WebDriver driver = createDriver(...);

    This will use by default the asynchronous, JSON wire spec implementation. You now can also use a synchronous version of WebDriver:

    import 'package:webdriver/sync_io.dart';
    final driver = createDriver(...);

    This version of WebDriver supports both the JSON wire spec and W3C spec, allowing use with modern versions of Firefox. This defaults to the JSON wire spec, but can also be configured to use the W3C spec or even to try and automatically infer the spec during session creation:

     final w3cDriver = createDriver(spec: WebDriverSpec.W3c);  // Use W3C spec.
     final anyDriver = createDriver(spec: WebDriverSpec.Auto); // Infer spec.

Testing #

Unfortunately using bazel with Dart libraries and Dart WebDriver is not yet supported. We hope to add this at some point, but for now pub still works.

As a consequence, running tests is a bit more complicated than we'd like:

  1. Launch a WebDriver binar(ies).

    First, bring up chromedriver / geckodriver. Other conforming WebDriver binaries should work as well, but we test against these:

    chromedriver --port=4444 --url-base=wd/hub --verbose
    geckodriver --port=4445

    ChromeDriver is used to test our JSON wire spec implementation, and geckodriver is used to test our W3C spec implementation.

    Synchronous tests are labeled as Chrome/Firefox. All async tests run exclusively against Chrome (as async, like ChromeDriver supports only the old JSON wire spec).

  2. Run a test. All files suffixed with '_test.dart' are tests.

    pub run test/path/to/test.dart -r expanded -p vm

    Or to run all tests:

    pub run test -r expanded -p vm

    You should probably go get a coffee or something, this is gonna take awhile.

v2.1.1 #

  • Forward-compatible fix for upcoming Dart SDK breaking change (HttpClientResponse implementing Stream<Uint8List>)

v2.1.0 #

  • Full support of JsonWire and W3C protocol specs in sync and async WebDriver.

v2.0.0 #

  • Dropped support for pkg:unittest.
  • Add W3C spec mouse and keyboard support.
  • Remove deprecated methods in async WebDriver.

The two big changes are the addition of support for synchronous communication via the package:sync_http (along with an accompanying synchronous API) and support for the W3C spec.

Currently, only the synchronous API supports the W3C spec, but in the future both asynchronous and synchronous APIs will support this.

v1.2.4 #

  • Adds null check for status before checking status code. Avoids throwing exceptions if status code is not present. (Due to oversight this was never properly released.)

v1.2.3 #

  • Enable generics for waitFor.

v1.2.2+1 #

  • Disable generics for waitFor.

v1.2.2 #

  • Refactor tests.
  • Make project buildable and testable with Bazel.

v1.2.1 #

  • Enable redirects to handle 303 responses from Selenium.

v1.2.0 #

  • Fix all strong mode errors.

v1.1.1 #

  • Fix some analyzer warnings.
  • _performRequest now uses whenComplete, not finally (#119).

v1.1.0 #

  • Added WebDriver.captureScreenshotAsBase64(), which returns the screenshot as a base64-encoded string.
  • Added WebDriver.captureScreenshotAsList(), which returns the screenshot as list of uint8.
  • Deprecated WebDriver.captureScreenshot() due to bad performance (#114). Please use the new screenshot methods instead.
  • Removed dependency on crypto package.

Thanks to @blackhc and @xavierhainaux for the contributions.

v1.0.0 #

No functional change, just bumping the version number.

v0.10.0-pre.15 #

  • Add Future-based listeners to web_driver.dart.
  • Use google.com/ncr to avoid redirect when running outside US
  • Add chords support to keyboard.dart.
  • Add enum for mouse buttons (breaking API change!)

v0.10.0-pre.14 #

  • Adds support for enabling/disabling listeners to WebDriver.
  • Adds awaitChecking mode to Lock class.

v0.10.0-pre.13 #

  • Lots of cleanup and new features.

v0.10.0-pre.12 #

  • Adds a Stepper interface and StdioStepper which allows control of execution of WebDriver commands.

v0.10.0-pre.11 #

  • Improve exception stack traces.
  • Add option to quit() to not end the WebDriver session.

v0.10.0-pre.10 #

  • Minor updates.

v0.10.0-pre.9 #

  • Adds command listening.

v0.10.0-pre.8 #

  • Add support/forwarder.dart.
  • Move async_helpers.dart to support/async.dart.

v0.10.0-pre.7 #

  • Fix expect implementation.

v0.10.0-pre.6 #

  • Fixes to pubspec.
  • Added missing copyright notices.

v0.10.0-pre.4 #

  • Various cleanup.
  • Change captureScreenshot to return Stream.

v0.10.0-pre.3 #

  • Rename some methods.
  • Add WebDriver.get() and remove WebDriver.navigate.to().

v0.10.0-pre.2 #

  • Added close() method to CommandProcessor that gets called by WebDriver.quit().
  • Ensure that HttpClient in _IOCommandProcessor gets closed.
  • Add fromExistingSession() functions to allow creation of WebDriver instances connected to existing sessions.

v0.10.0-pre.1 #

  • Isolate HTTP code from the rest of the WebDriver implementation.
  • Create support for running WebDriver from inside browser.
  • Other cleanup.

Use this package as a library

1. Depend on it

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

  webdriver: ^2.1.1

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:webdriver/async_core.dart';
import 'package:webdriver/async_html.dart';
import 'package:webdriver/async_io.dart';
import 'package:webdriver/core.dart';
import 'package:webdriver/io.dart';
import 'package:webdriver/support/async.dart';
import 'package:webdriver/support/firefox_profile.dart';
import 'package:webdriver/support/forwarder.dart';
import 'package:webdriver/support/stdio_stepper.dart';
import 'package:webdriver/sync_core.dart';
import 'package:webdriver/sync_io.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.

We analyzed this package on Jan 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.4

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and webdriver.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
archive >=1.0.0 <3.0.0 2.0.13
matcher ^0.12.3 0.12.6
path ^1.3.0 1.6.4
stack_trace ^1.3.0 1.9.3
sync_http ^0.1.1 0.1.4
Transitive dependencies
args 1.5.2
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.4
typed_data 1.1.6
Dev dependencies
test ^1.0.0