Skip to content

Commit c4a78ec

Browse files
tianfeng92Alex Plischke
and
Alex Plischke
authored
[DEVX-1973] Support chrome (#181)
* [DEVX-1973] Support chrome * remove useChrome config * report chrome * run post release test on mac12 * update playwright version in post release test * refine playwright config * add comments for browser settings * Update src/sauce.config.js Co-authored-by: Alex Plischke <[email protected]> Co-authored-by: Alex Plischke <[email protected]>
1 parent f644733 commit c4a78ec

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

src/constants.js

+2
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ exports.LOG_FILES = [
1919
];
2020

2121
exports.DESIRED_BROWSER = process.env.BROWSER_NAME || 'chromium';
22+
23+
exports.DOCKER_CHROME_PATH = '/opt/google/chrome/google-chrome';

src/playwright-runner.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const utils = require('./utils');
77
const {createJobReport} = require('./reporter');
88
const {prepareNpmEnv, loadRunConfig, escapeXML, preExec} = require('sauce-testrunner-utils');
99
const {updateExportedValue} = require('sauce-testrunner-utils').saucectl;
10-
const {LOG_FILES} = require('./constants');
10+
const {LOG_FILES, DOCKER_CHROME_PATH} = require('./constants');
1111
const glob = require('glob');
1212
const convert = require('xml-js');
1313
const {runCucumber} = require('./cucumber-runner');
@@ -341,10 +341,18 @@ async function run(nodeBin, runCfgPath, suiteName) {
341341
}
342342

343343
async function runPlaywright(nodeBin, runCfg) {
344+
let excludeParams = ['screenshot-on-failure', 'video', 'slow-mo', 'headless', 'headed'];
345+
344346
process.env.BROWSER_NAME = runCfg.suite.param.browserName;
345347
process.env.HEADLESS = runCfg.suite.param.headless;
346348
process.env.SAUCE_SUITE_NAME = runCfg.suite.name;
347349
process.env.SAUCE_ARTIFACTS_DIRECTORY = runCfg.assetsDir;
350+
if (runCfg.suite.param.browserName === 'chrome') {
351+
excludeParams.push('browser');
352+
}
353+
if (!process.env.SAUCE_VM) {
354+
process.env.BROWSER_PATH = DOCKER_CHROME_PATH;
355+
}
348356

349357
if (runCfg.playwright.configFile) {
350358
const playwrightCfgFile = path.join(runCfg.projectPath, runCfg.playwright.configFile);
@@ -381,7 +389,6 @@ async function runPlaywright(nodeBin, runCfg) {
381389
}
382390
let args = _.defaultsDeep(defaultArgs, utils.replaceLegacyKeys(suite.param));
383391

384-
let excludeParams = ['screenshot-on-failure', 'video', 'slow-mo', 'headless', 'headed'];
385392

386393
// There is a conflict if the playwright project has a `browser` defined,
387394
// since the job is launched with the browser set by saucectl, which is now set as the job's metadata.

src/sauce.config.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ for (const file of configFiles) {
2727

2828
const overrides = {
2929
use: {
30-
browserName: process.env.BROWSER_NAME, // override browserName with suite browserName
3130
headless: process.env.SAUCE_VM ? process.env.HEADLESS === 'true' : true,
3231
video: process.env.SAUCE_VM ? 'off' : 'on',
32+
launchOptions: {},
3333
},
3434
reporter: [
3535
['list'],
@@ -47,6 +47,17 @@ const overrides = {
4747
testIgnore: process.env.TEST_IGNORE,
4848
};
4949

50+
if (process.env.BROWSER_NAME !== 'chrome') {
51+
// chromium, firefox and webkit come pre-packaged with playwright.
52+
// So we can just pass those browser values to playwright and
53+
// it knows what to do and where to pick them up.
54+
overrides.use.browserName = process.env.BROWSER_NAME; // override browserName with suite browserName
55+
} else {
56+
// Google chrome is provided by the sauce VM (or docker image). So we have to let playwright know where to look.
57+
overrides.use.channel = 'chrome';
58+
overrides.use.launchOptions.executablePath = process.env.BROWSER_PATH;
59+
}
60+
5061
if ('HTTP_PROXY' in process.env && process.env.HTTP_PROXY !== '') {
5162
const proxy = {
5263
server: process.env.HTTP_PROXY,

tests/fixtures/post-release/.sauce/config_mac.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ rootDir: .
1010
playwright:
1111
# CAUTION: This has to be an already deployed framework version in the cloud. Not necessarily the one you want to test.
1212
# Then use --runner-version to specify the release you actually want to use.
13-
version: 1.18.1
13+
version: 1.27.1
1414
suites:
1515
- name: "Post Release Test (macOS) - chromium"
16-
platformName: "macOS 11.00"
16+
platformName: "macOS 12"
1717
testMatch: ['.*.js']
1818
params:
1919
browserName: "chromium"
2020

2121
- name: "Post Release Test (macOS) - webkit"
22-
platformName: "macOS 11.00"
22+
platformName: "macOS 12"
2323
testMatch: ['.*.js']
2424
params:
2525
browserName: "webkit"
2626

2727
- name: "Post Release Test (macOS) - firefox"
28-
platformName: "macOS 11.00"
28+
platformName: "macOS 12"
2929
testMatch: ['.*.js']
3030
params:
3131
browserName: "firefox"

tests/fixtures/post-release/.sauce/config_win.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ rootDir: .
1010
playwright:
1111
# CAUTION: This has to be an already deployed framework version in the cloud. Not necessarily the one you want to test.
1212
# Then use --runner-version to specify the release you actually want to use.
13-
version: 1.18.1
13+
version: 1.27.1
1414
suites:
1515
- name: "Post Release Test (Windows) - chromium"
1616
platformName: "Windows 10"

0 commit comments

Comments
 (0)