feat: do not let users pass userDataDir to browserType.launch() (#974)
We now have a separate method for this - `browserType.launchPersistent`. This will probably save our users quite some time.
This commit is contained in:
parent
b7f48f4603
commit
d735de5347
|
|
@ -50,6 +50,8 @@ export class Chromium implements BrowserType {
|
||||||
}
|
}
|
||||||
|
|
||||||
async launch(options?: LaunchOptions & { slowMo?: number }): Promise<CRBrowser> {
|
async launch(options?: LaunchOptions & { slowMo?: number }): Promise<CRBrowser> {
|
||||||
|
if (options && (options as any).userDataDir)
|
||||||
|
throw new Error('userDataDir option is not supported in `browserType.launch`. Use `browserType.launchPersistent` instead');
|
||||||
const { browserServer, transport } = await this._launchServer(options, 'local');
|
const { browserServer, transport } = await this._launchServer(options, 'local');
|
||||||
const browser = await CRBrowser.connect(transport!, options && options.slowMo);
|
const browser = await CRBrowser.connect(transport!, options && options.slowMo);
|
||||||
// Hack: for typical launch scenario, ensure that close waits for actual process termination.
|
// Hack: for typical launch scenario, ensure that close waits for actual process termination.
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ export class Firefox implements BrowserType {
|
||||||
}
|
}
|
||||||
|
|
||||||
async launch(options?: LaunchOptions & { slowMo?: number }): Promise<FFBrowser> {
|
async launch(options?: LaunchOptions & { slowMo?: number }): Promise<FFBrowser> {
|
||||||
|
if (options && (options as any).userDataDir)
|
||||||
|
throw new Error('userDataDir option is not supported in `browserType.launch`. Use `browserType.launchPersistent` instead');
|
||||||
const { browserServer, transport } = await this._launchServer(options, 'local');
|
const { browserServer, transport } = await this._launchServer(options, 'local');
|
||||||
const browser = await FFBrowser.connect(transport!, options && options.slowMo);
|
const browser = await FFBrowser.connect(transport!, options && options.slowMo);
|
||||||
// Hack: for typical launch scenario, ensure that close waits for actual process termination.
|
// Hack: for typical launch scenario, ensure that close waits for actual process termination.
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ export class WebKit implements BrowserType {
|
||||||
}
|
}
|
||||||
|
|
||||||
async launch(options?: LaunchOptions & { slowMo?: number }): Promise<WKBrowser> {
|
async launch(options?: LaunchOptions & { slowMo?: number }): Promise<WKBrowser> {
|
||||||
|
if (options && (options as any).userDataDir)
|
||||||
|
throw new Error('userDataDir option is not supported in `browserType.launch`. Use `browserType.launchPersistent` instead');
|
||||||
const { browserServer, transport } = await this._launchServer(options, 'local');
|
const { browserServer, transport } = await this._launchServer(options, 'local');
|
||||||
const browser = await WKBrowser.connect(transport!, options && options.slowMo);
|
const browser = await WKBrowser.connect(transport!, options && options.slowMo);
|
||||||
// Hack: for typical launch scenario, ensure that close waits for actual process termination.
|
// Hack: for typical launch scenario, ensure that close waits for actual process termination.
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,12 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
|
||||||
await neverResolves;
|
await neverResolves;
|
||||||
expect(error.message).toContain('Protocol error');
|
expect(error.message).toContain('Protocol error');
|
||||||
});
|
});
|
||||||
|
it('should throw if userDataDir option is passed', async() => {
|
||||||
|
let waitError = null;
|
||||||
|
const options = Object.assign({}, defaultBrowserOptions, {userDataDir: 'random-path'});
|
||||||
|
await playwright.launch(options).catch(e => waitError = e);
|
||||||
|
expect(waitError.message).toContain('launchPersistent');
|
||||||
|
});
|
||||||
it('should reject if executable path is invalid', async({server}) => {
|
it('should reject if executable path is invalid', async({server}) => {
|
||||||
let waitError = null;
|
let waitError = null;
|
||||||
const options = Object.assign({}, defaultBrowserOptions, {executablePath: 'random-invalid-path'});
|
const options = Object.assign({}, defaultBrowserOptions, {executablePath: 'random-invalid-path'});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue