Unverified Commit db528a24 authored by Justin Hutchins's avatar Justin Hutchins Committed by GitHub

Improve WebDriver error message (#81107)

* Add link to documentation in error message

The current WebDriver message is incomplete. Add link to
the documentation on WebDrivers for different browsers
to help troubleshooting.
parent 10840352
...@@ -109,9 +109,11 @@ class WebDriverService extends DriverService { ...@@ -109,9 +109,11 @@ class WebDriverService extends DriverService {
); );
} on Exception catch (ex) { } on Exception catch (ex) {
throwToolExit( throwToolExit(
'Unable to start WebDriver Session for Flutter for Web testing. \n' '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 you have the correct WebDriver Server running at $driverPort.\n'
'Make sure the WebDriver Server matches option --browser-name. \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'
'$ex' '$ex'
); );
} }
......
...@@ -16,6 +16,7 @@ import 'package:flutter_tools/src/build_info.dart'; ...@@ -16,6 +16,7 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/drive/drive_service.dart'; import 'package:flutter_tools/src/drive/drive_service.dart';
import 'package:flutter_tools/src/drive/web_driver_service.dart';
import 'package:flutter_tools/src/resident_runner.dart'; import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/version.dart'; import 'package:flutter_tools/src/version.dart';
import 'package:flutter_tools/src/vmservice.dart'; import 'package:flutter_tools/src/vmservice.dart';
...@@ -454,6 +455,25 @@ void main() { ...@@ -454,6 +455,25 @@ void main() {
); );
await driverService.stop(); await driverService.stop();
}); });
testWithoutContext('WebDriver error message includes link to documentation', () async {
const String link = 'https://flutter.dev/docs/testing/integration-tests#running-in-a-browser';
final DriverService driverService = WebDriverService(
dartSdkPath: 'dart',
processUtils: ProcessUtils(
processManager: FakeProcessManager.empty(),
logger: BufferLogger.test(),
),
);
expect(() => driverService.startTest(
'foo.test',
<String>[],
<String, String>{},
PackageConfig(<Package>[Package('test', Uri.base)]),
browserName: 'chrome',
), throwsToolExit(message: RegExp('\nFor more information see: $link\n')));
});
} }
FlutterDriverService setUpDriverService({ FlutterDriverService setUpDriverService({
...@@ -517,6 +537,8 @@ class FakeDevice extends Fake implements Device { ...@@ -517,6 +537,8 @@ class FakeDevice extends Fake implements Device {
bool didUninstallApp = false; bool didUninstallApp = false;
bool didDispose = false; bool didDispose = false;
bool failOnce = false; bool failOnce = false;
@override
final PlatformType platformType = PlatformType.web;
@override @override
String get name => 'test'; String get name => 'test';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment