Skip to content

cleanup #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
sdk: [dev]
sdk: [2.18.0, dev]
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
Expand All @@ -66,7 +66,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
sdk: [2.14.0, dev]
sdk: [2.18.0, dev]
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.0.2-dev

* Require Dart 2.18
* "Officially" deprecate `core.dart` and `io.dart` libraries.

## 3.0.1

* Return Future with non-nullable generic from `waitFor`. The generic `T` may
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![CI](https://github.com/google/webdriver.dart/actions/workflows/ci.yaml/badge.svg)](https://github.com/google/webdriver.dart/actions/workflows/ci.yaml)
[![pub package](https://img.shields.io/pub/v/webdriver.svg)](https://pub.dartlang.org/packages/webdriver)
[![package publisher](https://img.shields.io/pub/publisher/webdriver.svg)](https://pub.dev/packages/webdriver/publisher)

Provides WebDriver bindings for Dart. These use the WebDriver JSON interface,
and as such, require the use of the WebDriver remote server.
Expand All @@ -12,8 +13,8 @@ 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:
This will use by default the asynchronous, JSON wire spec implementation. You
now can also use a synchronous version of WebDriver:

```dart
import 'package:webdriver/sync_io.dart';
Expand All @@ -22,9 +23,9 @@ 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:
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:

```dart
final w3cDriver = createDriver(spec: WebDriverSpec.W3c); // Use W3C spec.
Expand All @@ -35,11 +36,11 @@ 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.
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).
1. Launch a WebDriver binar(ies).

First, bring up chromedriver / geckodriver. Other conforming WebDriver
binaries should work as well, but we test against these:
Expand All @@ -53,19 +54,19 @@ As a consequence, running tests is a bit more complicated than we'd like:
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).
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.
2. Run a test. All files suffixed with `_test.dart` are tests.

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

Or to run *all* tests:
Or to run _all_ tests:

```
pub run test -r expanded -p vm
dart test -r expanded -p vm
```

You should probably go get a coffee or something, this is gonna take a while.
63 changes: 30 additions & 33 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
# https://dart.dev/guides/language/analysis-options
include: package:lints/recommended.yaml

analyzer:
strong-mode:
implicit-casts: false
language:
strict-casts: true

linter:
rules:
- avoid_empty_else
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
- always_declare_return_types
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_returning_null_for_future
- avoid_returning_this
- avoid_unused_constructor_parameters
- await_only_futures
- camel_case_types
- avoid_void_async
- cancel_subscriptions
- constant_identifier_names
- control_flow_in_finally
- directives_ordering
- empty_catches
- empty_constructor_bodies
- empty_statements
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- library_names
- library_prefixes
- list_remove_unrelated_type
- non_constant_identifier_names
- overridden_fields
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- omit_local_variable_types
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_equal_for_default_values
- prefer_asserts_in_initializer_lists
- prefer_const_constructors
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_fields
- prefer_generic_function_type_aliases
- prefer_is_not_empty
- prefer_final_locals
- prefer_relative_imports
- slash_for_doc_comments
- prefer_single_quotes
- sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
- type_init_formals
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_new
- unrelated_type_equality_checks
- valid_regexps
- type_annotate_public_apis
- unawaited_futures
- unnecessary_lambdas
- unnecessary_parenthesis
- unnecessary_statements
- use_if_null_to_convert_nulls_to_bools
- use_raw_strings
- use_string_buffers
- use_super_parameters
2 changes: 0 additions & 2 deletions lib/async_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

library webdriver.core;

import 'dart:async' show Future;
import 'dart:collection' show UnmodifiableMapView;

Expand Down
8 changes: 2 additions & 6 deletions lib/async_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

library webdriver.html;

import 'dart:async' show Future;

import 'async_core.dart' as core
Expand Down Expand Up @@ -53,8 +51,7 @@ Future<core.WebDriver> createDriver(
/// last path component will be dropped.
Future<core.WebDriver> fromExistingSession(String sessionId,
{Uri? uri, WebDriverSpec spec = WebDriverSpec.Auto}) =>
core.fromExistingSession(
(prefix) => AsyncXhrRequestClient(prefix), sessionId,
core.fromExistingSession(AsyncXhrRequestClient.new, sessionId,
uri: uri, spec: spec);

/// Creates an async WebDriver from existing session with a sync function using
Expand All @@ -70,6 +67,5 @@ Future<core.WebDriver> fromExistingSession(String sessionId,
/// last path component will be dropped.
core.WebDriver fromExistingSessionSync(String sessionId, WebDriverSpec spec,
{Uri? uri, Map<String, dynamic>? capabilities}) =>
core.fromExistingSessionSync(
(prefix) => AsyncXhrRequestClient(prefix), sessionId, spec,
core.fromExistingSessionSync(AsyncXhrRequestClient.new, sessionId, spec,
uri: uri, capabilities: capabilities);
8 changes: 2 additions & 6 deletions lib/async_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

library webdriver.io;

import 'dart:async' show Future;

import 'async_core.dart' as core
Expand Down Expand Up @@ -55,8 +53,7 @@ Future<core.WebDriver> createDriver(
/// last path component will be dropped.
Future<core.WebDriver> fromExistingSession(String sessionId,
{Uri? uri, core.WebDriverSpec spec = core.WebDriverSpec.Auto}) =>
core.fromExistingSession(
(prefix) => AsyncIoRequestClient(prefix), sessionId,
core.fromExistingSession(AsyncIoRequestClient.new, sessionId,
uri: uri, spec: spec);

/// Creates an async WebDriver from existing session with a sync function using
Expand All @@ -73,6 +70,5 @@ Future<core.WebDriver> fromExistingSession(String sessionId,
core.WebDriver fromExistingSessionSync(
String sessionId, core.WebDriverSpec spec,
{Uri? uri, Map<String, dynamic>? capabilities}) =>
core.fromExistingSessionSync(
(prefix) => AsyncIoRequestClient(prefix), sessionId, spec,
core.fromExistingSessionSync(AsyncIoRequestClient.new, sessionId, spec,
uri: uri, capabilities: capabilities);
3 changes: 2 additions & 1 deletion lib/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

library webdriver.core;
@Deprecated("Use 'package:webdriver/async_core.dart' instead.")
library core;

/// Consider this file as deprecated. This exists as an alias to async_core.dart
/// for backward compatibility.
Expand Down
5 changes: 3 additions & 2 deletions lib/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

library webdriver.io;
@Deprecated("Use 'package:webdriver/async_io.dart' instead.")
library io;

/// Consider this file as deprecated. This exists as an alias to async_io.dart
/// for backward compatibility.
export 'package:webdriver/async_io.dart';
export 'async_io.dart';
2 changes: 1 addition & 1 deletion lib/src/async/alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ class Alert {
int get hashCode => _client.hashCode;

@override
bool operator ==(other) =>
bool operator ==(Object other) =>
other is Alert && _handler == other._handler && _client == other._client;
}
2 changes: 1 addition & 1 deletion lib/src/async/cookies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Cookies {
int get hashCode => _client.hashCode;

@override
bool operator ==(other) =>
bool operator ==(Object other) =>
other is Cookies &&
_handler == other._handler &&
_client == other._client;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/async/keyboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Keyboard {
int get hashCode => _client.hashCode;

@override
bool operator ==(other) =>
bool operator ==(Object other) =>
other is Keyboard &&
_handler == other._handler &&
_client == other._client;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/async/logs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ class Logs {
int get hashCode => _client.hashCode;

@override
bool operator ==(other) =>
bool operator ==(Object other) =>
other is Logs && _handler == other._handler && _client == other._client;
}
2 changes: 1 addition & 1 deletion lib/src/async/mouse.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ class Mouse {
int get hashCode => _client.hashCode;

@override
bool operator ==(other) =>
bool operator ==(Object other) =>
other is Mouse && _handler == other._handler && _client == other._client;
}
2 changes: 1 addition & 1 deletion lib/src/async/stepper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ class Stepper {
const Stepper();

/// returns true if command should be executed, false if should not be executed.
Future<bool> step(String method, String command, params) =>
Future<bool> step(String method, String command, Object? params) =>
Future.value(true);
}
5 changes: 3 additions & 2 deletions lib/src/async/target_locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TargetLocator {
/// not provided: selects the first frame on the page or the main document.
///
/// Throws [NoSuchFrameException] if the specified frame can't be found.
Future<void> frame([/* int | WebElement | String */ frame]) async {
Future<void> frame([Object? /* int | WebElement | String */ frame]) async {
if (frame is int?) {
await _client.send(_handler.frame.buildSwitchByIdRequest(frame),
_handler.frame.parseSwitchByIdResponse);
Expand Down Expand Up @@ -75,5 +75,6 @@ class TargetLocator {
int get hashCode => _driver.hashCode;

@override
bool operator ==(other) => other is TargetLocator && other._driver == _driver;
bool operator ==(Object other) =>
other is TargetLocator && other._driver == _driver;
}
2 changes: 1 addition & 1 deletion lib/src/async/timeouts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Timeouts {
int get hashCode => _client.hashCode;

@override
bool operator ==(other) =>
bool operator ==(Object other) =>
other is Timeouts &&
_handler == other._handler &&
_client == other._client;
Expand Down
10 changes: 5 additions & 5 deletions lib/src/async/web_driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class WebDriver implements SearchContext {
_handler.core.parseCurrentUrlResponse);

/// Navigates to the specified url
Future<void> get(/* Uri | String */ url) => _client.send(
Future<void> get(Object /* Uri | String */ url) => _client.send(
_handler.navigation.buildNavigateToRequest(
(url is Uri) ? url.toString() : url as String,
),
Expand Down Expand Up @@ -200,13 +200,13 @@ class WebDriver implements SearchContext {

/// Take a screenshot of the current page as PNG as list of uint8.
Future<List<int>> captureScreenshotAsList() async {
var base64Encoded = captureScreenshotAsBase64();
final base64Encoded = captureScreenshotAsBase64();
return base64.decode(await base64Encoded);
}

/// Take a screenshot of the specified element as PNG as list of uint8.
Future<List<int>> captureElementScreenshotAsList(WebElement element) async {
var base64Encoded = captureElementScreenshotAsBase64(element);
final base64Encoded = captureElementScreenshotAsBase64(element);
return base64.decode(await base64Encoded);
}

Expand Down Expand Up @@ -263,7 +263,7 @@ class WebDriver implements SearchContext {
),
);

Future<dynamic> postRequest(String command, [params]) => _client.send(
Future<dynamic> postRequest(String command, [Object? params]) => _client.send(
_handler.buildGeneralRequest(HttpMethod.httpPost, command, params),
(response) => _handler.parseGeneralResponse(
response,
Expand All @@ -290,7 +290,7 @@ class WebDriver implements SearchContext {
WebElement getElement(
String elementId, [
SearchContext? context,
locator,
Object? locator,
int? index,
]) =>
WebElement(this, _client, _handler, elementId, context, locator, index);
Expand Down
Loading