Closed hdorgeval closed 4 years ago
The following snippet worked for me:
const browser = await playwright['firefox'].launch({
headless: false,
// either pass as a=b or 'a', 'b', no spaces inside
args: ['-height=666', '-width=888'],
});
// you want to opt-out from the default 800/600 viewport.
const context = await browser.newContext({ viewport: null });
const page = await context.newPage();
Note that the actual outer height is going to be higher than what you specify due to the toolbar. Please feel free to reopen if that did not address your issue.
@pavelfeldman : thank you very much for your fast answer 👍 It works for me also thanks to your snippet. Is there a similar snippet to be able to resize the webkit browser window?
Resizing via page.setViewport
(page.setViewportSize
in 0.11+) should change the size of both Firefox and WebKit in headful mode. It would not work for Chromium though - Chromium uses lower level emulation capabilities for resize, so you still need the args.
Do you mind sharing more about your use case?
Hi @pavelfeldman , As you may notice, I am currently developing a Fluent API around Playwright.
In this API, I want to ensure that the browser window size is as near as possible to the physical size of the emulated device. For example, if I want to run a test by emulating an iPhone, I do not want to have a 'big' browser window with a 'small' active size in it (the viewport).
When I open a browser in the real life, the viewport size seems to fit exactly the browser window size, so in headfull scenarios the viewport should always be set by default to null in Playwright.
So in my opinion, viewport size should always be correlated to the browser window size and vice versa: setting up the viewport size, regardless of the opened browser window size, is only a way to overcome some display hardware limitation on CI environment.
Context:
Code Snippet
Describe the bug
I expect that browser width and height to be the ones set in the options arg passed to the launch() method.
Works for chromium with the options set as