Skip to content

Commit 095ad63

Browse files
authored
chore: update error message when using userDataDir arg (#5814)
1 parent ea32ad2 commit 095ad63

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/server/chromium/chromium.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class Chromium extends BrowserType {
119119
const { args = [], proxy } = options;
120120
const userDataDirArg = args.find(arg => arg.startsWith('--user-data-dir'));
121121
if (userDataDirArg)
122-
throw new Error('Pass userDataDir parameter instead of specifying --user-data-dir argument');
122+
throw new Error('Pass userDataDir parameter to `browserType.launchPersistentContext(userDataDir, ...)` instead of specifying --user-data-dir argument');
123123
if (args.find(arg => arg.startsWith('--remote-debugging-pipe')))
124124
throw new Error('Playwright manages remote debugging connection itself.');
125125
if (args.find(arg => !arg.startsWith('-')))

src/server/firefox/firefox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class Firefox extends BrowserType {
6060
console.warn('devtools parameter is not supported as a launch argument in Firefox. You can launch the devtools window manually.');
6161
const userDataDirArg = args.find(arg => arg.startsWith('-profile') || arg.startsWith('--profile'));
6262
if (userDataDirArg)
63-
throw new Error('Pass userDataDir parameter instead of specifying -profile argument');
63+
throw new Error('Pass userDataDir parameter to `browserType.launchPersistentContext(userDataDir, ...)` instead of specifying --profile argument');
6464
if (args.find(arg => arg.startsWith('-juggler')))
6565
throw new Error('Use the port parameter instead of -juggler argument');
6666
const firefoxUserPrefs = isPersistent ? undefined : options.firefoxUserPrefs;

src/server/webkit/webkit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ export class WebKit extends BrowserType {
4949
const { args = [], proxy, devtools, headless } = options;
5050
if (devtools)
5151
console.warn('devtools parameter as a launch argument in WebKit is not supported. Also starting Web Inspector manually will terminate the execution in WebKit.');
52-
const userDataDirArg = args.find(arg => arg.startsWith('--user-data-dir='));
52+
const userDataDirArg = args.find(arg => arg.startsWith('--user-data-dir'));
5353
if (userDataDirArg)
54-
throw new Error('Pass userDataDir parameter instead of specifying --user-data-dir argument');
54+
throw new Error('Pass userDataDir parameter to `browserType.launchPersistentContext(userDataDir, ...)` instead of specifying --user-data-dir argument');
5555
if (args.find(arg => !arg.startsWith('-')))
5656
throw new Error('Arguments can not specify page to be opened');
5757
const webkitArguments = ['--inspector-pipe'];

test/browsertype-launch.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ it('should throw if userDataDir option is passed', async ({browserType, browserO
3636
expect(waitError.message).toContain('userDataDir option is not supported in `browserType.launch`. Use `browserType.launchPersistentContext` instead');
3737
});
3838

39+
it('should throw if userDataDir is passed as an argument', async ({browserType, browserOptions}) => {
40+
let waitError = null;
41+
const options = Object.assign({}, browserOptions, {args: ['--user-data-dir=random-path', '--profile=random-path']});
42+
await browserType.launch(options).catch(e => waitError = e);
43+
expect(waitError.message).toContain('Pass userDataDir parameter to `browserType.launchPersistentContext');
44+
});
45+
3946
it('should throw if port option is passed', async ({browserType, browserOptions}) => {
4047
const options = Object.assign({}, browserOptions, {port: 1234});
4148
const error = await browserType.launch(options).catch(e => e);

0 commit comments

Comments
 (0)