Skip to content

Flutter drive --browser-dimension not working #136109

Closed

Description

@hoantruong

Is there an existing issue for this?

Steps to reproduce

I am trying to run flutter web test on Chrome, with the following command:

flutter drive \
  --driver=test_driver/integration_test.dart \
  --target=integration_test/main_test.dart > C:\Automation_test\Report_log\log.txt \
  --browser-dimension="1920,1080" \
  -d chrome

Expected results

The browser is resized to 1920 x 1080 when start.

Actual results

The browser is NOT resized to 1920 x 1080 when start.

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Activity

  1. darshankawar commented on Oct 9, 2023

    @darshankawar
    Member

    Thanks for the report. I verified using a sample app and running using latest versions and observed that passing browser dimension is not taking effect. I tried passing different dimensions, but the browser window size is same:

    1. 1920 x 1080:
    Screenshot 2023-10-09 at 1 42 17 PM
    1. 400 x 800:
    Screenshot 2023-10-09 at 1 43 44 PM
    1. Without passing --browser-dimension argument:
    Screenshot 2023-10-09 at 1 45 14 PM
  2. added
    platform-webWeb applications specifically
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    toolAffects the "flutter" command-line tool. See also t: labels.
    t: flutter driver"flutter driver", flutter_drive, or a driver test
    team-webOwned by Web platform team
    and removed
    in triagePresently being triaged by the triage team
    on Oct 9, 2023
  3. added
    P2Important issues not at the top of the work list
    triaged-webTriaged by Web platform team
    on Oct 12, 2023
  4. hoantruong commented on Oct 25, 2023

    @hoantruong
    Author

    Could you please help to fix this issue soon @darshankawar?

    Thanks very much!

  5. amrgetment commented on Dec 5, 2024

    @amrgetment

    Yes, I can confirm it still exists on the latest Flutter release 3.24.5
    is there any workaround

  6. amrgetment commented on Dec 5, 2024

    @amrgetment

    @kevmoo Sorry to mention you, but could you look into this issue, it is breaking the visual UI testing(golden testing) for Flutter web

  7. munrocket commented on Dec 19, 2024

    @munrocket
    Contributor

    We need to add mobile emulation in dart.

    Here same bug with selenium and fix for it.

    const { Builder } = require('selenium-webdriver');
    const chrome = require('selenium-webdriver/chrome');
    const fs = require('fs');
    
    const options = new chrome.Options();
    options.addArguments('--no-sandbox');
    
    // FIX BUG ==>
    options.setMobileEmulation({
        deviceMetrics: {
            width: 393,
            height: 852,
            pixelRatio: 3.0 // iPhone 15 size
        },
        userAgent: 'Mozilla/5.0 (Linux; Android 11; Pixel 6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.91 Mobile Safari/537.36'
    });
    
    const driver = new Builder()
        .forBrowser('chrome')
        .usingServer('http://localhost:4444')
        .setChromeOptions(options)
        .build();
    
    (async function resize() {
        try {
            await driver.manage().window().setRect({ width: 393, height: 852 });
            if (!fs.existsSync('screenshots')) {
                fs.mkdirSync('screenshots');
            }
            const screenshot = await driver.takeScreenshot();
            fs.writeFileSync('screenshots/screenshot.png', screenshot, 'base64');
        } finally {
            await driver.quit();
        }
    })();
  8. munrocket commented on Dec 22, 2024

    @munrocket
    Contributor

    @amrgetment I am created pull request. You can apply patch to stable Flutter with git apply patch.diff, don't forget to clean ~/.pub-cache before use, if it is not clean setup.

  9. added a commit that references this issue on May 26, 2025
    a9e9ff9
  10. added a commit that references this issue on May 26, 2025
    3568a2e
  11. added
    r: fixedIssue is closed as already fixed in a newer version
    on May 27, 2025
  12. github-actions commented on Jun 10, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Jun 10, 2025
  14. ksokolovskyi commented on Jul 14, 2025

    @ksokolovskyi
    Contributor

    Hi @darshankawar, not long ago this issue was closed as fixed by #160678. While investigating another driver issue on master channel, I noticed that passing --browser-dimensions doesn't resize the browser window.

    I am using flutter-dev to run Flutter Tools from source.

    With --browser-dimension='200x300@1'

    flutter-dev drive \
       --driver=test_driver/integration_test.dart \
       --target=integration_test/app_test.dart \
       -d chrome --browser-dimension='200x300@1'
    
    Image

    Without --browser-dimension

    flutter-dev drive \
       --driver=test_driver/integration_test.dart \
       --target=integration_test/app_test.dart \
       -d chrome
    
    Image

    ⠀

    Could you please try to reproduce the issue again on master channel? Thanks in advance!

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 listfound in release: 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: flutter driver"flutter driver", flutter_drive, or a driver testteam-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