Skip to content

Improve WebDriver error message #81107

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 7 commits into from
Jun 10, 2021

Conversation

jushutch
Copy link
Contributor

@jushutch jushutch commented Apr 24, 2021

The current WebDriver error message is too vague, since it's a generic message with no specific guidance for each browser. Adding a link to the documentation on WebDrivers to help troubleshooting. This same pattern exists elsewhere in the code and works well in directing people to the right information for resolving the error.

An example of the new message including the link:

Make sure you have the correct WebDriver Server running at 4444. 
Make sure the WebDriver Server matches option --browser-name. 
For more information see: https://flutter.dev/docs/testing/integration-tests#running-in-a-browser 
SocketException: OS Error: The remote computer refused the network connection.
, errno = 1225, address = localhost, port = 61383

This PR fixes issue #78472.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Apr 24, 2021
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@google-cla google-cla bot added the cla: yes label Apr 24, 2021
@jonahwilliams
Copy link
Contributor

It seems reasonable that this could be test exempt but I would ask in the discord according to the instructions above.

@jonahwilliams
Copy link
Contributor

@Hixie did this get marked as test exempt or not?

@Hixie
Copy link
Contributor

Hixie commented Apr 29, 2021

It did not (test-exempt PRs have a comment somewhere that starts with test-exempt: ). I would recommend having a test, in part because hopefully a test would catch the error in the PR. :-)

The current WebDriver message is incomplete. Add link to
the documentation on WebDrivers for different browsers
to help troubleshooting.
Add a simple test to verify that the WebDriver error
message includes a link to the documentation.
@jushutch jushutch force-pushed the 78472-webdriver-error-message branch from bd9ef65 to a480ed9 Compare April 30, 2021 03:10
@jushutch
Copy link
Contributor Author

I just added a simple test to check that the error message contains the link that was added. However I must be missing the error in the PR that was mentioned; @Hixie would you mind elaborating to save some time? Is there more that I should be explicitly testing for in this change? Thanks for the help!

@@ -111,6 +111,8 @@ class WebDriverService extends DriverService {
'Unable to start WebDriver Session for Flutter for Web testing. \n'
'Make sure you have the correct WebDriver Server running at $driverPort. \n'
'Make sure the WebDriver Server matches option --browser-name. \n'
'For more information see: '
'https://flutter.dev/docs/testing/integration-tests#running-in-a-browser \n'
Copy link
Contributor

Choose a reason for hiding this comment

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

the trailing space before the newline here is what i was referring to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, thanks for pointing it out. I assumed this was the correct style based on the existing message, but let me know if you prefer otherwise and I can remove the trailing spaces for the entire message.

Copy link
Contributor

Choose a reason for hiding this comment

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

Friendly ping @Hixie

Copy link
Contributor

Choose a reason for hiding this comment

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

The existing text also needs fixing, I hadn't noticed that.

There shouldn't be a trailing space before a newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed all of the trailing spaces before new lines in this message 👍

jushutch added 2 commits May 1, 2021 17:27
The previous implementation was vulnerable to false
positives when a ToolExit exception isn't thrown. Change
to fail when no ToolExit is thrown.
Specify types to meet style rules.
Copy link
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 if lg to @Hixie

<String, String>{},
PackageConfig(<Package>[Package('test', Uri.base)]),
browserName: 'chrome',
), throwsToolExit(message: RegExp(' $link ')));
Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably make this test more strict. It's not just that there's a link that matters, it's also that the text is correct around the link, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I made the test more strict by including the preamble 👍

jushutch added 2 commits May 22, 2021 13:19
Remove trailing spaces before newlines to follow style
guide.
Test that the link in the error message includes an appropriate
preamble and follows style rules.
@jonahwilliams
Copy link
Contributor

This branch unfortunately has merge conflicts that need to be handled before we could land it.

@jonahwilliams
Copy link
Contributor

I don't know why this got stuck so I'm merging it

@jonahwilliams jonahwilliams merged commit db528a2 into flutter:master Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

3 participants