[Question] New browser windows are opened instead of tabs on every newPage()
See original GitHub issueTrying to use a single browser instance with mutiple sessions (pages/ tabs), but on every newPage() a new window is launched instead of a tab.
main.js
const chromium = require('playwright').chromium;
const options = {
headless: false,
timeout: 30000,
},
const browser = await chromium.launch(options);
app.set('browser', browser);
At this point browser window is not opened. (Unlike puppeteer which opens a new browser window on launch)
/lib/other.js
const browser = app.get('browser');
const page = await browser.newPage();
Now a new browser window is opened every time newPage is called, instead of opening a new page in the existing window.
So, Is this the expected behaviour with PlayWright?
NOTE: Puppeteer would open a window once (on launch) and add tabs on every newPage().
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
htmlpage.window.navigate opens a new page or new tab on ...
First click should open a new window and next click should refresh the same opened window or tab which is already opened. –...
Read more >Why Microsoft is opening every link in a new window
In my case, if Edge opens two tabs in a window, it will show only one instance of Edge in taskbar. Then when...
Read more >Opening Links in New Browser Windows and Tabs
New windows or tabs can cause disorientation, with users often not realizing that a new window or tab has opened. This problem is ......
Read more >Window.open() - Web APIs - MDN Web Docs
Users may use browser built-in features or extensions to choose whether to open a link in a new window, in the same window,...
Read more >How to Make Links Open in a New Window or Tab
How to Open Hyperlinks in a New Browser Tab or Window ... The short answer is: just add a target="_blank" attribute to your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, this intentional behavior. Each page is opened in its own window. We had to split it for video recording to properly work in other browsers and wanted to keep it consistent across browsers. Moreover, in your code snippet each page created by
const page = await browser.newPage();
will have its own context and we do not want to mix pages from separate contexts in the same window (similar to how pages from different chrome profiles could never be combined as tabs in the same window). Your code is equivalent to:Is there a test scenario that doesn’t work with separate window per page approach?
Well, our use case is not exactly related to testing but scrapping at high volume. Thus, opening many windows paralelly would hamper the memory footprint of our apps.