Viewing version 3.2.0. Open the latest package page.

webdriver

3.2.0

Provides WebDriver bindings for Dart. Supports WebDriver JSON interface and W3C spec. Requires the use of WebDriver remote server.

Download archive

Readme

CI pub package package publisher

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

Using package:webdriver

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.

    dart test test/path/to/the_test.dart -r expanded -p vm
    

    Or to run all tests:

    dart test -r expanded -p vm
    

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

Changelog

3.2.0

  • Require Dart 3.4 and add a dependency on package:web.
  • Ensure HTTP clients are closed if creating a session fails.
  • Update functions that return List<int> to return Uint8List.

3.1.0

  • Add a reason argument to Clock.waitFor.
  • Explicitly close http clients on quit.

3.0.4

  • Require Dart 3.1.

3.0.3

  • Include a content-type header when sending requests from async_html.dart. The content-type is necessary for compatibility with GeckoDriver 0.27.0 and newer versions. The content-type header was already being sent in IO clients for a long time, so only the HTML client had to be updated.

3.0.2

  • Require Dart 2.18.
  • "Officially" deprecate core.dart and io.dart libraries.
  • Remove the dependency on package:archive.

3.0.1

  • Return Future with non-nullable generic from waitFor. The generic T may still be a nullable type where required.
  • Treat 405 response code as an unknown command for compatibility with GeckoDriver.

3.0.0

  • Stable release for null safety.

v2.1.2

  • Updated to latest version of sync_http.

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.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'webdriver:3.2.0'
pubspec.yaml
name: webdriver
version: 3.2.0
description: >-
  Provides WebDriver bindings for Dart. Supports WebDriver JSON interface and
  W3C spec. Requires the use of WebDriver remote server.
repository: https://github.com/google/webdriver.dart

environment:
  sdk: ^3.4.0

dependencies:
  matcher: ^0.12.10
  path: ^1.8.0
  stack_trace: ^1.10.0
  sync_http: ^0.3.0
  web: ^1.1.0

dev_dependencies:
  archive: ^4.0.2
  dart_flutter_team_lints: ^3.0.0
  test: ^1.24.0

Version history

VersionPublishedArchiveSHA-256
0.2.7On demandDownload533862f1…3827d7
0.2.8+2On demandDownloadd1767ffd…7dafde
0.2.9+7On demandDownload3dd0f4af…7ad820
0.3.1+1On demandDownloadcdb2de82…b3b788
0.3.2On demandDownloadbabf6ed8…db556f
0.3.4On demandDownloaddadf2181…edd083
0.3.5+1On demandDownloadd3ac9f97…96e8d4
0.3.7+6On demandDownloadda10e0f8…19c261
0.4.0On demandDownload33e32b4a…3ab62a
0.4.1On demandDownload77c8526f…76b597
0.4.2On demandDownload6b2d0801…00d2e6
0.4.3+1On demandDownloadb9948b90…6051f0
0.4.4+4On demandDownload6484bb7a…9e2d84
0.4.5+1On demandDownload267cf558…71557e
0.4.7+1On demandDownload60320993…f26ed5
0.5.0+1On demandDownload855653b4…db029e
0.5.1On demandDownload55ac5726…e38b9f
0.5.4On demandDownload2fff77be…44ab2d
0.5.5On demandDownload21dd541b…979c59
0.5.6On demandDownloadd06a762e…a4d193
0.5.7On demandDownload06685b63…3c58e2
0.5.9On demandDownload8e38424f…ed85b3
0.5.11+1On demandDownload9638f6aa…f2a72c
0.5.12On demandDownload2fec7d9e…3e8492
0.5.13On demandDownloadf5739110…5a3a9b
0.5.14+1On demandDownload3122d43a…774f6a
0.5.14+3On demandDownloadfceb4351…de5a15
0.5.15On demandDownloadf89aefe3…f54e45
0.5.16On demandDownload1fee8425…063214
0.5.17On demandDownload44c5a60e…0265a9
0.5.20On demandDownload8ed56d4f…70e43b
0.6.1On demandDownload632ff7d8…a59874
0.6.2On demandDownloada2d631cf…1b58be
0.6.3+1On demandDownload45250954…014912
0.6.5On demandDownload768181d1…1d5715
0.6.6On demandDownload07196241…ff9b33
0.6.8On demandDownload0e029dda…9848c0
0.6.9On demandDownloadff3d8791…3c1b87
0.6.9+2On demandDownload7cea84ee…8d5d12
0.6.10On demandDownload2beb0cc3…25001a
0.7.0On demandDownload91f38787…cd2e96
0.7.1On demandDownloadf63749d0…eec201
0.7.2On demandDownloaddb1565a1…a25f51
0.7.3On demandDownload92915a64…6ef767
0.7.4On demandDownload46c7867f…3a98d1
0.7.5On demandDownloadfcf6f625…557c3e
0.8.7On demandDownload306f0844…b2b12f
0.8.8On demandDownloadd8aafb6a…c85160
0.9.0On demandDownload1414d8b2…757a47
0.9.1On demandDownloadb33f461b…3e3e95
0.10.0-pre.2On demandDownload4ace7b34…4fb146
0.10.0-pre.3On demandDownload9019d98e…7404d5
0.10.0-pre.5On demandDownload6bc7c27a…a1dd5b
0.10.0-pre.6On demandDownloadde941984…c059d1
0.10.0-pre.7On demandDownloaded5b7f34…12facc
0.10.0-pre.8On demandDownloadc8a610f7…6cd94f
0.10.0-pre.9On demandDownloade6e1a943…beb6b4
0.10.0-pre.10On demandDownload225f1864…7e14c1
0.10.0-pre.11On demandDownload02f81379…0a9515
0.10.0-pre.12On demandDownloaddd8cd51b…43aba3
0.10.0-pre.13On demandDownloade297fc4c…57bf25
0.10.0-pre.15On demandDownload2f83cf89…155676
1.0.0On demandDownload79bc8135…4c4957
1.1.0On demandDownload38e810c7…12623b
1.1.1On demandDownload5b6d47be…01243a
1.2.0On demandDownload1507bb4f…7e2032
1.2.1On demandDownloadb86c6336…98cb5e
1.2.2On demandDownload893b424f…e8201f
1.2.2+1On demandDownloadcb876f11…c71652
1.2.3On demandDownload6c07e7c2…7b3189
2.0.0-betaOn demandDownload08d9a264…e25653
2.0.0-beta+1On demandDownload7c92be2a…f42e0f
2.0.0On demandDownloada639bfab…a7330d
2.1.0On demandDownloadbb56bd41…54a706
2.1.1On demandDownloadc29ed375…4865c4
2.1.2On demandDownloadaf7ac0e9…2d7c92
3.0.0-nullsafety.0On demandDownloade22e0d31…6a3ee4
3.0.0-nullsafety.1On demandDownloadf775f1dd…f0242e
3.0.0On demandDownload404f637d…485886
3.0.1On demandDownloadef67178f…f9d841
3.0.2On demandDownload3c923e91…f86c49
3.0.3On demandDownload003d7da9…ed845e
3.0.4On demandDownload3d773670…4d61c8
3.1.0Cached · Upstream SHA-256 matchedDownload2f3a14ca…a7cade
3.2.0Cached · Upstream SHA-256 matchedDownload28b82ec8…e5657e

Dependencies

matcher "^0.12.10"

path "^1.8.0"

stack_trace "^1.10.0"

sync_http "^0.3.0"

web "^1.1.0"