Repository navigation
Description
I'm trying flutter drive for flutter web integration_test on CI (without GUI). I noticed that the --headless is true by default, but got error when executing the flutter drive as the GUI Chrome is required. Then I did an investigation on the source code of the package flutter_tools, and found (please correct me if something misunderstood), the flutter drive does two things:
(1) launch chrome first (which check the option --web-run-headless to determine the mode for chrome)
(2) connect to the chromedriver for test
But seems the option --web-run-headless does not work as expected, I suspect the root cause is there:
flutter/packages/flutter_tools/lib/src/drive/web_driver_service.dart
Lines 70 to 91 in 895beb0
| _residentRunner = webRunnerFactory.createWebRunner( | |
| flutterDevice, | |
| target: mainPath, | |
| ipv6: ipv6, | |
| debuggingOptions: buildInfo.isRelease ? | |
| DebuggingOptions.disabled( | |
| buildInfo, | |
| port: debuggingOptions.port, | |
| ) | |
| : DebuggingOptions.enabled( | |
| buildInfo, | |
| port: debuggingOptions.port, | |
| disablePortPublication: debuggingOptions.disablePortPublication, | |
| ), | |
| stayResident: true, | |
| urlTunneller: null, | |
| flutterProject: FlutterProject.current(), | |
| fileSystem: globals.fs, | |
| usage: globals.flutterUsage, | |
| logger: _logger, | |
| systemClock: globals.systemClock, | |
| ); |
that is, the debuggingOptions here is built new, but not using the debuggingOptions from function start calling:
flutter/packages/flutter_tools/lib/src/drive/web_driver_service.dart
Lines 52 to 58 in 895beb0
| @override | |
| Future<void> start( | |
| BuildInfo buildInfo, | |
| Device device, | |
| DebuggingOptions debuggingOptions, | |
| bool ipv6, { | |
| File applicationBinary, |
so that, the debuggingOptions.webRunHeadless will be set to false always, whether if the --web-run-headless specified or not.
I tried add one line code as below, now --web-run-headless work as it implies.
_residentRunner = webRunnerFactory.createWebRunner(
flutterDevice,
target: mainPath,
ipv6: ipv6,
debuggingOptions: buildInfo.isRelease ?
DebuggingOptions.disabled(
buildInfo,
port: debuggingOptions.port,
webRunHeadless: debuggingOptions.webRunHeadless, // addded by zpsean
)
: DebuggingOptions.enabled(
buildInfo,
port: debuggingOptions.port,
disablePortPublication: debuggingOptions.disablePortPublication,
webRunHeadless: debuggingOptions.webRunHeadless, // addded by zpsean
),
stayResident: true,
urlTunneller: null,
flutterProject: FlutterProject.current(),
fileSystem: globals.fs,
usage: globals.flutterUsage,
logger: _logger,
systemClock: globals.systemClock,
);
So, please kindly confirm if something i missed or this is a real issue. (cosidering the usage --web-run-headless, --headless for flutter drive)
Activity
darshankawar commentedon Dec 13, 2021
@zpsean
Can you provide us the full command you are trying to run ?
If we are running flutter driver test locally on web and like to see it running visibly, we need to pass
--headlessflag to the command, for ex:flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart -d web-server --no-headlessCan you try the same and see if it still doesn't take the effect ?
zpsean commentedon Dec 13, 2021
Now, i'm trying on Mac with command below:
flutter drive --driver=test_driver/IT_driver_test.dart --target=integration_test/IT_test.dart -d chrome --web-run-headless --headless --releaseThe Chrome is invoked with GUI mode unexpected.
Instead, i'm trying to use dart command directly as below, with the flutter_tools code changed showing above (webRunHeadless: debuggingOptions.webRunHeadless, // addded by zpsean):
dart --disable-dart-dev --packages=/flutter/packages/flutter_tools/.packages /flutter/packages/flutter_tools/bin/flutter_tools.dart drive --driver=test_driver/IT_driver_test.dart --target=integration_test/IT_test.dart -d chrome --web-run-headless --headlessThis time, the test is run in headless mode. The i removed the option "--web-run-headless":
dart --disable-dart-dev --packages=/flutter/packages/flutter_tools/.packages /flutter/packages/flutter_tools/bin/flutter_tools.dart drive --driver=test_driver/IT_driver_test.dart --target=integration_test/IT_test.dart -d chrome --headlessThis time the GUI invoked again, which means the option "--web-run-headless” is false, and take priority than --headless.
In fact, I tried the combination of "--web-run-headless" and "--headless":
darshankawar commentedon Dec 14, 2021
Labeling it for further insights from the team.
/cc @jiahaog
Add a virtual display for the web render-matrix job's headed Chrome
Variable stroke width (0.6.0) (#10)