Skip to content

Commit 7153df9

Browse files
authored
cleanup (#260)
1 parent 336dd3d commit 7153df9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+379
-424
lines changed

.github/workflows/ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
fail-fast: false
4141
matrix:
4242
os: [ubuntu-latest]
43-
sdk: [dev]
43+
sdk: [2.18.0, dev]
4444
steps:
4545
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
4646
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
@@ -66,7 +66,7 @@ jobs:
6666
fail-fast: false
6767
matrix:
6868
os: [ubuntu-latest]
69-
sdk: [2.14.0, dev]
69+
sdk: [2.18.0, dev]
7070
steps:
7171
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
7272
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.0.2-dev
2+
3+
* Require Dart 2.18
4+
* "Officially" deprecate `core.dart` and `io.dart` libraries.
5+
16
## 3.0.1
27

38
* Return Future with non-nullable generic from `waitFor`. The generic `T` may

README.md

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![CI](https://github.com/google/webdriver.dart/actions/workflows/ci.yaml/badge.svg)](https://github.com/google/webdriver.dart/actions/workflows/ci.yaml)
22
[![pub package](https://img.shields.io/pub/v/webdriver.svg)](https://pub.dartlang.org/packages/webdriver)
3+
[![package publisher](https://img.shields.io/pub/publisher/webdriver.svg)](https://pub.dev/packages/webdriver/publisher)
34

45
Provides WebDriver bindings for Dart. These use the WebDriver JSON interface,
56
and as such, require the use of the WebDriver remote server.
@@ -12,8 +13,8 @@ import 'package:webdriver/io.dart';
1213
WebDriver driver = createDriver(...);
1314
```
1415

15-
This will use by default the asynchronous, JSON wire spec implementation.
16-
You now can also use a synchronous version of WebDriver:
16+
This will use by default the asynchronous, JSON wire spec implementation. You
17+
now can also use a synchronous version of WebDriver:
1718

1819
```dart
1920
import 'package:webdriver/sync_io.dart';
@@ -22,9 +23,9 @@ final driver = createDriver(...);
2223
```
2324

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

2930
```dart
3031
final w3cDriver = createDriver(spec: WebDriverSpec.W3c); // Use W3C spec.
@@ -35,11 +36,11 @@ final anyDriver = createDriver(spec: WebDriverSpec.Auto); // Infer spec.
3536
## Testing
3637

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

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

42-
1) Launch a WebDriver binar(ies).
43+
1. Launch a WebDriver binar(ies).
4344

4445
First, bring up chromedriver / geckodriver. Other conforming WebDriver
4546
binaries should work as well, but we test against these:
@@ -53,19 +54,19 @@ As a consequence, running tests is a bit more complicated than we'd like:
5354
geckodriver is used to test our W3C spec implementation.
5455

5556
Synchronous tests are labeled as Chrome/Firefox. All async tests run
56-
exclusively against Chrome (as async, like ChromeDriver supports only the
57-
old JSON wire spec).
57+
exclusively against Chrome (as async, like ChromeDriver supports only the old
58+
JSON wire spec).
5859

59-
2) Run a test. All files suffixed with '_test.dart' are tests.
60+
2. Run a test. All files suffixed with `_test.dart` are tests.
6061

6162
```
62-
pub run test/path/to/test.dart -r expanded -p vm
63+
dart test test/path/to/the_test.dart -r expanded -p vm
6364
```
6465

65-
Or to run *all* tests:
66+
Or to run _all_ tests:
6667

6768
```
68-
pub run test -r expanded -p vm
69+
dart test -r expanded -p vm
6970
```
7071

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

analysis_options.yaml

+30-33
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,44 @@
1+
# https://dart.dev/guides/language/analysis-options
12
include: package:lints/recommended.yaml
23

34
analyzer:
4-
strong-mode:
5-
implicit-casts: false
5+
language:
6+
strict-casts: true
67

78
linter:
89
rules:
9-
- avoid_empty_else
10-
- avoid_init_to_null
11-
- avoid_null_checks_in_equality_operators
10+
- always_declare_return_types
11+
- avoid_bool_literals_in_conditional_expressions
12+
- avoid_classes_with_only_static_members
13+
- avoid_private_typedef_functions
14+
- avoid_redundant_argument_values
15+
- avoid_returning_null_for_future
16+
- avoid_returning_this
1217
- avoid_unused_constructor_parameters
13-
- await_only_futures
14-
- camel_case_types
18+
- avoid_void_async
1519
- cancel_subscriptions
16-
- constant_identifier_names
17-
- control_flow_in_finally
1820
- directives_ordering
19-
- empty_catches
20-
- empty_constructor_bodies
21-
- empty_statements
22-
- hash_and_equals
23-
- implementation_imports
24-
- iterable_contains_unrelated_type
25-
- library_names
26-
- library_prefixes
27-
- list_remove_unrelated_type
28-
- non_constant_identifier_names
29-
- overridden_fields
21+
- literal_only_boolean_expressions
22+
- missing_whitespace_between_adjacent_strings
23+
- no_adjacent_strings_in_list
24+
- omit_local_variable_types
3025
- package_api_docs
31-
- package_names
32-
- package_prefixed_library_names
33-
- prefer_equal_for_default_values
26+
- prefer_asserts_in_initializer_lists
27+
- prefer_const_constructors
28+
- prefer_const_declarations
3429
- prefer_expression_function_bodies
35-
- prefer_final_fields
36-
- prefer_generic_function_type_aliases
37-
- prefer_is_not_empty
30+
- prefer_final_locals
3831
- prefer_relative_imports
39-
- slash_for_doc_comments
32+
- prefer_single_quotes
33+
- sort_pub_dependencies
4034
- test_types_in_equals
4135
- throw_in_finally
42-
- type_init_formals
43-
- unnecessary_brace_in_string_interps
44-
- unnecessary_const
45-
- unnecessary_new
46-
- unrelated_type_equality_checks
47-
- valid_regexps
36+
- type_annotate_public_apis
37+
- unawaited_futures
38+
- unnecessary_lambdas
39+
- unnecessary_parenthesis
40+
- unnecessary_statements
41+
- use_if_null_to_convert_nulls_to_bools
42+
- use_raw_strings
43+
- use_string_buffers
44+
- use_super_parameters

lib/async_core.dart

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
library webdriver.core;
16-
1715
import 'dart:async' show Future;
1816
import 'dart:collection' show UnmodifiableMapView;
1917

lib/async_html.dart

+2-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
library webdriver.html;
16-
1715
import 'dart:async' show Future;
1816

1917
import 'async_core.dart' as core
@@ -53,8 +51,7 @@ Future<core.WebDriver> createDriver(
5351
/// last path component will be dropped.
5452
Future<core.WebDriver> fromExistingSession(String sessionId,
5553
{Uri? uri, WebDriverSpec spec = WebDriverSpec.Auto}) =>
56-
core.fromExistingSession(
57-
(prefix) => AsyncXhrRequestClient(prefix), sessionId,
54+
core.fromExistingSession(AsyncXhrRequestClient.new, sessionId,
5855
uri: uri, spec: spec);
5956

6057
/// Creates an async WebDriver from existing session with a sync function using
@@ -70,6 +67,5 @@ Future<core.WebDriver> fromExistingSession(String sessionId,
7067
/// last path component will be dropped.
7168
core.WebDriver fromExistingSessionSync(String sessionId, WebDriverSpec spec,
7269
{Uri? uri, Map<String, dynamic>? capabilities}) =>
73-
core.fromExistingSessionSync(
74-
(prefix) => AsyncXhrRequestClient(prefix), sessionId, spec,
70+
core.fromExistingSessionSync(AsyncXhrRequestClient.new, sessionId, spec,
7571
uri: uri, capabilities: capabilities);

lib/async_io.dart

+2-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
library webdriver.io;
16-
1715
import 'dart:async' show Future;
1816

1917
import 'async_core.dart' as core
@@ -55,8 +53,7 @@ Future<core.WebDriver> createDriver(
5553
/// last path component will be dropped.
5654
Future<core.WebDriver> fromExistingSession(String sessionId,
5755
{Uri? uri, core.WebDriverSpec spec = core.WebDriverSpec.Auto}) =>
58-
core.fromExistingSession(
59-
(prefix) => AsyncIoRequestClient(prefix), sessionId,
56+
core.fromExistingSession(AsyncIoRequestClient.new, sessionId,
6057
uri: uri, spec: spec);
6158

6259
/// Creates an async WebDriver from existing session with a sync function using
@@ -73,6 +70,5 @@ Future<core.WebDriver> fromExistingSession(String sessionId,
7370
core.WebDriver fromExistingSessionSync(
7471
String sessionId, core.WebDriverSpec spec,
7572
{Uri? uri, Map<String, dynamic>? capabilities}) =>
76-
core.fromExistingSessionSync(
77-
(prefix) => AsyncIoRequestClient(prefix), sessionId, spec,
73+
core.fromExistingSessionSync(AsyncIoRequestClient.new, sessionId, spec,
7874
uri: uri, capabilities: capabilities);

lib/core.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
library webdriver.core;
15+
@Deprecated("Use 'package:webdriver/async_core.dart' instead.")
16+
library core;
1617

1718
/// Consider this file as deprecated. This exists as an alias to async_core.dart
1819
/// for backward compatibility.

lib/io.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
library webdriver.io;
15+
@Deprecated("Use 'package:webdriver/async_io.dart' instead.")
16+
library io;
1617

1718
/// Consider this file as deprecated. This exists as an alias to async_io.dart
1819
/// for backward compatibility.
19-
export 'package:webdriver/async_io.dart';
20+
export 'async_io.dart';

lib/src/async/alert.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ class Alert {
5757
int get hashCode => _client.hashCode;
5858

5959
@override
60-
bool operator ==(other) =>
60+
bool operator ==(Object other) =>
6161
other is Alert && _handler == other._handler && _client == other._client;
6262
}

lib/src/async/cookies.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Cookies {
6161
int get hashCode => _client.hashCode;
6262

6363
@override
64-
bool operator ==(other) =>
64+
bool operator ==(Object other) =>
6565
other is Cookies &&
6666
_handler == other._handler &&
6767
_client == other._client;

lib/src/async/keyboard.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Keyboard {
9797
int get hashCode => _client.hashCode;
9898

9999
@override
100-
bool operator ==(other) =>
100+
bool operator ==(Object other) =>
101101
other is Keyboard &&
102102
_handler == other._handler &&
103103
_client == other._client;

lib/src/async/logs.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ class Logs {
4545
int get hashCode => _client.hashCode;
4646

4747
@override
48-
bool operator ==(other) =>
48+
bool operator ==(Object other) =>
4949
other is Logs && _handler == other._handler && _client == other._client;
5050
}

lib/src/async/mouse.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,6 @@ class Mouse {
127127
int get hashCode => _client.hashCode;
128128

129129
@override
130-
bool operator ==(other) =>
130+
bool operator ==(Object other) =>
131131
other is Mouse && _handler == other._handler && _client == other._client;
132132
}

lib/src/async/stepper.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ class Stepper {
2020
const Stepper();
2121

2222
/// returns true if command should be executed, false if should not be executed.
23-
Future<bool> step(String method, String command, params) =>
23+
Future<bool> step(String method, String command, Object? params) =>
2424
Future.value(true);
2525
}

lib/src/async/target_locator.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TargetLocator {
3535
/// not provided: selects the first frame on the page or the main document.
3636
///
3737
/// Throws [NoSuchFrameException] if the specified frame can't be found.
38-
Future<void> frame([/* int | WebElement | String */ frame]) async {
38+
Future<void> frame([Object? /* int | WebElement | String */ frame]) async {
3939
if (frame is int?) {
4040
await _client.send(_handler.frame.buildSwitchByIdRequest(frame),
4141
_handler.frame.parseSwitchByIdResponse);
@@ -75,5 +75,6 @@ class TargetLocator {
7575
int get hashCode => _driver.hashCode;
7676

7777
@override
78-
bool operator ==(other) => other is TargetLocator && other._driver == _driver;
78+
bool operator ==(Object other) =>
79+
other is TargetLocator && other._driver == _driver;
7980
}

lib/src/async/timeouts.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Timeouts {
4545
int get hashCode => _client.hashCode;
4646

4747
@override
48-
bool operator ==(other) =>
48+
bool operator ==(Object other) =>
4949
other is Timeouts &&
5050
_handler == other._handler &&
5151
_client == other._client;

lib/src/async/web_driver.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class WebDriver implements SearchContext {
7474
_handler.core.parseCurrentUrlResponse);
7575

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

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

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

@@ -263,7 +263,7 @@ class WebDriver implements SearchContext {
263263
),
264264
);
265265

266-
Future<dynamic> postRequest(String command, [params]) => _client.send(
266+
Future<dynamic> postRequest(String command, [Object? params]) => _client.send(
267267
_handler.buildGeneralRequest(HttpMethod.httpPost, command, params),
268268
(response) => _handler.parseGeneralResponse(
269269
response,
@@ -290,7 +290,7 @@ class WebDriver implements SearchContext {
290290
WebElement getElement(
291291
String elementId, [
292292
SearchContext? context,
293-
locator,
293+
Object? locator,
294294
int? index,
295295
]) =>
296296
WebElement(this, _client, _handler, elementId, context, locator, index);

0 commit comments

Comments
 (0)