Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(browser): playwright provider doesn't allow resizing the browser viewport #5984

Merged
merged 12 commits into from
Jul 1, 2024

Conversation

userquin
Copy link
Member

@userquin userquin commented Jun 27, 2024

Description

Playwright using custom viewport implementation, once the browser is opened PW will prevent resizing the Vitest UI.

We need to configure viewport: null when creating the context, for context check: microsoft/playwright#20721

Playwright prevents resizing the viewport
imagen

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@userquin userquin changed the title fix(browser): playwright provider doesn't resize the browser viewport fix(browser): playwright provider doesn't allow resizing the browser viewport Jun 27, 2024
@userquin
Copy link
Member Author

@sheremet-va we can also open it maximized via args if you want to add it here: https://discord.com/channels/807756831384403968/1255831070339891281/1255867837793439857

launchOptions: { args: ["--start-maximized"] }

@userquin userquin requested a review from sheremet-va June 27, 2024 13:07
@userquin userquin changed the title fix(browser): playwright provider doesn't allow resizing the browser viewport feat(browser): playwright provider doesn't allow resizing the browser viewport Jun 27, 2024
@userquin
Copy link
Member Author

NOTE: since we're opening the browser before running the tests...

imagen

@kwojcik
Copy link

kwojcik commented Jun 27, 2024

Is this the same problem as what causes my failure screenshots to get cutoff? This screenshot is taken with viewport: { width: 800, height: 1500 }

Screenshot

screenshot

@sheremet-va
Copy link
Member

we can also open it maximized via args if you want to add it here

Maybe we should open it in max if --browser.ui is true, and pass down the same viewport from the config otherwise

@userquin
Copy link
Member Author

userquin commented Jun 28, 2024

we can also open it maximized via args if you want to add it here

Maybe we should open it in max if --browser.ui is true, and pass down the same viewport from the config otherwise

Added launchViewport to resolved browser options: Vitest UI maximized when ui enabled with PW and WDIO providers.

For WDIO I haven't found a way to maximize the window on remote call, using browser.maximizeWindow, once the browser is opened, the window is maximized.

For PW, adding --start-maximized arg to launch (when missing --start-maximized and --start-fullscreen from args) just works: Vitest UI maximized when the browser is opened => https://peter.sh/experiments/chromium-command-line-switches/

@sheremet-va
Copy link
Member

Let’s not add any new options. Args can already be overriden by providerOptions

@userquin userquin requested a review from sheremet-va June 28, 2024 13:50
@userquin
Copy link
Member Author

userquin commented Jun 28, 2024

We can use browser capabilities, but will differ between browsers (note from @christian-bromann ):

capabilities: {
  browserName: 'chrome',
  'goog:chromeOptions': {
    args: ['--start-maximized', '--start-fullscreen']
  }
}

EDIT: WDIO should simplify this, it is a pain

test/browser/test/viewport.test.ts Outdated Show resolved Hide resolved
packages/browser/src/node/providers/webdriver.ts Outdated Show resolved Hide resolved
@userquin userquin requested a review from sheremet-va June 30, 2024 13:26
@userquin
Copy link
Member Author

userquin commented Jul 1, 2024

With latest change, the viewport.test.ts will not pass when running it with Vitest UI using Firefox or Safari (with both providers).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants