Hi everyone! I am running 10 playwright browsers at the same time and out of them only one of them is working properly. I definitely need to run the browsers in non incognito mode. Here is my code:
const browser = await chromium.launchPersistentContext(
userDataFolder,
{
timeout: 30000,
headless: true,
bypassCSP: true,
ignoreHTTPSErrors: true,
timezoneId: 'America/Los_Angeles',
userAgent:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.187 Safari/537.36',
args: [
'--headless=new',
'--no-sandbox',
'--disable-setid-sandbox',
'--ignore-certificate-errors',
'--disable-blink-features=AutomationControlled',
'--disable-features=IsolateOrigins,site-per-process',
'--remote-debugging-port=9222',
'--disable-setuid-sandbox',
'--disk-cache-size=1',
'--disable-infobars',
],
ignoreDefaultArgs: ['--enable-automation'],
javaScriptEnabled: true,
proxy,
}
);
This is error:
This thread is trying to answer question "Why are only one out of 10 playwright browsers working properly when launched simultaneously?"
What way are you using to start them at the same time? I don't know if Playwright library is thread safe. At least for Python and Java it is not.
And how sure are you that you really need non-incognito mode? Launching 10 browsers instead of just 10 lightweight browser contexts inside the same browser is using a lot more resources.
If all you need is cookies and local storage to be saved/restored, then you could alternatively use the storage state feature. https://playwright.dev/docs/api/class-browsercontext#browser-context-storage-state
On the NodeJS side you could probably rely on async instead of threading to do things in parallel. Most of the time the NodeJS code will be waiting for the real work to be done by the browsers.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].