Playwright: [Feature] create context in fullscreen mode

Created on 24 Feb 2020  路  10Comments  路  Source: microsoft/playwright

How to launch browser.newContext() or browser.newPage() in fullscreen ? There is no way to pass full-screen via options while calling browser.newContext(options).

P3-collecting-feedback

Most helpful comment

Synced offline with @star-kashyap to understand this better. Due to DRM constraints, the tests are executed in headful mode. A small browser window impacts verifiability of execution, and looks suboptimal to an observer.

While it is possible to use something like --start-fullscreen or --window-size as args to launch a browser, it is not possible to enlarge the size of a new window launched with newContext. Combination of enlarged window size and viewport: null would fix this.

All 10 comments

I'm not sure what you mean. Currently the default is:

browser.newConext({
  viewport: {
    width: 800, // 1280 in commit 1ee6578
    height: 600, // 720 in commit 1ee6578
  }
})

If I understood correctly, you were expecting that viewport width and height will automatically be set to your current desktop/laptop's viewport?

Screenshot 2020-02-25 at 11 54 23 AM

I am talking about this new cognito window size, which I am launching by context.newPage(). Viewport is visible area which is visible on device, however browser window size is different. Opening new browser window in full screen size is my concern. How to launch it in full screen. Passing viewport do not help.

I know that the user can maximize the browser window and I know that the page can request full screen mode via the web api. But I'm not sure user can create a new full screen page.

Could you share more about your use case?

Sorry, my bad. My point is user maximize browser window. How can we get it done ? Before context.newPage(), I am getting context by browser.newContext(). Can we get new context in fullscreen mode ?

My point is user maximize browser window

If you call browser.newContext({ viewport: null }), it would tell Playwright to not emulate certain device size and will follow the browser size when maximized. Is that what you are looking for?

Before the viewport: null I'm getting:

width: 800 height: 600

which is expected of course, since that is the default. I tried the browser.newContext({ viewport: null }) and now I'm getting:

width: 1200 height: 610

Which does take the whole size of the browser, but the browser itself is not full screen. For reference, my full screen browser should measure:

{width: 1280, height: 721}

Side Note: not sure why there is an extra 1 pixel height, I used this method on an about:blank page:

{
  width: document.documentElement.clientWidth,
  height: document.documentElement.clientHeight
}

@arjun27 What do you think here ?

Synced offline with @star-kashyap to understand this better. Due to DRM constraints, the tests are executed in headful mode. A small browser window impacts verifiability of execution, and looks suboptimal to an observer.

While it is possible to use something like --start-fullscreen or --window-size as args to launch a browser, it is not possible to enlarge the size of a new window launched with newContext. Combination of enlarged window size and viewport: null would fix this.

I think launching with args: ['--window-size=1280,720'] and using viewport: null should bring you close to where you want to be. But that would be Chromium-specific solution. Non-chromium you should run with viewport: { width: 1280, height: 720 }.

Please feel free to reopen if there is something else we can do for you here!

Reopening as a feature request.

Was this page helpful?
0 / 5 - 0 ratings