Skip to content

--web-run-headless does not take effect when using flutter drive for flutter web integration_test #95085

Open

Description

@zpsean

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:

_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:

@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

  1. darshankawar commented on Dec 13, 2021

    @darshankawar
    Member

    @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 --headless flag to the command, for ex: flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart -d web-server --no-headless
    Can you try the same and see if it still doesn't take the effect ?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Dec 13, 2021
  3. zpsean commented on Dec 13, 2021

    @zpsean
    Author

    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 --release

    The 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 --headless

    This 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 --headless

    This 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":

    flutter drive ... --release
    flutter drive ... --web-run-headless --release
    flutter drive ... --web-run-headless --no-headless --release
    flutter drive ... --no-headless --release
    
  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Dec 13, 2021
  5. darshankawar commented on Dec 14, 2021

    @darshankawar
    Member

    Labeling it for further insights from the team.

    /cc @jiahaog

  6. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: integration_testThe flutter/packages/integration_test plugin
    platform-webWeb applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    and removed
    in triagePresently being triaged by the triage team
    on Dec 14, 2021
  7. added
    P2Important issues not at the top of the work list
    on May 5, 2022
  8. removed their assignment
    on May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: integration_testThe flutter/packages/integration_test pluginframeworkflutter/packages/flutter repository. See also f: labels.platform-webWeb applications specificallyteam-webOwned by Web platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions