fix: render actions in ui mode with browsers from selenium (#23382)
This commit is contained in:
parent
49c8c6fa33
commit
7ab754f5d5
|
|
@ -146,12 +146,9 @@ export abstract class BrowserType extends SdkObject {
|
||||||
|
|
||||||
const env = options.env ? envArrayToObject(options.env) : process.env;
|
const env = options.env ? envArrayToObject(options.env) : process.env;
|
||||||
|
|
||||||
const tempDirectories = [];
|
await this._createArtifactDirs(options);
|
||||||
if (options.downloadsPath)
|
|
||||||
await fs.promises.mkdir(options.downloadsPath, { recursive: true });
|
|
||||||
if (options.tracesDir)
|
|
||||||
await fs.promises.mkdir(options.tracesDir, { recursive: true });
|
|
||||||
|
|
||||||
|
const tempDirectories = [];
|
||||||
const artifactsDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'playwright-artifacts-'));
|
const artifactsDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'playwright-artifacts-'));
|
||||||
tempDirectories.push(artifactsDir);
|
tempDirectories.push(artifactsDir);
|
||||||
|
|
||||||
|
|
@ -257,6 +254,13 @@ export abstract class BrowserType extends SdkObject {
|
||||||
return { browserProcess, artifactsDir, userDataDir, transport };
|
return { browserProcess, artifactsDir, userDataDir, transport };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _createArtifactDirs(options: types.LaunchOptions): Promise<void> {
|
||||||
|
if (options.downloadsPath)
|
||||||
|
await fs.promises.mkdir(options.downloadsPath, { recursive: true });
|
||||||
|
if (options.tracesDir)
|
||||||
|
await fs.promises.mkdir(options.tracesDir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
async connectOverCDP(metadata: CallMetadata, endpointURL: string, options: { slowMo?: number }, timeout?: number): Promise<Browser> {
|
async connectOverCDP(metadata: CallMetadata, endpointURL: string, options: { slowMo?: number }, timeout?: number): Promise<Browser> {
|
||||||
throw new Error('CDP connections are only supported by Chromium');
|
throw new Error('CDP connections are only supported by Chromium');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ export class Chromium extends BrowserType {
|
||||||
}, TimeoutSettings.timeout({ timeout }));
|
}, TimeoutSettings.timeout({ timeout }));
|
||||||
}
|
}
|
||||||
|
|
||||||
async _connectOverCDPInternal(progress: Progress, endpointURL: string, options: { slowMo?: number, headers?: types.HeadersArray }, onClose?: () => Promise<void>) {
|
async _connectOverCDPInternal(progress: Progress, endpointURL: string, options: types.LaunchOptions & { headers?: types.HeadersArray }, onClose?: () => Promise<void>) {
|
||||||
let headersMap: { [key: string]: string; } | undefined;
|
let headersMap: { [key: string]: string; } | undefined;
|
||||||
if (options.headers)
|
if (options.headers)
|
||||||
headersMap = headersArrayToObject(options.headers, false);
|
headersMap = headersArrayToObject(options.headers, false);
|
||||||
|
|
@ -107,8 +107,8 @@ export class Chromium extends BrowserType {
|
||||||
protocolLogger: helper.debugProtocolLogger(),
|
protocolLogger: helper.debugProtocolLogger(),
|
||||||
browserLogsCollector: new RecentLogsCollector(),
|
browserLogsCollector: new RecentLogsCollector(),
|
||||||
artifactsDir,
|
artifactsDir,
|
||||||
downloadsPath: artifactsDir,
|
downloadsPath: options.downloadsPath || artifactsDir,
|
||||||
tracesDir: artifactsDir,
|
tracesDir: options.tracesDir || artifactsDir,
|
||||||
// On Windows context level proxies only work, if there isn't a global proxy
|
// On Windows context level proxies only work, if there isn't a global proxy
|
||||||
// set. This is currently a bug in the CR/Windows networking stack. By
|
// set. This is currently a bug in the CR/Windows networking stack. By
|
||||||
// passing an arbitrary value we disable the check in PW land which warns
|
// passing an arbitrary value we disable the check in PW land which warns
|
||||||
|
|
@ -167,6 +167,8 @@ export class Chromium extends BrowserType {
|
||||||
}
|
}
|
||||||
|
|
||||||
override async _launchWithSeleniumHub(progress: Progress, hubUrl: string, options: types.LaunchOptions): Promise<CRBrowser> {
|
override async _launchWithSeleniumHub(progress: Progress, hubUrl: string, options: types.LaunchOptions): Promise<CRBrowser> {
|
||||||
|
await this._createArtifactDirs(options);
|
||||||
|
|
||||||
if (!hubUrl.endsWith('/'))
|
if (!hubUrl.endsWith('/'))
|
||||||
hubUrl = hubUrl + '/';
|
hubUrl = hubUrl + '/';
|
||||||
|
|
||||||
|
|
@ -252,7 +254,7 @@ export class Chromium extends BrowserType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this._connectOverCDPInternal(progress, endpointURL.toString(), { slowMo: options.slowMo }, disconnectFromSelenium);
|
return await this._connectOverCDPInternal(progress, endpointURL.toString(), options, disconnectFromSelenium);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await disconnectFromSelenium();
|
await disconnectFromSelenium();
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue