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.
This commit is contained in:
Justin Hutchins 2021-06-10 11:52:42 -04:00 committed by GitHub
parent 10840352ce
commit db528a24a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 3 deletions

View File

@ -109,9 +109,11 @@ class WebDriverService extends DriverService {
);
} on Exception catch (ex) {
throwToolExit(
'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'
'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'
'$ex'
);
}

View File

@ -16,6 +16,7 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/device.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/version.dart';
import 'package:flutter_tools/src/vmservice.dart';
@ -454,6 +455,25 @@ void main() {
);
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({
@ -517,6 +537,8 @@ class FakeDevice extends Fake implements Device {
bool didUninstallApp = false;
bool didDispose = false;
bool failOnce = false;
@override
final PlatformType platformType = PlatformType.web;
@override
String get name => 'test';