Using example here: https://github.com/microsoft/playwright/issues/15142 My code is below, I hit the "Record at cursor" in vscode, but an incognito window is still opened. Is there a simpler way to get out of incognito? If not, any idea why the code, or my approach is not working? Thank you
import { test as _test, expect, BrowserContext } from '@playwright/test';
import playwright from 'playwright-core';
import fs from 'fs';
import os from 'os';
import path from 'path';
const test = _test.extend<{ context: BrowserContext }>({
context: async ({ browserName }, use) => {
const tmpUserDataDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'playwright-user-data-dir-'));
const context = await playwright[browserName].launchPersistentContext(tmpUserDataDir, { /* other options */});
await use(context);
await fs.promises.rm(tmpUserDataDir, { recursive: true, force: true });
}
})
test('test', async ({ page }) => {
await page.goto('https://google.com');
});
This thread is trying to answer question "Why does 'launchPersistentContext' still launch an incognito window and is there a simpler way to avoid this?"
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].