mirror of
https://github.com/microsoft/playwright.git
synced 2024-09-11 20:37:54 +03:00
Create userDataDir
if it does not exist (#9483)
This commit is contained in:
parent
584014f6fa
commit
84a70eae2f
@ -146,7 +146,11 @@ export abstract class BrowserType extends SdkObject {
|
||||
const artifactsDir = await fs.promises.mkdtemp(ARTIFACTS_FOLDER);
|
||||
tempDirectories.push(artifactsDir);
|
||||
|
||||
if (!userDataDir) {
|
||||
if (userDataDir) {
|
||||
// Firefox bails if the profile directory does not exist, Chrome creates it. We ensure consistent behavior here.
|
||||
if (!await existsAsync(userDataDir))
|
||||
await fs.promises.mkdir(userDataDir, { recursive: true, mode: 0o700 });
|
||||
} else {
|
||||
userDataDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), `playwright_${this._name}dev_profile-`));
|
||||
tempDirectories.push(userDataDir);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
import { playwrightTest as it, expect } from './config/browserTest';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
it('should support hasTouch option', async ({ server, launchPersistent }) => {
|
||||
const { page } = await launchPersistent({ hasTouch: true });
|
||||
@ -119,6 +120,13 @@ it('should restore state from userDataDir', async ({ browserType, browserOptions
|
||||
await browserContext3.close();
|
||||
});
|
||||
|
||||
it('should create userDataDir if it does not exist', async ({ createUserDataDir, browserType, browserOptions }) => {
|
||||
const userDataDir = path.join(await createUserDataDir(), 'nonexisting');
|
||||
const context = await browserType.launchPersistentContext(userDataDir, browserOptions);
|
||||
await context.close();
|
||||
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should restore cookies from userDataDir', async ({ browserType, browserOptions, server, createUserDataDir, platform, channel }) => {
|
||||
it.fixme(platform === 'win32' && channel === 'chrome');
|
||||
it.slow();
|
||||
|
Loading…
Reference in New Issue
Block a user