-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] 0.15 Cannot launch new chromium context after closing old one #1962
Comments
Which operating system / Linux distribution are you using? |
Sorry - meant macOS 10.15.4 |
I am having a somewhat related (?) error after upgrading from Using chromium for testing on Ubuntu 18.04.4 LTS. The tests which were working well earlier, have started having this error now:
beforeAll(async () => {
browser = await chromium.launch({ headless: false });
// custom function
teamMembers = await getTeamMembersDataFromMdFiles();
});
beforeEach(async () => {
browserContext = await browser.newContext();
page = await browserContext.newPage();
await page.goto(`${appUrl}/`);
});
afterEach(async () => {
await page.close();
await browserContext.close();
});
afterAll(async () => {
await browser.close();
}); If this error is not related, apologies; please let me know. I will create another ticket. Edit: Working fine for |
Your code snippets look good, so there is something wrong with either the test harness or with Playwright. Our tests do the same thing and they pass. Could you share an end-to-end snippet or a repo where this would reproduce? That would help a lot. |
Here's an example. Following example works for:
Breaks on Chromium, trying to run both tests together. Error (before second test):
Playwright: 0.15.0 const { chromium } = require('playwright');
const appUrl = 'http://example.com/';
let page;
let browserContext;
let browser;
beforeAll(async () => {
browser = await chromium.launch({ headless: false });
});
beforeEach(async () => {
browserContext = await browser.newContext();
page = await browserContext.newPage();
await page.goto(`${appUrl}/`);
});
afterEach(async () => {
if (!page.isClosed()) {
await page.close();
await browserContext.close();
}
});
afterAll(async () => {
await browser.close();
});
describe('Home Page', () => {
it('should have the correct title', async () => {
await page.waitForSelector('text=Example Domain');
const pageTitle = await page.title();
expect(pageTitle).toBe('Example Domain');
});
it('should have the correct text in link', async () => {
const tagEl = await page.waitForSelector('a');
const tagText = await tagEl.evaluate((el) => el.innerText);
expect(tagText).toBe('More information...');
});
}); Edit: Just checked, this works good for |
@pavelfeldman I've created a minimal standalone project you can check out that incorporates my snippet: https://github.com/alexduhanov/playwright-test Both tests in the suite pass individually but running the suite results in the |
Out of curiosity I ran my example snippet in headless mode, and the tests succeeded. It seems like the problem may be tied to disabling chromium headless mode, which is also consistent with the example @sagrawal-idrc posted. |
Thanks for the great example, I managed to reproduce it locally in headful mode (headless seems to be fine). In headful mode the browser crashes: pw:browser:err Received signal 11 SEGV_MAPERR ffffd2fb3eb2afdf +301ms I'll look at what's going on there. |
Minimal repro case: const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({
headless: false,
});
const context = await browser.newContext();
await context.newPage();
await context.close();
})(); |
Fixing upstream in https://chromium-review.googlesource.com/c/chromium/src/+/2168515 |
Context:
Code Snippet
Describe the bug
Error output:
This does seems to work for webkit and firefox.
Not sure if I'm doing something wrong -- I did see this note in the docs:
the default browser context cannot be closed.
but it wasn't clear to me if this meant "you cannot close the first new context you create via invoking newContext()" or "you cannot close a context if you do not invoke newContext() at all".Thanks!
The text was updated successfully, but these errors were encountered: