question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] BrowserContext.maximizeWindow()

See original GitHub issue

Selenium feature: https://www.selenium.dev/selenium/docs/api/py/webdriver_remote/selenium.webdriver.remote.webdriver.html#selenium.webdriver.remote.webdriver.WebDriver.maximize_window

Requested via Slack.

Scenario: Automate a website and then let the user complete something. Its great if the max possible width/height could be determined so the user has “maximum available viewport”.

But not sure how or if its easy implementable since we in CR e.g. emulate the viewport independent from the window size.

For Chromium it works already like that:

// @ts-check
const playwright = require('playwright');

(async () => {
    const browser = await playwright.chromium.launch({
      args: ["--start-maximized"],
      headless: false,
    });
    const context = await browser.newContext({
      viewport: null
    });
    const page = await context.newPage();
    await page.goto('http://whatsmyuseragent.org/');
    await browser.close();
})();

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:75
  • Comments:38 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
azad-derakhshani-GScommented, Apr 6, 2022

@azad-derakhshani-GS This looks backwards to me: maximize would make pages behave differently, while fixed viewport guarantees consistent behavior. What do I miss?

A well-designed page behaves consistently across different viewports, so this is nothing for the testautomation framework to worry about. Trust me, in several years of TA experience, maximizing the browser window never caused any such issues, not even once. It’s also closer to the way a real user would behave. But Playwright artificially shrinks the viewport so the pages aren’t even displayed in full, which (despite it scrolling into elements) leads to page elements not being fully displayed while PW interacts with them.

Also to elaborate a bit further on the second point from my previous post: Not having a flexible (= maximized) resolution means I have to define a specific screen resolution (even null does mean 1280x720). But a static resolution could be incompatible with other people’s screens. Sizing the browser window flexibly via maximize eliminates that problem.

4reactions
starosta357commented, Nov 25, 2021

Solution for Java: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebdriverIO Tutorial: Browser Commands for ... - LambdaTest
newWindow command is used when you want to open a new url on a new browser window. Other parameters included are windoname and...
Read more >
WebdriverIO Tutorial: Browser Commands for Selenium Testing
maximizeWindow command helps the browser to maximize the browser window for automated browser testing. Syntax: browser.maximizeWindow(). Example ...
Read more >
26 - Maximize/Full Screen Browser in Playwright | ViewPortSize
In this video, I have explained how to maximize the browser window.Maximize/Full Screen Browser in Playwright | ViewPortSize | Playwright ...
Read more >
chrome/test/chromedriver/test/run_py_tests.py - chromium/src
ChromeDriverLogTest tests an internal ChromeDriver feature, not needed ... Browser context management is not supported by Android ... MaximizeWindow().
Read more >
Storybook Integration | Developer Guide - Nightwatch.js
In addition, Nightwatch provides a test() function which has access to its own APIs ... Runs in the browser context FilledForm.play = async...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found