infra(channel): wire release channel to all tests (#5820)
This commit is contained in:
parent
a96d6a7dbb
commit
1dd6bd3316
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
|
|
@ -272,8 +272,12 @@ jobs:
|
||||||
- name: Install Chrome Stable
|
- name: Install Chrome Stable
|
||||||
run: sudo apt install google-chrome-stable
|
run: sudo apt install google-chrome-stable
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
env:
|
||||||
|
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: node lib/cli/cli install-deps chromium
|
- run: node lib/cli/cli install-deps chromium
|
||||||
|
# This only created problems, should we move ffmpeg back into npm?
|
||||||
|
- run: node lib/cli/cli install ffmpeg
|
||||||
- run: mkdir -p coredumps
|
- run: mkdir -p coredumps
|
||||||
# Set core dump file name pattern
|
# Set core dump file name pattern
|
||||||
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern'
|
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern'
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,19 @@ Whether to run browser in headless mode. More details for
|
||||||
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode). Defaults to `true` unless the
|
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode). Defaults to `true` unless the
|
||||||
[`option: devtools`] option is `true`.
|
[`option: devtools`] option is `true`.
|
||||||
|
|
||||||
|
### option: BrowserType.launchPersistentContext.channel
|
||||||
|
- `channel` <[string]>
|
||||||
|
|
||||||
|
Chromium distribution channel, one of
|
||||||
|
* chrome
|
||||||
|
* chrome-beta
|
||||||
|
* chrome-dev
|
||||||
|
* chrome-canary
|
||||||
|
* msedge
|
||||||
|
* msedge-beta
|
||||||
|
* msedge-dev
|
||||||
|
* msedge-canary
|
||||||
|
|
||||||
### option: BrowserType.launchPersistentContext.executablePath
|
### option: BrowserType.launchPersistentContext.executablePath
|
||||||
- `executablePath` <[path]>
|
- `executablePath` <[path]>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ program
|
||||||
.description('ensure browsers necessary for this version of Playwright are installed')
|
.description('ensure browsers necessary for this version of Playwright are installed')
|
||||||
.action(async function(browserType) {
|
.action(async function(browserType) {
|
||||||
try {
|
try {
|
||||||
const allBrowsers = new Set(['chromium', 'firefox', 'webkit']);
|
const allBrowsers = new Set(['chromium', 'firefox', 'webkit', 'ffmpeg']);
|
||||||
for (const type of browserType) {
|
for (const type of browserType) {
|
||||||
if (!allBrowsers.has(type)) {
|
if (!allBrowsers.has(type)) {
|
||||||
console.log(`Invalid browser name: '${type}'. Expecting 'chromium', 'firefox' or 'webkit'.`);
|
console.log(`Invalid browser name: '${type}'. Expecting 'chromium', 'firefox' or 'webkit'.`);
|
||||||
|
|
@ -186,6 +186,7 @@ else
|
||||||
|
|
||||||
type Options = {
|
type Options = {
|
||||||
browser: string;
|
browser: string;
|
||||||
|
channel?: string;
|
||||||
colorScheme?: string;
|
colorScheme?: string;
|
||||||
device?: string;
|
device?: string;
|
||||||
geolocation?: string;
|
geolocation?: string;
|
||||||
|
|
@ -209,6 +210,9 @@ async function launchContext(options: Options, headless: boolean): Promise<{ bro
|
||||||
validateOptions(options);
|
validateOptions(options);
|
||||||
const browserType = lookupBrowserType(options);
|
const browserType = lookupBrowserType(options);
|
||||||
const launchOptions: LaunchOptions = { headless };
|
const launchOptions: LaunchOptions = { headless };
|
||||||
|
if (options.channel)
|
||||||
|
launchOptions.channel = options.channel;
|
||||||
|
|
||||||
const contextOptions: BrowserContextOptions =
|
const contextOptions: BrowserContextOptions =
|
||||||
// Copy the device descriptor since we have to compare and modify the options.
|
// Copy the device descriptor since we have to compare and modify the options.
|
||||||
options.device ? { ...playwright.devices[options.device] } : {};
|
options.device ? { ...playwright.devices[options.device] } : {};
|
||||||
|
|
@ -452,6 +456,7 @@ function commandWithOpenOptions(command: string, description: string, options: a
|
||||||
result = result.option(option[0], ...option.slice(1));
|
result = result.option(option[0], ...option.slice(1));
|
||||||
return result
|
return result
|
||||||
.option('-b, --browser <browserType>', 'browser to use, one of cr, chromium, ff, firefox, wk, webkit', 'chromium')
|
.option('-b, --browser <browserType>', 'browser to use, one of cr, chromium, ff, firefox, wk, webkit', 'chromium')
|
||||||
|
.option('--channel <channel>', 'Chromium distribution channel, "chrome", "chrome-beta", "msedge-dev", etc')
|
||||||
.option('--color-scheme <scheme>', 'emulate preferred color scheme, "light" or "dark"')
|
.option('--color-scheme <scheme>', 'emulate preferred color scheme, "light" or "dark"')
|
||||||
.option('--device <deviceName>', 'emulate device, for example "iPhone 11"')
|
.option('--device <deviceName>', 'emulate device, for example "iPhone 11"')
|
||||||
.option('--geolocation <coordinates>', 'specify geolocation coordinates, for example "37.819722,-122.478611"')
|
.option('--geolocation <coordinates>', 'specify geolocation coordinates, for example "37.819722,-122.478611"')
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel, chann
|
||||||
ignoreDefaultArgs: Array.isArray(options.ignoreDefaultArgs) ? options.ignoreDefaultArgs : undefined,
|
ignoreDefaultArgs: Array.isArray(options.ignoreDefaultArgs) ? options.ignoreDefaultArgs : undefined,
|
||||||
ignoreAllDefaultArgs: !!options.ignoreDefaultArgs && !Array.isArray(options.ignoreDefaultArgs),
|
ignoreAllDefaultArgs: !!options.ignoreDefaultArgs && !Array.isArray(options.ignoreDefaultArgs),
|
||||||
env: options.env ? envObjectToArray(options.env) : undefined,
|
env: options.env ? envObjectToArray(options.env) : undefined,
|
||||||
|
channel: options.channel,
|
||||||
userDataDir,
|
userDataDir,
|
||||||
};
|
};
|
||||||
const result = await channel.launchPersistentContext(persistentParams);
|
const result = await channel.launchPersistentContext(persistentParams);
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,7 @@ export type BrowserTypeLaunchResult = {
|
||||||
browser: BrowserChannel,
|
browser: BrowserChannel,
|
||||||
};
|
};
|
||||||
export type BrowserTypeLaunchPersistentContextParams = {
|
export type BrowserTypeLaunchPersistentContextParams = {
|
||||||
|
channel?: string,
|
||||||
userDataDir: string,
|
userDataDir: string,
|
||||||
sdkLanguage: string,
|
sdkLanguage: string,
|
||||||
executablePath?: string,
|
executablePath?: string,
|
||||||
|
|
@ -333,6 +334,7 @@ export type BrowserTypeLaunchPersistentContextParams = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
export type BrowserTypeLaunchPersistentContextOptions = {
|
export type BrowserTypeLaunchPersistentContextOptions = {
|
||||||
|
channel?: string,
|
||||||
executablePath?: string,
|
executablePath?: string,
|
||||||
args?: string[],
|
args?: string[],
|
||||||
ignoreAllDefaultArgs?: boolean,
|
ignoreAllDefaultArgs?: boolean,
|
||||||
|
|
|
||||||
|
|
@ -334,6 +334,7 @@ BrowserType:
|
||||||
|
|
||||||
launchPersistentContext:
|
launchPersistentContext:
|
||||||
parameters:
|
parameters:
|
||||||
|
channel: string?
|
||||||
userDataDir: string
|
userDataDir: string
|
||||||
sdkLanguage: string
|
sdkLanguage: string
|
||||||
executablePath: string?
|
executablePath: string?
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
||||||
slowMo: tOptional(tNumber),
|
slowMo: tOptional(tNumber),
|
||||||
});
|
});
|
||||||
scheme.BrowserTypeLaunchPersistentContextParams = tObject({
|
scheme.BrowserTypeLaunchPersistentContextParams = tObject({
|
||||||
|
channel: tOptional(tString),
|
||||||
userDataDir: tString,
|
userDataDir: tString,
|
||||||
sdkLanguage: tString,
|
sdkLanguage: tString,
|
||||||
executablePath: tOptional(tString),
|
executablePath: tOptional(tString),
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ export type PlaywrightOptions = {
|
||||||
export type BrowserOptions = PlaywrightOptions & {
|
export type BrowserOptions = PlaywrightOptions & {
|
||||||
name: string,
|
name: string,
|
||||||
isChromium: boolean,
|
isChromium: boolean,
|
||||||
|
channel?: string,
|
||||||
downloadsPath?: string,
|
downloadsPath?: string,
|
||||||
headful?: boolean,
|
headful?: boolean,
|
||||||
persistent?: types.BrowserContextOptions, // Undefined means no persistent context.
|
persistent?: types.BrowserContextOptions, // Undefined means no persistent context.
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ export abstract class BrowserType extends SdkObject {
|
||||||
...this._playwrightOptions,
|
...this._playwrightOptions,
|
||||||
name: this._name,
|
name: this._name,
|
||||||
isChromium: this._name === 'chromium',
|
isChromium: this._name === 'chromium',
|
||||||
|
channel: options.channel,
|
||||||
slowMo: options.slowMo,
|
slowMo: options.slowMo,
|
||||||
persistent,
|
persistent,
|
||||||
headful: !options.headless,
|
headful: !options.headless,
|
||||||
|
|
@ -176,7 +177,7 @@ export abstract class BrowserType extends SdkObject {
|
||||||
throw new Error(errorMessageLines.join('\n'));
|
throw new Error(errorMessageLines.join('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!executablePath) {
|
if (!executable) {
|
||||||
// We can only validate dependencies for bundled browsers.
|
// We can only validate dependencies for bundled browsers.
|
||||||
await validateHostRequirements(this._registry, this._name);
|
await validateHostRequirements(this._registry, this._name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ import path from 'path';
|
||||||
function darwin(channel: string): string | undefined {
|
function darwin(channel: string): string | undefined {
|
||||||
switch (channel) {
|
switch (channel) {
|
||||||
case 'chrome': return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
case 'chrome': return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
||||||
|
case 'chrome-beta': return '/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta';
|
||||||
|
case 'chrome-dev': return '/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev';
|
||||||
case 'chrome-canary': return '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary';
|
case 'chrome-canary': return '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary';
|
||||||
case 'msedge': return '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge';
|
case 'msedge': return '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge';
|
||||||
case 'msedge-beta': return '/Applications/Microsoft Edge Beta.app/Contents/MacOS/Microsoft Edge Beta';
|
case 'msedge-beta': return '/Applications/Microsoft Edge Beta.app/Contents/MacOS/Microsoft Edge Beta';
|
||||||
|
|
@ -41,6 +43,8 @@ function win32(channel: string): string | undefined {
|
||||||
let suffix: string | undefined;
|
let suffix: string | undefined;
|
||||||
switch (channel) {
|
switch (channel) {
|
||||||
case 'chrome': suffix = `\\Google\\Chrome\\Application\\chrome.exe`; break;
|
case 'chrome': suffix = `\\Google\\Chrome\\Application\\chrome.exe`; break;
|
||||||
|
case 'chrome-beta': suffix = `\\Google\\Chrome Beta\\Application\\chrome.exe`; break;
|
||||||
|
case 'chrome-dev': suffix = `\\Google\\Chrome Dev\\Application\\chrome.exe`; break;
|
||||||
case 'chrome-canary': suffix = `\\Google\\Chrome SxS\\Application\\chrome.exe`; break;
|
case 'chrome-canary': suffix = `\\Google\\Chrome SxS\\Application\\chrome.exe`; break;
|
||||||
case 'msedge': suffix = `\\Microsoft\\Edge\\Application\\msedge.exe`; break;
|
case 'msedge': suffix = `\\Microsoft\\Edge\\Application\\msedge.exe`; break;
|
||||||
case 'msedge-beta': suffix = `\\Microsoft\\Edge Beta\\Application\\msedge.exe`; break;
|
case 'msedge-beta': suffix = `\\Microsoft\\Edge Beta\\Application\\msedge.exe`; break;
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,8 @@ export class CSharpLanguageGenerator implements LanguageGenerator {
|
||||||
formatter.add(`
|
formatter.add(`
|
||||||
await Playwright.InstallAsync();
|
await Playwright.InstallAsync();
|
||||||
using var playwright = await Playwright.CreateAsync();
|
using var playwright = await Playwright.CreateAsync();
|
||||||
await using var browser = await playwright.${toPascal(options.browserName)}.LaunchAsync(${formatArgs(options.launchOptions)});
|
await using var browser = await playwright.${toPascal(options.browserName)}.LaunchAsync(${formatArgs(options.launchOptions)}
|
||||||
|
);
|
||||||
var context = await browser.NewContextAsync(${formatContextOptions(options.contextOptions, options.deviceName)});`);
|
var context = await browser.NewContextAsync(${formatContextOptions(options.contextOptions, options.deviceName)});`);
|
||||||
return formatter.format();
|
return formatter.format();
|
||||||
}
|
}
|
||||||
|
|
@ -178,10 +179,7 @@ function formatArgs(value: any, indent = ' '): string {
|
||||||
const tokens: string[] = [];
|
const tokens: string[] = [];
|
||||||
for (const key of keys)
|
for (const key of keys)
|
||||||
tokens.push(`${keys.length !== 1 ? indent : ''}${key}: ${formatObject(value[key], indent, key)}`);
|
tokens.push(`${keys.length !== 1 ? indent : ''}${key}: ${formatObject(value[key], indent, key)}`);
|
||||||
if (keys.length === 1)
|
return `\n${indent}${tokens.join(`,\n${indent}`)}`;
|
||||||
return `${tokens.join(`,\n${indent}`)}`;
|
|
||||||
else
|
|
||||||
return `\n${indent}${tokens.join(`,\n${indent}`)}`;
|
|
||||||
}
|
}
|
||||||
return String(value);
|
return String(value);
|
||||||
}
|
}
|
||||||
|
|
@ -271,7 +269,7 @@ class CSharpFormatter {
|
||||||
return this._lines.map((line: string) => {
|
return this._lines.map((line: string) => {
|
||||||
if (line === '')
|
if (line === '')
|
||||||
return line;
|
return line;
|
||||||
if (line.startsWith('}') || line.startsWith(']') || line.includes('});'))
|
if (line.startsWith('}') || line.startsWith(']') || line.includes('});') || line === ');')
|
||||||
spaces = spaces.substring(this._baseIndent.length);
|
spaces = spaces.substring(this._baseIndent.length);
|
||||||
|
|
||||||
const extraSpaces = /^(for|while|if).*\(.*\)$/.test(previousLine) ? this._baseIndent : '';
|
const extraSpaces = /^(for|while|if).*\(.*\)$/.test(previousLine) ? this._baseIndent : '';
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,8 @@ function formatLaunchOptions(options: any): string {
|
||||||
lines.push('new BrowserType.LaunchOptions()');
|
lines.push('new BrowserType.LaunchOptions()');
|
||||||
if (typeof options.headless === 'boolean')
|
if (typeof options.headless === 'boolean')
|
||||||
lines.push(` .setHeadless(false)`);
|
lines.push(` .setHeadless(false)`);
|
||||||
|
if (options.channel)
|
||||||
|
lines.push(` .setChannel("${options.channel}")`);
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ export class RecorderApp extends EventEmitter {
|
||||||
if (isUnderTest())
|
if (isUnderTest())
|
||||||
args.push(`--remote-debugging-port=0`);
|
args.push(`--remote-debugging-port=0`);
|
||||||
const context = await recorderPlaywright.chromium.launchPersistentContext(internalCallMetadata(), '', {
|
const context = await recorderPlaywright.chromium.launchPersistentContext(internalCallMetadata(), '', {
|
||||||
|
channel: inspectedContext._browser.options.channel,
|
||||||
sdkLanguage: inspectedContext._options.sdkLanguage,
|
sdkLanguage: inspectedContext._options.sdkLanguage,
|
||||||
args,
|
args,
|
||||||
noDefaultViewport: true,
|
noDefaultViewport: true,
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,11 @@
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { it, expect } from './fixtures';
|
import { it, expect } from './fixtures';
|
||||||
|
|
||||||
it('browserType.executablePath should work', test => {
|
it('browserType.executablePath should work', (test, { browserChannel }) => {
|
||||||
|
test.fixme(!!browserChannel, 'Uncomment on roll');
|
||||||
test.skip(Boolean(process.env.CRPATH || process.env.FFPATH || process.env.WKPATH));
|
test.skip(Boolean(process.env.CRPATH || process.env.FFPATH || process.env.WKPATH));
|
||||||
}, async ({browserType}) => {
|
}, async ({ browserType, browserChannel }) => {
|
||||||
|
// Interesting, unless I use browserChannel in test, filter above does not work!
|
||||||
const executablePath = browserType.executablePath();
|
const executablePath = browserType.executablePath();
|
||||||
expect(fs.existsSync(executablePath)).toBe(true);
|
expect(fs.existsSync(executablePath)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,9 @@ describe('launch server', (suite, { mode }) => {
|
||||||
await browserServer.close();
|
await browserServer.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fire close event', async ({browserType, browserOptions}) => {
|
it('should fire close event', (test, { browserChannel }) => {
|
||||||
|
test.fixme(!!browserChannel, 'Uncomment on roll');
|
||||||
|
}, async ({browserType, browserOptions}) => {
|
||||||
const browserServer = await browserType.launchServer(browserOptions);
|
const browserServer = await browserType.launchServer(browserOptions);
|
||||||
const [result] = await Promise.all([
|
const [result] = await Promise.all([
|
||||||
// @ts-expect-error The signal parameter is not documented.
|
// @ts-expect-error The signal parameter is not documented.
|
||||||
|
|
|
||||||
|
|
@ -21,24 +21,28 @@ import { folio } from './cli.fixtures';
|
||||||
const { it, expect } = folio;
|
const { it, expect } = folio;
|
||||||
|
|
||||||
const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
|
const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
|
||||||
|
const launchOptions = (channel: string) => {
|
||||||
|
return channel ? `headless: false,\n channel: "${channel}"` : 'headless: false';
|
||||||
|
};
|
||||||
|
|
||||||
function capitalize(browserName: string): string {
|
function capitalize(browserName: string): string {
|
||||||
return browserName[0].toUpperCase() + browserName.slice(1);
|
return browserName[0].toUpperCase() + browserName.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should print the correct imports and context options', async ({ browserName, runCLI }) => {
|
it('should print the correct imports and context options', async ({ browserName, browserChannel, runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--target=csharp', emptyHTML]);
|
const cli = runCLI(['--target=csharp', emptyHTML]);
|
||||||
const expectedResult = `await Playwright.InstallAsync();
|
const expectedResult = `await Playwright.InstallAsync();
|
||||||
using var playwright = await Playwright.CreateAsync();
|
using var playwright = await Playwright.CreateAsync();
|
||||||
await using var browser = await playwright.${capitalize(browserName)}.LaunchAsync(headless: false);
|
await using var browser = await playwright.${capitalize(browserName)}.LaunchAsync(
|
||||||
|
${launchOptions(browserChannel)}
|
||||||
|
);
|
||||||
var context = await browser.NewContextAsync();`;
|
var context = await browser.NewContextAsync();`;
|
||||||
await cli.waitFor(expectedResult).catch(e => e);
|
await cli.waitFor(expectedResult).catch(e => e);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print the correct context options for custom settings', async ({ browserName, runCLI }) => {
|
it('should print the correct context options for custom settings', async ({ browserName, browserChannel, runCLI }) => {
|
||||||
const cli = runCLI([
|
const cli = runCLI([
|
||||||
'codegen',
|
|
||||||
'--color-scheme=dark',
|
'--color-scheme=dark',
|
||||||
'--geolocation=37.819722,-122.478611',
|
'--geolocation=37.819722,-122.478611',
|
||||||
'--lang=es',
|
'--lang=es',
|
||||||
|
|
@ -51,11 +55,12 @@ it('should print the correct context options for custom settings', async ({ brow
|
||||||
const expectedResult = `await Playwright.InstallAsync();
|
const expectedResult = `await Playwright.InstallAsync();
|
||||||
using var playwright = await Playwright.CreateAsync();
|
using var playwright = await Playwright.CreateAsync();
|
||||||
await using var browser = await playwright.${capitalize(browserName)}.LaunchAsync(
|
await using var browser = await playwright.${capitalize(browserName)}.LaunchAsync(
|
||||||
headless: false,
|
${launchOptions(browserChannel)},
|
||||||
proxy: new ProxySettings
|
proxy: new ProxySettings
|
||||||
{
|
{
|
||||||
Server = "http://myproxy:3128",
|
Server = "http://myproxy:3128",
|
||||||
});
|
}
|
||||||
|
);
|
||||||
var context = await browser.NewContextAsync(
|
var context = await browser.NewContextAsync(
|
||||||
viewport: new ViewportSize
|
viewport: new ViewportSize
|
||||||
{
|
{
|
||||||
|
|
@ -78,21 +83,22 @@ var context = await browser.NewContextAsync(
|
||||||
|
|
||||||
it('should print the correct context options when using a device', (test, { browserName }) => {
|
it('should print the correct context options when using a device', (test, { browserName }) => {
|
||||||
test.skip(browserName !== 'chromium');
|
test.skip(browserName !== 'chromium');
|
||||||
}, async ({ runCLI }) => {
|
}, async ({ browserChannel, runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--device=Pixel 2', '--target=csharp', emptyHTML]);
|
const cli = runCLI(['--device=Pixel 2', '--target=csharp', emptyHTML]);
|
||||||
const expectedResult = `await Playwright.InstallAsync();
|
const expectedResult = `await Playwright.InstallAsync();
|
||||||
using var playwright = await Playwright.CreateAsync();
|
using var playwright = await Playwright.CreateAsync();
|
||||||
await using var browser = await playwright.Chromium.LaunchAsync(headless: false);
|
await using var browser = await playwright.Chromium.LaunchAsync(
|
||||||
|
${launchOptions(browserChannel)}
|
||||||
|
);
|
||||||
var context = await browser.NewContextAsync(playwright.Devices["Pixel 2"]);`;
|
var context = await browser.NewContextAsync(playwright.Devices["Pixel 2"]);`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print the correct context options when using a device and additional options', (test, {browserName}) => {
|
it('should print the correct context options when using a device and additional options', (test, { browserName }) => {
|
||||||
test.skip(browserName !== 'webkit');
|
test.skip(browserName !== 'webkit');
|
||||||
}, async ({ runCLI }) => {
|
}, async ({ browserChannel, runCLI }) => {
|
||||||
const cli = runCLI([
|
const cli = runCLI([
|
||||||
'codegen',
|
|
||||||
'--device=iPhone 11',
|
'--device=iPhone 11',
|
||||||
'--color-scheme=dark',
|
'--color-scheme=dark',
|
||||||
'--geolocation=37.819722,-122.478611',
|
'--geolocation=37.819722,-122.478611',
|
||||||
|
|
@ -106,11 +112,12 @@ it('should print the correct context options when using a device and additional
|
||||||
const expectedResult = `await Playwright.InstallAsync();
|
const expectedResult = `await Playwright.InstallAsync();
|
||||||
using var playwright = await Playwright.CreateAsync();
|
using var playwright = await Playwright.CreateAsync();
|
||||||
await using var browser = await playwright.Webkit.LaunchAsync(
|
await using var browser = await playwright.Webkit.LaunchAsync(
|
||||||
headless: false,
|
${launchOptions(browserChannel)},
|
||||||
proxy: new ProxySettings
|
proxy: new ProxySettings
|
||||||
{
|
{
|
||||||
Server = "http://myproxy:3128",
|
Server = "http://myproxy:3128",
|
||||||
});
|
}
|
||||||
|
);
|
||||||
var context = await browser.NewContextAsync(new BrowserContextOptions(playwright.Devices["iPhone 11"])
|
var context = await browser.NewContextAsync(new BrowserContextOptions(playwright.Devices["iPhone 11"])
|
||||||
{
|
{
|
||||||
UserAgent = "hardkodemium",
|
UserAgent = "hardkodemium",
|
||||||
|
|
@ -134,15 +141,18 @@ var context = await browser.NewContextAsync(new BrowserContextOptions(playwright
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print load/save storageState', async ({ browserName, runCLI, testInfo }) => {
|
it('should print load/save storageState', async ({ browserName, browserChannel, runCLI, testInfo }) => {
|
||||||
const loadFileName = testInfo.outputPath('load.json');
|
const loadFileName = testInfo.outputPath('load.json');
|
||||||
const saveFileName = testInfo.outputPath('save.json');
|
const saveFileName = testInfo.outputPath('save.json');
|
||||||
await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8');
|
await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8');
|
||||||
const cli = runCLI(['codegen', `--load-storage=${loadFileName}`, `--save-storage=${saveFileName}`, '--target=csharp', emptyHTML]);
|
const cli = runCLI([`--load-storage=${loadFileName}`, `--save-storage=${saveFileName}`, '--target=csharp', emptyHTML]);
|
||||||
const expectedResult1 = `await Playwright.InstallAsync();
|
const expectedResult1 = `await Playwright.InstallAsync();
|
||||||
using var playwright = await Playwright.CreateAsync();
|
using var playwright = await Playwright.CreateAsync();
|
||||||
await using var browser = await playwright.${capitalize(browserName)}.LaunchAsync(headless: false);
|
await using var browser = await playwright.${capitalize(browserName)}.LaunchAsync(
|
||||||
var context = await browser.NewContextAsync(storageState: "${loadFileName}");`;
|
${launchOptions(browserChannel)}
|
||||||
|
);
|
||||||
|
var context = await browser.NewContextAsync(
|
||||||
|
storageState: "${loadFileName}");`;
|
||||||
await cli.waitFor(expectedResult1);
|
await cli.waitFor(expectedResult1);
|
||||||
|
|
||||||
const expectedResult2 = `
|
const expectedResult2 = `
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,12 @@ import { folio } from './cli.fixtures';
|
||||||
const { it, expect } = folio;
|
const { it, expect } = folio;
|
||||||
|
|
||||||
const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
|
const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
|
||||||
|
const launchOptions = (channel: string) => {
|
||||||
|
return channel ? `.setHeadless(false)\n .setChannel("${channel}")` : '.setHeadless(false)';
|
||||||
|
};
|
||||||
|
|
||||||
it('should print the correct imports and context options', async ({ runCLI, browserName }) => {
|
it('should print the correct imports and context options', async ({ runCLI, browserChannel, browserName }) => {
|
||||||
const cli = runCLI(['codegen', '--target=java', emptyHTML]);
|
const cli = runCLI(['--target=java', emptyHTML]);
|
||||||
const expectedResult = `import com.microsoft.playwright.*;
|
const expectedResult = `import com.microsoft.playwright.*;
|
||||||
import com.microsoft.playwright.options.*;
|
import com.microsoft.playwright.options.*;
|
||||||
|
|
||||||
|
|
@ -31,14 +34,14 @@ public class Example {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try (Playwright playwright = Playwright.create()) {
|
try (Playwright playwright = Playwright.create()) {
|
||||||
Browser browser = playwright.${browserName}().launch(new BrowserType.LaunchOptions()
|
Browser browser = playwright.${browserName}().launch(new BrowserType.LaunchOptions()
|
||||||
.setHeadless(false));
|
${launchOptions(browserChannel)});
|
||||||
BrowserContext context = browser.newContext();`;
|
BrowserContext context = browser.newContext();`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print the correct context options for custom settings', async ({ runCLI, browserName }) => {
|
it('should print the correct context options for custom settings', async ({ runCLI, browserName }) => {
|
||||||
const cli = runCLI(['codegen', '--color-scheme=light', '--target=java', emptyHTML]);
|
const cli = runCLI(['--color-scheme=light', '--target=java', emptyHTML]);
|
||||||
const expectedResult = `BrowserContext context = browser.newContext(new Browser.NewContextOptions()
|
const expectedResult = `BrowserContext context = browser.newContext(new Browser.NewContextOptions()
|
||||||
.setColorScheme(ColorScheme.LIGHT));`;
|
.setColorScheme(ColorScheme.LIGHT));`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
|
|
@ -48,7 +51,7 @@ it('should print the correct context options for custom settings', async ({ runC
|
||||||
it('should print the correct context options when using a device', (test, { browserName }) => {
|
it('should print the correct context options when using a device', (test, { browserName }) => {
|
||||||
test.skip(browserName !== 'chromium');
|
test.skip(browserName !== 'chromium');
|
||||||
}, async ({ runCLI }) => {
|
}, async ({ runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--device=Pixel 2', '--target=java', emptyHTML]);
|
const cli = runCLI(['--device=Pixel 2', '--target=java', emptyHTML]);
|
||||||
const expectedResult = `BrowserContext context = browser.newContext(new Browser.NewContextOptions()
|
const expectedResult = `BrowserContext context = browser.newContext(new Browser.NewContextOptions()
|
||||||
.setUserAgent("Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3765.0 Mobile Safari/537.36")
|
.setUserAgent("Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3765.0 Mobile Safari/537.36")
|
||||||
.setViewportSize(411, 731)
|
.setViewportSize(411, 731)
|
||||||
|
|
@ -62,7 +65,7 @@ it('should print the correct context options when using a device', (test, { brow
|
||||||
it('should print the correct context options when using a device and additional options', (test, { browserName }) => {
|
it('should print the correct context options when using a device and additional options', (test, { browserName }) => {
|
||||||
test.skip(browserName !== 'webkit');
|
test.skip(browserName !== 'webkit');
|
||||||
}, async ({ runCLI }) => {
|
}, async ({ runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--color-scheme=light', '--device=iPhone 11', '--target=java', emptyHTML]);
|
const cli = runCLI(['--color-scheme=light', '--device=iPhone 11', '--target=java', emptyHTML]);
|
||||||
const expectedResult = `BrowserContext context = browser.newContext(new Browser.NewContextOptions()
|
const expectedResult = `BrowserContext context = browser.newContext(new Browser.NewContextOptions()
|
||||||
.setColorScheme(ColorScheme.LIGHT)
|
.setColorScheme(ColorScheme.LIGHT)
|
||||||
.setUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Mobile/15E148 Safari/604.1")
|
.setUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Mobile/15E148 Safari/604.1")
|
||||||
|
|
@ -78,7 +81,7 @@ it('should print load/save storage_state', async ({ runCLI, browserName, testInf
|
||||||
const loadFileName = testInfo.outputPath('load.json');
|
const loadFileName = testInfo.outputPath('load.json');
|
||||||
const saveFileName = testInfo.outputPath('save.json');
|
const saveFileName = testInfo.outputPath('save.json');
|
||||||
await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8');
|
await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8');
|
||||||
const cli = runCLI(['codegen', `--load-storage=${loadFileName}`, `--save-storage=${saveFileName}`, '--target=java', emptyHTML]);
|
const cli = runCLI([`--load-storage=${loadFileName}`, `--save-storage=${saveFileName}`, '--target=java', emptyHTML]);
|
||||||
const expectedResult1 = `BrowserContext context = browser.newContext(new Browser.NewContextOptions()
|
const expectedResult1 = `BrowserContext context = browser.newContext(new Browser.NewContextOptions()
|
||||||
.setStorageStatePath(Paths.get("${loadFileName}")));`;
|
.setStorageStatePath(Paths.get("${loadFileName}")));`;
|
||||||
await cli.waitFor(expectedResult1);
|
await cli.waitFor(expectedResult1);
|
||||||
|
|
|
||||||
|
|
@ -22,26 +22,30 @@ const { it, expect } = folio;
|
||||||
|
|
||||||
const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
|
const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
|
||||||
|
|
||||||
it('should print the correct imports and context options', async ({ browserName, runCLI }) => {
|
const launchOptions = (channel: string) => {
|
||||||
const cli = runCLI(['codegen', emptyHTML]);
|
return channel ? `headless: false,\n channel: '${channel}'` : 'headless: false';
|
||||||
|
};
|
||||||
|
|
||||||
|
it('should print the correct imports and context options', async ({ browserName, browserChannel, runCLI }) => {
|
||||||
|
const cli = runCLI([emptyHTML]);
|
||||||
const expectedResult = `const { ${browserName} } = require('playwright');
|
const expectedResult = `const { ${browserName} } = require('playwright');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const browser = await ${browserName}.launch({
|
const browser = await ${browserName}.launch({
|
||||||
headless: false
|
${launchOptions(browserChannel)}
|
||||||
});
|
});
|
||||||
const context = await browser.newContext();`;
|
const context = await browser.newContext();`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print the correct context options for custom settings', async ({ browserName, runCLI }) => {
|
it('should print the correct context options for custom settings', async ({ browserName, browserChannel, runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--color-scheme=light', emptyHTML]);
|
const cli = runCLI(['--color-scheme=light', emptyHTML]);
|
||||||
const expectedResult = `const { ${browserName} } = require('playwright');
|
const expectedResult = `const { ${browserName} } = require('playwright');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const browser = await ${browserName}.launch({
|
const browser = await ${browserName}.launch({
|
||||||
headless: false
|
${launchOptions(browserChannel)}
|
||||||
});
|
});
|
||||||
const context = await browser.newContext({
|
const context = await browser.newContext({
|
||||||
colorScheme: 'light'
|
colorScheme: 'light'
|
||||||
|
|
@ -51,15 +55,15 @@ it('should print the correct context options for custom settings', async ({ brow
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should print the correct context options when using a device', (test, { browserName }) => {
|
it('should print the correct context options when using a device', (test, { browserName, browserChannel }) => {
|
||||||
test.skip(browserName !== 'chromium');
|
test.skip(browserName !== 'chromium');
|
||||||
}, async ({ runCLI }) => {
|
}, async ({ browserChannel, runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--device=Pixel 2', emptyHTML]);
|
const cli = runCLI(['--device=Pixel 2', emptyHTML]);
|
||||||
const expectedResult = `const { chromium, devices } = require('playwright');
|
const expectedResult = `const { chromium, devices } = require('playwright');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const browser = await chromium.launch({
|
const browser = await chromium.launch({
|
||||||
headless: false
|
${launchOptions(browserChannel)}
|
||||||
});
|
});
|
||||||
const context = await browser.newContext({
|
const context = await browser.newContext({
|
||||||
...devices['Pixel 2'],
|
...devices['Pixel 2'],
|
||||||
|
|
@ -70,13 +74,13 @@ it('should print the correct context options when using a device', (test, { brow
|
||||||
|
|
||||||
it('should print the correct context options when using a device and additional options', (test, { browserName }) => {
|
it('should print the correct context options when using a device and additional options', (test, { browserName }) => {
|
||||||
test.skip(browserName !== 'webkit');
|
test.skip(browserName !== 'webkit');
|
||||||
}, async ({ runCLI }) => {
|
}, async ({ browserChannel, runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--color-scheme=light', '--device=iPhone 11', emptyHTML]);
|
const cli = runCLI(['--color-scheme=light', '--device=iPhone 11', emptyHTML]);
|
||||||
const expectedResult = `const { webkit, devices } = require('playwright');
|
const expectedResult = `const { webkit, devices } = require('playwright');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const browser = await webkit.launch({
|
const browser = await webkit.launch({
|
||||||
headless: false
|
${launchOptions(browserChannel)}
|
||||||
});
|
});
|
||||||
const context = await browser.newContext({
|
const context = await browser.newContext({
|
||||||
...devices['iPhone 11'],
|
...devices['iPhone 11'],
|
||||||
|
|
@ -86,16 +90,16 @@ it('should print the correct context options when using a device and additional
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should save the codegen output to a file if specified', async ({ browserName, runCLI, testInfo }) => {
|
it('should save the codegen output to a file if specified', async ({ browserName, browserChannel, runCLI, testInfo }) => {
|
||||||
const tmpFile = testInfo.outputPath('script.js');
|
const tmpFile = testInfo.outputPath('script.js');
|
||||||
const cli = runCLI(['codegen', '--output', tmpFile, emptyHTML]);
|
const cli = runCLI(['--output', tmpFile, emptyHTML]);
|
||||||
await cli.exited;
|
await cli.exited;
|
||||||
const content = fs.readFileSync(tmpFile);
|
const content = fs.readFileSync(tmpFile);
|
||||||
expect(content.toString()).toBe(`const { ${browserName} } = require('playwright');
|
expect(content.toString()).toBe(`const { ${browserName} } = require('playwright');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const browser = await ${browserName}.launch({
|
const browser = await ${browserName}.launch({
|
||||||
headless: false
|
${launchOptions(browserChannel)}
|
||||||
});
|
});
|
||||||
const context = await browser.newContext();
|
const context = await browser.newContext();
|
||||||
|
|
||||||
|
|
@ -114,16 +118,16 @@ it('should save the codegen output to a file if specified', async ({ browserName
|
||||||
})();`);
|
})();`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print load/save storageState', async ({ browserName, runCLI, testInfo }) => {
|
it('should print load/save storageState', async ({ browserName, browserChannel, runCLI, testInfo }) => {
|
||||||
const loadFileName = testInfo.outputPath('load.json');
|
const loadFileName = testInfo.outputPath('load.json');
|
||||||
const saveFileName = testInfo.outputPath('save.json');
|
const saveFileName = testInfo.outputPath('save.json');
|
||||||
await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8');
|
await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8');
|
||||||
const cli = runCLI(['codegen', `--load-storage=${loadFileName}`, `--save-storage=${saveFileName}`, emptyHTML]);
|
const cli = runCLI([`--load-storage=${loadFileName}`, `--save-storage=${saveFileName}`, emptyHTML]);
|
||||||
const expectedResult1 = `const { ${browserName} } = require('playwright');
|
const expectedResult1 = `const { ${browserName} } = require('playwright');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const browser = await ${browserName}.launch({
|
const browser = await ${browserName}.launch({
|
||||||
headless: false
|
${launchOptions(browserChannel)}
|
||||||
});
|
});
|
||||||
const context = await browser.newContext({
|
const context = await browser.newContext({
|
||||||
storageState: '${loadFileName}'
|
storageState: '${loadFileName}'
|
||||||
|
|
|
||||||
|
|
@ -21,26 +21,29 @@ import { folio } from './cli.fixtures';
|
||||||
const { it, expect } = folio;
|
const { it, expect } = folio;
|
||||||
|
|
||||||
const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
|
const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
|
||||||
|
const launchOptions = (channel: string) => {
|
||||||
|
return channel ? `headless=False, channel="${channel}"` : 'headless=False';
|
||||||
|
};
|
||||||
|
|
||||||
it('should print the correct imports and context options', async ({ browserName, runCLI }) => {
|
it('should print the correct imports and context options', async ({ browserName, browserChannel, runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--target=python-async', emptyHTML]);
|
const cli = runCLI(['--target=python-async', emptyHTML]);
|
||||||
const expectedResult = `import asyncio
|
const expectedResult = `import asyncio
|
||||||
from playwright.async_api import async_playwright
|
from playwright.async_api import async_playwright
|
||||||
|
|
||||||
async def run(playwright):
|
async def run(playwright):
|
||||||
browser = await playwright.${browserName}.launch(headless=False)
|
browser = await playwright.${browserName}.launch(${launchOptions(browserChannel)})
|
||||||
context = await browser.new_context()`;
|
context = await browser.new_context()`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print the correct context options for custom settings', async ({ browserName, runCLI }) => {
|
it('should print the correct context options for custom settings', async ({ browserName, browserChannel, runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--color-scheme=light', '--target=python-async', emptyHTML]);
|
const cli = runCLI(['--color-scheme=light', '--target=python-async', emptyHTML]);
|
||||||
const expectedResult = `import asyncio
|
const expectedResult = `import asyncio
|
||||||
from playwright.async_api import async_playwright
|
from playwright.async_api import async_playwright
|
||||||
|
|
||||||
async def run(playwright):
|
async def run(playwright):
|
||||||
browser = await playwright.${browserName}.launch(headless=False)
|
browser = await playwright.${browserName}.launch(${launchOptions(browserChannel)})
|
||||||
context = await browser.new_context(color_scheme="light")`;
|
context = await browser.new_context(color_scheme="light")`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
|
|
@ -48,13 +51,13 @@ async def run(playwright):
|
||||||
|
|
||||||
it('should print the correct context options when using a device', (test, { browserName }) => {
|
it('should print the correct context options when using a device', (test, { browserName }) => {
|
||||||
test.skip(browserName !== 'chromium');
|
test.skip(browserName !== 'chromium');
|
||||||
}, async ({ runCLI }) => {
|
}, async ({ browserChannel, runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--device=Pixel 2', '--target=python-async', emptyHTML]);
|
const cli = runCLI(['--device=Pixel 2', '--target=python-async', emptyHTML]);
|
||||||
const expectedResult = `import asyncio
|
const expectedResult = `import asyncio
|
||||||
from playwright.async_api import async_playwright
|
from playwright.async_api import async_playwright
|
||||||
|
|
||||||
async def run(playwright):
|
async def run(playwright):
|
||||||
browser = await playwright.chromium.launch(headless=False)
|
browser = await playwright.chromium.launch(${launchOptions(browserChannel)})
|
||||||
context = await browser.new_context(**playwright.devices["Pixel 2"])`;
|
context = await browser.new_context(**playwright.devices["Pixel 2"])`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
|
|
@ -62,28 +65,28 @@ async def run(playwright):
|
||||||
|
|
||||||
it('should print the correct context options when using a device and additional options', (test, { browserName }) => {
|
it('should print the correct context options when using a device and additional options', (test, { browserName }) => {
|
||||||
test.skip(browserName !== 'webkit');
|
test.skip(browserName !== 'webkit');
|
||||||
}, async ({ runCLI }) => {
|
}, async ({ browserChannel, runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--color-scheme=light', '--device=iPhone 11', '--target=python-async', emptyHTML]);
|
const cli = runCLI(['--color-scheme=light', '--device=iPhone 11', '--target=python-async', emptyHTML]);
|
||||||
const expectedResult = `import asyncio
|
const expectedResult = `import asyncio
|
||||||
from playwright.async_api import async_playwright
|
from playwright.async_api import async_playwright
|
||||||
|
|
||||||
async def run(playwright):
|
async def run(playwright):
|
||||||
browser = await playwright.webkit.launch(headless=False)
|
browser = await playwright.webkit.launch(${launchOptions(browserChannel)})
|
||||||
context = await browser.new_context(**playwright.devices["iPhone 11"], color_scheme="light")`;
|
context = await browser.new_context(**playwright.devices["iPhone 11"], color_scheme="light")`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should save the codegen output to a file if specified', async ({ browserName, runCLI, testInfo }) => {
|
it('should save the codegen output to a file if specified', async ({ browserName, browserChannel, runCLI, testInfo }) => {
|
||||||
const tmpFile = testInfo.outputPath('script.js');
|
const tmpFile = testInfo.outputPath('script.js');
|
||||||
const cli = runCLI(['codegen', '--target=python-async', '--output', tmpFile, emptyHTML]);
|
const cli = runCLI(['--target=python-async', '--output', tmpFile, emptyHTML]);
|
||||||
await cli.exited;
|
await cli.exited;
|
||||||
const content = await fs.readFileSync(tmpFile);
|
const content = await fs.readFileSync(tmpFile);
|
||||||
expect(content.toString()).toBe(`import asyncio
|
expect(content.toString()).toBe(`import asyncio
|
||||||
from playwright.async_api import async_playwright
|
from playwright.async_api import async_playwright
|
||||||
|
|
||||||
async def run(playwright):
|
async def run(playwright):
|
||||||
browser = await playwright.${browserName}.launch(headless=False)
|
browser = await playwright.${browserName}.launch(${launchOptions(browserChannel)})
|
||||||
context = await browser.new_context()
|
context = await browser.new_context()
|
||||||
|
|
||||||
# Open new page
|
# Open new page
|
||||||
|
|
@ -105,16 +108,16 @@ async def main():
|
||||||
asyncio.run(main())`);
|
asyncio.run(main())`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print load/save storage_state', async ({ browserName, runCLI, testInfo }) => {
|
it('should print load/save storage_state', async ({ browserName, browserChannel, runCLI, testInfo }) => {
|
||||||
const loadFileName = testInfo.outputPath('load.json');
|
const loadFileName = testInfo.outputPath('load.json');
|
||||||
const saveFileName = testInfo.outputPath('save.json');
|
const saveFileName = testInfo.outputPath('save.json');
|
||||||
await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8');
|
await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8');
|
||||||
const cli = runCLI(['codegen', `--load-storage=${loadFileName}`, `--save-storage=${saveFileName}`, '--target=python-async', emptyHTML]);
|
const cli = runCLI([`--load-storage=${loadFileName}`, `--save-storage=${saveFileName}`, '--target=python-async', emptyHTML]);
|
||||||
const expectedResult1 = `import asyncio
|
const expectedResult1 = `import asyncio
|
||||||
from playwright.async_api import async_playwright
|
from playwright.async_api import async_playwright
|
||||||
|
|
||||||
async def run(playwright):
|
async def run(playwright):
|
||||||
browser = await playwright.${browserName}.launch(headless=False)
|
browser = await playwright.${browserName}.launch(${launchOptions(browserChannel)})
|
||||||
context = await browser.new_context(storage_state="${loadFileName}")`;
|
context = await browser.new_context(storage_state="${loadFileName}")`;
|
||||||
await cli.waitFor(expectedResult1);
|
await cli.waitFor(expectedResult1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,24 +21,27 @@ import { folio } from './cli.fixtures';
|
||||||
const { it, expect } = folio;
|
const { it, expect } = folio;
|
||||||
|
|
||||||
const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
|
const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
|
||||||
|
const launchOptions = (channel: string) => {
|
||||||
|
return channel ? `headless=False, channel="${channel}"` : 'headless=False';
|
||||||
|
};
|
||||||
|
|
||||||
it('should print the correct imports and context options', async ({ runCLI, browserName }) => {
|
it('should print the correct imports and context options', async ({ runCLI, browserChannel, browserName }) => {
|
||||||
const cli = runCLI(['codegen', '--target=python', emptyHTML]);
|
const cli = runCLI(['--target=python', emptyHTML]);
|
||||||
const expectedResult = `from playwright.sync_api import sync_playwright
|
const expectedResult = `from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
def run(playwright):
|
def run(playwright):
|
||||||
browser = playwright.${browserName}.launch(headless=False)
|
browser = playwright.${browserName}.launch(${launchOptions(browserChannel)})
|
||||||
context = browser.new_context()`;
|
context = browser.new_context()`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print the correct context options for custom settings', async ({ runCLI, browserName }) => {
|
it('should print the correct context options for custom settings', async ({ runCLI, browserChannel, browserName }) => {
|
||||||
const cli = runCLI(['codegen', '--color-scheme=light', '--target=python', emptyHTML]);
|
const cli = runCLI(['--color-scheme=light', '--target=python', emptyHTML]);
|
||||||
const expectedResult = `from playwright.sync_api import sync_playwright
|
const expectedResult = `from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
def run(playwright):
|
def run(playwright):
|
||||||
browser = playwright.${browserName}.launch(headless=False)
|
browser = playwright.${browserName}.launch(${launchOptions(browserChannel)})
|
||||||
context = browser.new_context(color_scheme="light")`;
|
context = browser.new_context(color_scheme="light")`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
|
|
@ -46,12 +49,12 @@ def run(playwright):
|
||||||
|
|
||||||
it('should print the correct context options when using a device', (test, { browserName }) => {
|
it('should print the correct context options when using a device', (test, { browserName }) => {
|
||||||
test.skip(browserName !== 'chromium');
|
test.skip(browserName !== 'chromium');
|
||||||
}, async ({ runCLI }) => {
|
}, async ({ browserChannel, runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--device=Pixel 2', '--target=python', emptyHTML]);
|
const cli = runCLI(['--device=Pixel 2', '--target=python', emptyHTML]);
|
||||||
const expectedResult = `from playwright.sync_api import sync_playwright
|
const expectedResult = `from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
def run(playwright):
|
def run(playwright):
|
||||||
browser = playwright.chromium.launch(headless=False)
|
browser = playwright.chromium.launch(${launchOptions(browserChannel)})
|
||||||
context = browser.new_context(**playwright.devices["Pixel 2"])`;
|
context = browser.new_context(**playwright.devices["Pixel 2"])`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
|
|
@ -59,26 +62,26 @@ def run(playwright):
|
||||||
|
|
||||||
it('should print the correct context options when using a device and additional options', (test, { browserName }) => {
|
it('should print the correct context options when using a device and additional options', (test, { browserName }) => {
|
||||||
test.skip(browserName !== 'webkit');
|
test.skip(browserName !== 'webkit');
|
||||||
}, async ({ runCLI }) => {
|
}, async ({ browserChannel, runCLI }) => {
|
||||||
const cli = runCLI(['codegen', '--color-scheme=light', '--device=iPhone 11', '--target=python', emptyHTML]);
|
const cli = runCLI(['--color-scheme=light', '--device=iPhone 11', '--target=python', emptyHTML]);
|
||||||
const expectedResult = `from playwright.sync_api import sync_playwright
|
const expectedResult = `from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
def run(playwright):
|
def run(playwright):
|
||||||
browser = playwright.webkit.launch(headless=False)
|
browser = playwright.webkit.launch(${launchOptions(browserChannel)})
|
||||||
context = browser.new_context(**playwright.devices["iPhone 11"], color_scheme="light")`;
|
context = browser.new_context(**playwright.devices["iPhone 11"], color_scheme="light")`;
|
||||||
await cli.waitFor(expectedResult);
|
await cli.waitFor(expectedResult);
|
||||||
expect(cli.text()).toContain(expectedResult);
|
expect(cli.text()).toContain(expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should save the codegen output to a file if specified', async ({ runCLI, browserName, testInfo }) => {
|
it('should save the codegen output to a file if specified', async ({ runCLI, browserChannel, browserName, testInfo }) => {
|
||||||
const tmpFile = testInfo.outputPath('script.js');
|
const tmpFile = testInfo.outputPath('script.js');
|
||||||
const cli = runCLI(['codegen', '--target=python', '--output', tmpFile, emptyHTML]);
|
const cli = runCLI(['--target=python', '--output', tmpFile, emptyHTML]);
|
||||||
await cli.exited;
|
await cli.exited;
|
||||||
const content = fs.readFileSync(tmpFile);
|
const content = fs.readFileSync(tmpFile);
|
||||||
expect(content.toString()).toBe(`from playwright.sync_api import sync_playwright
|
expect(content.toString()).toBe(`from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
def run(playwright):
|
def run(playwright):
|
||||||
browser = playwright.${browserName}.launch(headless=False)
|
browser = playwright.${browserName}.launch(${launchOptions(browserChannel)})
|
||||||
context = browser.new_context()
|
context = browser.new_context()
|
||||||
|
|
||||||
# Open new page
|
# Open new page
|
||||||
|
|
@ -98,15 +101,15 @@ with sync_playwright() as playwright:
|
||||||
run(playwright)`);
|
run(playwright)`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print load/save storage_state', async ({ runCLI, browserName, testInfo }) => {
|
it('should print load/save storage_state', async ({ runCLI, browserChannel, browserName, testInfo }) => {
|
||||||
const loadFileName = testInfo.outputPath('load.json');
|
const loadFileName = testInfo.outputPath('load.json');
|
||||||
const saveFileName = testInfo.outputPath('save.json');
|
const saveFileName = testInfo.outputPath('save.json');
|
||||||
await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8');
|
await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8');
|
||||||
const cli = runCLI(['codegen', `--load-storage=${loadFileName}`, `--save-storage=${saveFileName}`, '--target=python', emptyHTML]);
|
const cli = runCLI([`--load-storage=${loadFileName}`, `--save-storage=${saveFileName}`, '--target=python', emptyHTML]);
|
||||||
const expectedResult1 = `from playwright.sync_api import sync_playwright
|
const expectedResult1 = `from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
def run(playwright):
|
def run(playwright):
|
||||||
browser = playwright.${browserName}.launch(headless=False)
|
browser = playwright.${browserName}.launch(${launchOptions(browserChannel)})
|
||||||
context = browser.new_context(storage_state="${loadFileName}")`;
|
context = browser.new_context(storage_state="${loadFileName}")`;
|
||||||
await cli.waitFor(expectedResult1);
|
await cli.waitFor(expectedResult1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,10 +149,10 @@ class Recorder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fixtures.runCLI.init(async ({ browserName, headful }, runTest) => {
|
fixtures.runCLI.init(async ({ browserName, browserChannel, headful }, runTest) => {
|
||||||
let cli: CLIMock;
|
let cli: CLIMock;
|
||||||
const cliFactory = (args: string[]) => {
|
const cliFactory = (args: string[]) => {
|
||||||
cli = new CLIMock(browserName, !headful, args);
|
cli = new CLIMock(browserName, browserChannel, !headful, args);
|
||||||
return cli;
|
return cli;
|
||||||
};
|
};
|
||||||
await runTest(cliFactory);
|
await runTest(cliFactory);
|
||||||
|
|
@ -166,13 +166,17 @@ class CLIMock {
|
||||||
private waitForCallback: () => void;
|
private waitForCallback: () => void;
|
||||||
exited: Promise<void>;
|
exited: Promise<void>;
|
||||||
|
|
||||||
constructor(browserName: string, headless: boolean, args: string[]) {
|
constructor(browserName: string, browserChannel: string, headless: boolean, args: string[]) {
|
||||||
this.data = '';
|
this.data = '';
|
||||||
this.process = spawn('node', [
|
const nodeArgs = [
|
||||||
path.join(__dirname, '..', '..', 'lib', 'cli', 'cli.js'),
|
path.join(__dirname, '..', '..', 'lib', 'cli', 'cli.js'),
|
||||||
|
'codegen',
|
||||||
...args,
|
...args,
|
||||||
`--browser=${browserName}`,
|
`--browser=${browserName}`,
|
||||||
], {
|
];
|
||||||
|
if (browserChannel)
|
||||||
|
nodeArgs.push(`--channel=${browserChannel}`);
|
||||||
|
this.process = spawn('node', nodeArgs, {
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
PWCLI_EXIT_FOR_TEST: '1',
|
PWCLI_EXIT_FOR_TEST: '1',
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ fixtures.downloadsBrowser.init(async ({ server, browserType, browserOptions, tes
|
||||||
await browser.close();
|
await browser.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
fixtures.persistentDownloadsContext.init(async ({ server, launchPersistent, testInfo }, test) => {
|
fixtures.persistentDownloadsContext.init(async ({ server, launchPersistent, testInfo, browserChannel }, test) => {
|
||||||
server.setRoute('/download', (req, res) => {
|
server.setRoute('/download', (req, res) => {
|
||||||
res.setHeader('Content-Type', 'application/octet-stream');
|
res.setHeader('Content-Type', 'application/octet-stream');
|
||||||
res.setHeader('Content-Disposition', 'attachment; filename=file.txt');
|
res.setHeader('Content-Disposition', 'attachment; filename=file.txt');
|
||||||
|
|
@ -49,7 +49,8 @@ fixtures.persistentDownloadsContext.init(async ({ server, launchPersistent, test
|
||||||
const { context, page } = await launchPersistent(
|
const { context, page } = await launchPersistent(
|
||||||
{
|
{
|
||||||
downloadsPath: testInfo.outputPath(''),
|
downloadsPath: testInfo.outputPath(''),
|
||||||
acceptDownloads: true
|
acceptDownloads: true,
|
||||||
|
channel: browserChannel,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
logOnCI('--- setting content for the page ---');
|
logOnCI('--- setting content for the page ---');
|
||||||
|
|
|
||||||
|
|
@ -80,21 +80,27 @@ describe('fixtures', (suite, { platform, headful }) => {
|
||||||
await connectedRemoteServer.childExitCode();
|
await connectedRemoteServer.childExitCode();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should close the browser on SIGINT', async ({connectedRemoteServer}) => {
|
it('should close the browser on SIGINT', (test, { browserChannel }) => {
|
||||||
|
test.fixme(!!browserChannel, 'Uncomment on roll');
|
||||||
|
}, async ({connectedRemoteServer}) => {
|
||||||
process.kill(connectedRemoteServer.child().pid, 'SIGINT');
|
process.kill(connectedRemoteServer.child().pid, 'SIGINT');
|
||||||
expect(await connectedRemoteServer.out('exitCode')).toBe('0');
|
expect(await connectedRemoteServer.out('exitCode')).toBe('0');
|
||||||
expect(await connectedRemoteServer.out('signal')).toBe('null');
|
expect(await connectedRemoteServer.out('signal')).toBe('null');
|
||||||
expect(await connectedRemoteServer.childExitCode()).toBe(130);
|
expect(await connectedRemoteServer.childExitCode()).toBe(130);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should close the browser on SIGTERM', async ({connectedRemoteServer}) => {
|
it('should close the browser on SIGTERM', (test, { browserChannel }) => {
|
||||||
|
test.fixme(!!browserChannel, 'Uncomment on roll');
|
||||||
|
}, async ({connectedRemoteServer}) => {
|
||||||
process.kill(connectedRemoteServer.child().pid, 'SIGTERM');
|
process.kill(connectedRemoteServer.child().pid, 'SIGTERM');
|
||||||
expect(await connectedRemoteServer.out('exitCode')).toBe('0');
|
expect(await connectedRemoteServer.out('exitCode')).toBe('0');
|
||||||
expect(await connectedRemoteServer.out('signal')).toBe('null');
|
expect(await connectedRemoteServer.out('signal')).toBe('null');
|
||||||
expect(await connectedRemoteServer.childExitCode()).toBe(0);
|
expect(await connectedRemoteServer.childExitCode()).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should close the browser on SIGHUP', async ({connectedRemoteServer}) => {
|
it('should close the browser on SIGHUP', (test, { browserChannel }) => {
|
||||||
|
test.fixme(!!browserChannel, 'Uncomment on roll');
|
||||||
|
}, async ({connectedRemoteServer}) => {
|
||||||
process.kill(connectedRemoteServer.child().pid, 'SIGHUP');
|
process.kill(connectedRemoteServer.child().pid, 'SIGHUP');
|
||||||
expect(await connectedRemoteServer.out('exitCode')).toBe('0');
|
expect(await connectedRemoteServer.out('exitCode')).toBe('0');
|
||||||
expect(await connectedRemoteServer.out('signal')).toBe('null');
|
expect(await connectedRemoteServer.out('signal')).toBe('null');
|
||||||
|
|
|
||||||
|
|
@ -87,12 +87,12 @@ fixtures.launchPersistent.init(async ({ createUserDataDir, browserOptions, brows
|
||||||
await context.close();
|
await context.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
fixtures.browserOptions.override(async ({ browserName, headful, slowMo }, run) => {
|
fixtures.browserOptions.override(async ({ browserName, headful, slowMo, browserChannel }, run) => {
|
||||||
const executablePath = getExecutablePath(browserName);
|
const executablePath = getExecutablePath(browserName);
|
||||||
if (executablePath)
|
if (executablePath)
|
||||||
console.error(`Using executable at ${executablePath}`);
|
console.error(`Using executable at ${executablePath}`);
|
||||||
await run({
|
await run({
|
||||||
channel: process.env.PW_CHROMIUM_CHANNEL,
|
channel: browserChannel,
|
||||||
executablePath,
|
executablePath,
|
||||||
handleSIGINT: false,
|
handleSIGINT: false,
|
||||||
slowMo,
|
slowMo,
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ config.timeout = 30000;
|
||||||
type PlaywrightParameters = {
|
type PlaywrightParameters = {
|
||||||
// Browser type name.
|
// Browser type name.
|
||||||
browserName: 'chromium' | 'firefox' | 'webkit';
|
browserName: 'chromium' | 'firefox' | 'webkit';
|
||||||
|
// Browser release channel, if applicable.
|
||||||
|
browserChannel: string | undefined;
|
||||||
// Whether to run tests headless or headful.
|
// Whether to run tests headless or headful.
|
||||||
headful: boolean;
|
headful: boolean;
|
||||||
// Operating system.
|
// Operating system.
|
||||||
|
|
@ -94,12 +96,14 @@ fixtures.platform.initParameter('Operating system', process.platform as ('win32'
|
||||||
fixtures.screenshotOnFailure.initParameter('Generate screenshot on failure', false);
|
fixtures.screenshotOnFailure.initParameter('Generate screenshot on failure', false);
|
||||||
fixtures.slowMo.initParameter('Slows down Playwright operations by the specified amount of milliseconds', 0);
|
fixtures.slowMo.initParameter('Slows down Playwright operations by the specified amount of milliseconds', 0);
|
||||||
fixtures.video.initParameter('Record videos while running tests', false);
|
fixtures.video.initParameter('Record videos while running tests', false);
|
||||||
|
fixtures.browserChannel.initParameter('Browser release channel', process.env.PW_CHROMIUM_CHANNEL);
|
||||||
|
|
||||||
fixtures.browserOptions.init(async ({ headful, slowMo }, run) => {
|
fixtures.browserOptions.init(async ({ headful, slowMo, browserChannel }, run) => {
|
||||||
await run({
|
await run({
|
||||||
handleSIGINT: false,
|
handleSIGINT: false,
|
||||||
slowMo,
|
slowMo,
|
||||||
headless: !headful,
|
headless: !headful,
|
||||||
|
channel: browserChannel,
|
||||||
});
|
});
|
||||||
}, { scope: 'worker' });
|
}, { scope: 'worker' });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,12 @@ export class RemoteServer {
|
||||||
this._didExit = false;
|
this._didExit = false;
|
||||||
|
|
||||||
this._browserType = browserType;
|
this._browserType = browserType;
|
||||||
const launchOptions = {...browserOptions,
|
const launchOptions = {
|
||||||
|
...browserOptions,
|
||||||
handleSIGINT: true,
|
handleSIGINT: true,
|
||||||
handleSIGTERM: true,
|
handleSIGTERM: true,
|
||||||
handleSIGHUP: true,
|
handleSIGHUP: true,
|
||||||
executablePath: browserOptions.executablePath || browserType.executablePath(),
|
executablePath: browserOptions.channel ? undefined : browserOptions.executablePath || browserType.executablePath(),
|
||||||
logger: undefined,
|
logger: undefined,
|
||||||
};
|
};
|
||||||
const options = {
|
const options = {
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ describe('screencast', suite => {
|
||||||
expect(videoPlayer.videoHeight).toBe(600);
|
expect(videoPlayer.videoHeight).toBe(600);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be 800x450 by default', async ({browser, testInfo}) => {
|
it('should be 800x450 by default', async ({ browser, testInfo }) => {
|
||||||
const context = await browser.newContext({
|
const context = await browser.newContext({
|
||||||
recordVideo: {
|
recordVideo: {
|
||||||
dir: testInfo.outputPath(''),
|
dir: testInfo.outputPath(''),
|
||||||
|
|
|
||||||
13
types/types.d.ts
vendored
13
types/types.d.ts
vendored
|
|
@ -6356,6 +6356,19 @@ export interface BrowserType<Browser> {
|
||||||
*/
|
*/
|
||||||
bypassCSP?: boolean;
|
bypassCSP?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chromium distribution channel, one of
|
||||||
|
* - chrome
|
||||||
|
* - chrome-beta
|
||||||
|
* - chrome-dev
|
||||||
|
* - chrome-canary
|
||||||
|
* - msedge
|
||||||
|
* - msedge-beta
|
||||||
|
* - msedge-dev
|
||||||
|
* - msedge-canary
|
||||||
|
*/
|
||||||
|
channel?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable Chromium sandboxing. Defaults to `true`.
|
* Enable Chromium sandboxing. Defaults to `true`.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue