Flutter Web Driver Support (#45951)
* Support Flutter Driver test for Flutter Web application. * Support Flutter Driver test for Flutter Web application. * Fix documentation issues. * Support Flutter Driver test for Flutter Web application. * Fix documentation. * Remove unused file from dartdoc check. * Sync to date. * Revert change to dartdoc. * Address comments. * Apply suggestions from code review Co-Authored-By: Jonah Williams <jonahwilliams@google.com> * Update copyrights. * Update allowed list for browsers. * Verify command line arguments for Drive command is correctly parsed. * Make waitUntilFirstFrameRasterized throw unimplementedError for Flutter Web Driver. * Add comment for why sync WebDriver is used. * Update documentations. * Add more unit tests and update documentation. * Configure test.dart so that web_extension_test will be executed with --platform=chrome. * Revert unnecessary changes. * Add new file path for Windows to blacklist. * Reconstruct the structure of flutter_driver/test/src folder to remove filtering logic in dev/bots/test.dart/ * Fix path to web_extension_test.dart. * Add instructions for how to use WebFlutterDriver. * Update getLayerTree to use sendCommand instead of _sendCommand. * Update pubspec files.
This commit is contained in:
committed by
Jonah Williams
parent
f546aa7def
commit
1ef0eadb45
@@ -69,6 +69,34 @@ class DriveCommand extends RunCommandBase {
|
||||
..addFlag('build',
|
||||
defaultsTo: true,
|
||||
help: 'Build the app before running.',
|
||||
)
|
||||
..addOption('driver-port',
|
||||
defaultsTo: '4444',
|
||||
help: 'The port where Webdriver server is launched at. Defaults to 4444.',
|
||||
valueHelp: '4444'
|
||||
)
|
||||
..addFlag('headless',
|
||||
defaultsTo: true,
|
||||
help: 'Whether the driver browser is going to be launched in headless mode. Defaults to true.',
|
||||
)
|
||||
..addOption('browser-name',
|
||||
defaultsTo: 'chrome',
|
||||
help: 'Name of browser where tests will be executed. \n'
|
||||
'Following browsers are supported: \n'
|
||||
'Chrome, Firefox, Safari (macOS and iOS) and Edge. Defaults to Chrome.',
|
||||
allowed: <String>[
|
||||
'chrome',
|
||||
'edge',
|
||||
'firefox',
|
||||
'ios-safari',
|
||||
'safari',
|
||||
]
|
||||
)
|
||||
..addOption('browser-dimension',
|
||||
defaultsTo: '1600,1024',
|
||||
help: 'The dimension of browser when running Flutter Web test. \n'
|
||||
'This will affect screenshot and all offset-related actions. \n'
|
||||
'By default. it is set to 1600,1024 (1600 by 1024).',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -133,8 +161,16 @@ class DriveCommand extends RunCommandBase {
|
||||
|
||||
Cache.releaseLockEarly();
|
||||
|
||||
final Map<String, String> environment = <String, String>{
|
||||
'VM_SERVICE_URL': observatoryUri,
|
||||
'SELENIUM_PORT': argResults['driver-port'].toString(),
|
||||
'BROWSER_NAME': argResults['browser-name'].toString(),
|
||||
'BROWSER_DIMENSION': argResults['browser-dimension'].toString(),
|
||||
'HEADLESS': argResults['headless'].toString(),
|
||||
};
|
||||
|
||||
try {
|
||||
await testRunner(<String>[testFile], observatoryUri);
|
||||
await testRunner(<String>[testFile], environment);
|
||||
} catch (error, stackTrace) {
|
||||
if (error is ToolExit) {
|
||||
rethrow;
|
||||
@@ -291,13 +327,13 @@ Future<LaunchResult> _startApp(DriveCommand command) async {
|
||||
}
|
||||
|
||||
/// Runs driver tests.
|
||||
typedef TestRunner = Future<void> Function(List<String> testArgs, String observatoryUri);
|
||||
typedef TestRunner = Future<void> Function(List<String> testArgs, Map<String, String> environment);
|
||||
TestRunner testRunner = _runTests;
|
||||
void restoreTestRunner() {
|
||||
testRunner = _runTests;
|
||||
}
|
||||
|
||||
Future<void> _runTests(List<String> testArgs, String observatoryUri) async {
|
||||
Future<void> _runTests(List<String> testArgs, Map<String, String> environment) async {
|
||||
printTrace('Running driver tests.');
|
||||
|
||||
PackageMap.globalPackagesPath = fs.path.normalize(fs.path.absolute(PackageMap.globalPackagesPath));
|
||||
@@ -310,7 +346,7 @@ Future<void> _runTests(List<String> testArgs, String observatoryUri) async {
|
||||
'--packages=${PackageMap.globalPackagesPath}',
|
||||
'-rexpanded',
|
||||
],
|
||||
environment: <String, String>{'VM_SERVICE_URL': observatoryUri},
|
||||
environment: environment,
|
||||
);
|
||||
if (result != 0) {
|
||||
throwToolExit('Driver tests failed: $result', exitCode: result);
|
||||
|
||||
Reference in New Issue
Block a user