fix: render actions in ui mode with browsers from selenium (#23382)

This commit is contained in:
Dmitriy Dudkevich 2023-06-02 23:24:21 +03:00 коммит произвёл GitHub
Родитель 49c8c6fa33
Коммит 7ab754f5d5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 15 добавлений и 9 удалений

Просмотреть файл

@ -146,12 +146,9 @@ export abstract class BrowserType extends SdkObject {
const env = options.env ? envArrayToObject(options.env) : process.env;
const tempDirectories = [];
if (options.downloadsPath)
await fs.promises.mkdir(options.downloadsPath, { recursive: true });
if (options.tracesDir)
await fs.promises.mkdir(options.tracesDir, { recursive: true });
await this._createArtifactDirs(options);
const tempDirectories = [];
const artifactsDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'playwright-artifacts-'));
tempDirectories.push(artifactsDir);
@ -257,6 +254,13 @@ export abstract class BrowserType extends SdkObject {
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> {
throw new Error('CDP connections are only supported by Chromium');
}

Просмотреть файл

@ -70,7 +70,7 @@ export class Chromium extends BrowserType {
}, 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;
if (options.headers)
headersMap = headersArrayToObject(options.headers, false);
@ -107,8 +107,8 @@ export class Chromium extends BrowserType {
protocolLogger: helper.debugProtocolLogger(),
browserLogsCollector: new RecentLogsCollector(),
artifactsDir,
downloadsPath: artifactsDir,
tracesDir: artifactsDir,
downloadsPath: options.downloadsPath || artifactsDir,
tracesDir: options.tracesDir || artifactsDir,
// 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
// 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> {
await this._createArtifactDirs(options);
if (!hubUrl.endsWith('/'))
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) {
await disconnectFromSelenium();
throw e;