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.

[Question] Popup window is not opened in Fullscreen mode

See original GitHub issue

Context:

  • Playwright Version: v1.2.1
  • Operating System: Ubuntu 18.04.5 LTS
  • Node.js version: v15.3.0
  • Browser: all

Describe the bug

The starting browser is opened in fullscreen successfully. However, the popup window (new page) is not. Here is my code:

const browser = await chromium.launch({
        args: ['--start-maximized'],
        headless : false, slowMo : 50});
const context = await browser.newContext({viewport : null});
const loginPage = await context.newPage();
await loginPage.goto(myURL.href);  //Login Page was opened in Maximized mode (Fullscreen)

// Next step is to click a button on Login Page, and a new page is opened.
await loginPage.click('#nextBtn');

console.log('Get page after a specific action (e.g. clicking a button');
const [overviewPage] = await Promise.all([
    context.waitForEvent('page')
]);
await overviewPage.waitForLoadState();
await overviewPage.screenshot({ path: `reportoverview.png` });
console.log('Current window: ' + await overviewPage.title());

Everything works, except the new Popup window is not maximized. I expect that, I already set maximized flag in the context, so the new popup window should be also maximized. Or am I missing something.

Thank you.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
aslushnikovcommented, Dec 10, 2020

thanks for your answer. --start-maximized works fine for me. The browser is opened in fullscreen, and it doesn’t depend on my screen resolution.

@louis57 Interesting! I don’t have headful linux ATM to check this, but this definitely doesn’t work on OSX. Here’s the script I try (also please check out inline comments):

Popup dimensions demo
const playwright = require('playwright');

(async () => {
  browser = await playwright.chromium.launch({
    args: ['--start-maximized'], // does not have any difference on Mac
    headless: false,
  });
  const context = await browser.newContext({viewport: null});
  // The following would specify the page size, unless popup
  // size is explicitly defined.
  /*
  const context = await browser.newContext({viewport: {
    width: 1000,
    height: 1000,
  }});

  */

  const page = await context.newPage();
  await page.goto('about:blank');
  await page.setContent(`
    <script>
      function doOpen() {
        // This popup does not have explicit dimensions, so we can specify its
        // size in Playwright with context viewport option
        window.open('https://example.com', 'window', 'left=500,top=500');

        // This popup has explicit dimensions, so it'll always open in a 500x500 square.
        window.open('https://example.com', 'window', 'left=500,top=500,width=500,height=500');
      }
    </script>
    <button onclick="javascript:doOpen();">open popup</button>
  `);

  await page.click('button');
})();

Everything works, except the new Popup window is not maximized.

@louis57 one more question: if you run your scenario manually, starting with a maximized browser, is the popup opened maximized as well? If not, then popup is being opened with predefined width and height.

What I want to achieve is to change the viewport of a popup window, or maximize it, in this case is overviewPage

Unless popup has explicit dimensions, context’s viewport option will affect all the popups that are opened in the given context. Is there a specific reason you want to use --start-maximized over the browser.newContext({viewport: {width: 2000, height: 1000}})?

0reactions
louis57commented, Dec 15, 2020

@aslushnikov sorry to bother you again.

Is there a specific reason you want to use --start-maximized over the browser.newContext({viewport: {width: 2000, height: 1000}})?

Yes, there is a reason which I didn’t realize before. My webapp has a footer. If I use --start-maximized in the context, then this footer will be shown. If I set the viewport, either (1920,1080) or (2000, 1000), this footer is not shown, I don’t understand why, because the view port is already big enough. When I test manually, the footer is shown in all viewport size.

I have a test case to check the footer, but I couldn’t proceed because of this problem. I thought setViewportSize solved my problem, but it didn’t.

Now this --start-maximized works for loginPage which comes direct from context. But for popup window overviewPage, --start-maximized doesn’t apply to it, even the setViewportSize doesn’t really help. My goal is to set popup window also maximized, so that the footer is shown.

Have you by any chance a solution? Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to show fullscreen popup window in javascript?
Use screen.availWidth and screen.availHeight to calculate a suitable size for the height and width parameters in window.open(). Although this is likely to ...
Read more >
Issue :when I go fullscreen the popup modal is not visible on ...
It implies overwriting the function responsible for opening the full-screen mode. First, create the desired pop-up element and place it ...
Read more >
Popup always should be opened in tab on fullscreen mode
If user clicks the opener window while the new popup window is being created or after open, the full screen opener hides the...
Read more >
'Pop-up to confirm' window in full screen mode - SAP Community
POP Up window is a type of MODAL Window ( child window ) and it can't be launched in full screen mode. However...
Read more >
Web browser opens popups as new tabs when maximized
(On Windows OS both Chrome and Firefox works as expected - they open dialog windows regardless of the browser being maximized or not.)...
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