Skip to content

Use flutter_tools to start WebDriver browser.#49228

Merged
fluttergithubbot merged 12 commits intoflutter:masterfrom
angjieli:drive
Jan 22, 2020
Merged

Use flutter_tools to start WebDriver browser.#49228
fluttergithubbot merged 12 commits intoflutter:masterfrom
angjieli:drive

Conversation

@angjieli
Copy link
Copy Markdown
Contributor

@angjieli angjieli commented Jan 21, 2020

Description

Previously, when running Flutter web driver test, test code is responsible for starting driver browser which is anti-flutter patter (it DOES follows webdriver test pattern). This PR is going to put driver initialization logic into flutter_tools to be consistent.

Tests

I added the following tests:

Added test cased to 'packages/flutter_tools/test/general.shard/web/devices_test.dart' to verify ChromeDevice and WebServerDevice would return true for isWebDevice.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.
    • I wrote a design doc: https://flutter.dev/go/template Replace this with a link to your design doc's short link
    • I got input from the developer relations team, specifically from: Replace with the names of who gave advice
    • I wrote a migration guide: Replace with a link to your migration guide

@fluttergithubbot fluttergithubbot added a: tests "flutter test", flutter_test, or one of our tests d: examples Sample code and demos framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. customer: gallery Relating to flutter/gallery repository. Please transfer non-framework issues there. tool Affects the "flutter" command-line tool. See also t: labels. labels Jan 21, 2020
@angjieli angjieli requested a review from chingjun January 21, 2020 18:00
bool get supportsFastStart => false;

/// Whether the device is a web-platform device.
bool get isWebDevice => false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding isWebDevice you could check whether the target platform is web_javascript

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

factory FlutterDriver.connectedTo({
FlutterWebConnection webConnection,
Browser browser,
bool supportTimelineAction,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a bit of a roundabout way to specify the web client. Could supportTimelineAction be inferred here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by wrapping it into FlutterWebConnection.


setUpAll(() async {
driver = await FlutterDriver.connect(browser: true);
driver = await FlutterDriver.connect();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could expose a "supportsTImeline" getter on the driver, then you could wrap the TimelineSummary in that and merge this back with the other test script

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with Jonah offline. Going to keep this as it is for now so that we can verify flutter driver works with non-chrome browsers (testing on non-chrome browsers will throw exceptions when calling timeline-related actions).

@angjieli angjieli requested review from jonahwilliams and removed request for chingjun January 21, 2020 21:17
Copy link
Copy Markdown
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fluttergithubbot fluttergithubbot merged commit f0a175f into flutter:master Jan 22, 2020
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: tests "flutter test", flutter_test, or one of our tests c: contributor-productivity Team-specific productivity, code health, technical debt. customer: gallery Relating to flutter/gallery repository. Please transfer non-framework issues there. d: examples Sample code and demos framework flutter/packages/flutter repository. See also f: labels. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants