Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat: support msedge-beta channel (#7442)

Andrey Lushnikovec8d0629f344
diff --git a/.github/workflows/tests_secondary.yml b/.github/workflows/tests_secondary.yml
index 6714bf3d84..b4a8f5d259 100644
--- a/.github/workflows/tests_secondary.yml
+++ b/.github/workflows/tests_secondary.yml
@@ -381,6 +381,77 @@ jobs:
name: edge-stable-win-test-results
path: test-results
+ edge_beta_mac:
+ name: "Edge Beta (Mac)"
+ runs-on: macos-10.15
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v2
+ with:
+ node-version: 12
+ - run: npm ci
+ env:
+ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
+ - run: npm run build
+ - run: node lib/cli/cli install msedge-beta
+ - run: npm run ctest
+ env:
+ PWTEST_CHANNEL: msedge-beta
+ - run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
+ if: always()
+ - uses: actions/upload-artifact@v1
+ if: ${{ always() }}
+ with:
+ name: msedge-beta-mac-test-results
+ path: test-results
+
+ edge_beta_win:
+ name: "Edge Beta (Win)"
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v2
+ with:
+ node-version: 12
+ - run: npm ci
+ env:
+ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
+ - run: npm run build
+ - run: node lib/cli/cli install msedge-beta
+ - run: npm run ctest
+ shell: bash
+ env:
+ PWTEST_CHANNEL: msedge-beta
+ - uses: actions/upload-artifact@v1
+ if: ${{ always() }}
+ with:
+ name: edge-beta-win-test-results
+ path: test-results
+
+ edge_beta_linux:
+ name: "Edge Beta (Linux)"
+ runs-on: ubuntu-20.04
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v2
+ with:
+ node-version: 12
+ - run: npm ci
+ env:
+ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
+ - run: npm run build
+ - run: node lib/cli/cli install msedge-beta
+ - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest
+ env:
+ PWTEST_CHANNEL: msedge-beta
+ - run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
+ if: always()
+ - uses: actions/upload-artifact@v1
+ if: ${{ always() }}
+ with:
+ name: edge-beta-linux-test-results
+ path: test-results
+
chrome_beta_linux:
name: "Chrome Beta (Linux)"
runs-on: ubuntu-20.04
diff --git a/bin/reinstall_chrome_beta_linux.sh b/bin/reinstall_chrome_beta_linux.sh
index 8a0a6876d7..afb9d87b56 100755
--- a/bin/reinstall_chrome_beta_linux.sh
+++ b/bin/reinstall_chrome_beta_linux.sh
@@ -2,15 +2,22 @@
set -e
set -x
+is_user_root () { [ "${EUID:-$(id -u)}" -eq 0 ]; }
+if is_user_root; then
+ maybesudo=""
+else
+ maybesudo="sudo"
+fi
+
# 1. make sure to remove old beta if any.
if dpkg --get-selections | grep -q "^google-chrome-beta[[:space:]]*install$" >/dev/null; then
- sudo apt-get remove -y google-chrome-beta
+ $maybesudo apt-get remove -y google-chrome-beta
fi
# 2. download chrome beta from dl.google.com and install it.
cd /tmp
wget https://dl.google.com/linux/direct/google-chrome-beta_current_amd64.deb
-sudo apt-get install -y ./google-chrome-beta_current_amd64.deb
+$maybesudo apt-get install -y ./google-chrome-beta_current_amd64.deb
rm -rf ./google-chrome-beta_current_amd64.deb
cd -
google-chrome-beta --version
diff --git a/bin/reinstall_chrome_stable_linux.sh b/bin/reinstall_chrome_stable_linux.sh
index 8c16080920..c5078f6403 100755
--- a/bin/reinstall_chrome_stable_linux.sh
+++ b/bin/reinstall_chrome_stable_linux.sh
@@ -2,16 +2,24 @@
set -e
set -x
+is_user_root () { [ "${EUID:-$(id -u)}" -eq 0 ]; }
+if is_user_root; then
+ maybesudo=""
+else
+ maybesudo="sudo"
+fi
+
+
# 1. make sure to remove old stable if any.
if dpkg --get-selections | grep -q "^google-chrome[[:space:]]*install$" >/dev/null; then
- sudo apt-get remove -y google-chrome
+ $maybesudo apt-get remove -y google-chrome
fi
# 2. download chrome stable from dl.google.com and install it.
cd /tmp
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
-sudo apt-get install -y ./google-chrome-stable_current_amd64.deb
+$maybesudo apt-get install -y ./google-chrome-stable_current_amd64.deb
rm -rf ./google-chrome-stable_current_amd64.deb
cd -
google-chrome --version
diff --git a/bin/reinstall_msedge_beta_linux.sh b/bin/reinstall_msedge_beta_linux.sh
new file mode 100755
index 0000000000..dab12e346f
--- /dev/null
+++ b/bin/reinstall_msedge_beta_linux.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -e
+set -x
+
+is_user_root () { [ "${EUID:-$(id -u)}" -eq 0 ]; }
+if is_user_root; then
+ maybesudo=""
+else
+ maybesudo="sudo"
+fi
+
+if dpkg --get-selections | grep -q "^microsoft-edge-beta[[:space:]]*install$" >/dev/null; then
+ $maybesudo apt-get remove -y microsoft-edge-beta
+fi
+
+curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/microsoft.gpg
+$maybesudo install -o root -g root -m 644 /tmp/microsoft.gpg /etc/apt/trusted.gpg.d/
+$maybesudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
+rm /tmp/microsoft.gpg
+$maybesudo apt-get update && $maybesudo apt-get install -y microsoft-edge-beta
+
+microsoft-edge-beta --version
diff --git a/bin/reinstall_msedge_beta_mac.sh b/bin/reinstall_msedge_beta_mac.sh
new file mode 100755
index 0000000000..fce4b6925a
--- /dev/null
+++ b/bin/reinstall_msedge_beta_mac.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+set -e
+set -x
+
+cd /tmp
+curl -o ./msedge_beta.pkg -k "$1"
+# Note: there's no way to uninstall previously installed MSEdge.
+# However, running PKG again seems to update installation.
+sudo installer -pkg /tmp/msedge_beta.pkg -target /
+rm -rf /tmp/msedge_beta.pkg
+/Applications/Microsoft\ Edge\ Beta.app/Contents/MacOS/Microsoft\ Edge\ Beta --version
diff --git a/bin/reinstall_msedge_beta_win.ps1 b/bin/reinstall_msedge_beta_win.ps1
new file mode 100644
index 0000000000..b7498688b3
--- /dev/null
+++ b/bin/reinstall_msedge_beta_win.ps1
@@ -0,0 +1,21 @@
+$url = $args[0]
+
+Write-Host "Downloading Microsoft Edge Beta"
+$wc = New-Object net.webclient
+$msiInstaller = "$env:temp\microsoft-edge-beta.msi"
+$wc.Downloadfile($url, $msiInstaller)
+
+Write-Host "Installing Microsoft Edge Beta"
+$arguments = "/i `"$msiInstaller`" /quiet"
+Start-Process msiexec.exe -ArgumentList $arguments -Wait
+Remove-Item $msiInstaller
+
+$suffix = "\\Microsoft\\Edge\\Application\\msedge.exe"
+if (Test-Path "${env:ProgramFiles(x86)}$suffix") {
+ (Get-Item "${env:ProgramFiles(x86)}$suffix").VersionInfo
+} elseif (Test-Path "${env:ProgramFiles}$suffix") {
+ (Get-Item "${env:ProgramFiles}$suffix").VersionInfo
+} else {
+ write-host "ERROR: failed to install Microsoft Edge"
+ exit 1
+}
diff --git a/src/cli/cli.ts b/src/cli/cli.ts
index cf8cc65758..0dcae0d23b 100755
--- a/src/cli/cli.ts
+++ b/src/cli/cli.ts
@@ -37,15 +37,17 @@ import * as utils from '../utils/utils';
const SCRIPTS_DIRECTORY = path.join(__dirname, '..', '..', 'bin');
-type BrowserChannel = 'chrome-beta'|'chrome'|'msedge';
-const allBrowserChannels: Set<BrowserChannel> = new Set(['chrome-beta', 'chrome', 'msedge']);
+type BrowserChannel = 'chrome-beta'|'chrome'|'msedge'|'msedge-beta';
+const allBrowserChannels: Set<BrowserChannel> = new Set(['chrome-beta', 'chrome', 'msedge', 'msedge-beta']);
const suggestedBrowsersToInstall = ['chromium', 'webkit', 'firefox', ...allBrowserChannels].map(name => `'${name}'`).join(', ');
+
const packageJSON = require('../../package.json');
const ChannelName = {
'chrome-beta': 'Google Chrome Beta',
'chrome': 'Google Chrome',
'msedge': 'Microsoft Edge',
+ 'msedge-beta': 'Microsoft Edge Beta',
};
const InstallationScriptName = {
@@ -63,6 +65,11 @@ const InstallationScriptName = {
'darwin': 'reinstall_msedge_stable_mac.sh',
'win32': 'reinstall_msedge_stable_win.ps1',
},
+ 'msedge-beta': {
+ 'darwin': 'reinstall_msedge_beta_mac.sh',
+ 'linux': 'reinstall_msedge_beta_linux.sh',
+ 'win32': 'reinstall_msedge_beta_win.ps1',
+ },
};
program
@@ -129,7 +136,7 @@ program
console.log(`Invalid installation targets: ${faultyArguments.map(name => `'${name}'`).join(', ')}. Expecting one of: ${suggestedBrowsersToInstall}`);
process.exit(1);
}
- if (browserNames.has('chromium') || browserChannels.has('chrome-beta') || browserChannels.has('chrome') || browserChannels.has('msedge'))
+ if (browserNames.has('chromium') || browserChannels.has('chrome-beta') || browserChannels.has('chrome') || browserChannels.has('msedge') || browserChannels.has('msedge-beta'))
browserNames.add('ffmpeg');
if (browserNames.size)
await installBrowsers([...browserNames]);
@@ -156,21 +163,20 @@ async function installBrowserChannel(channel: BrowserChannel) {
throw new Error(`Cannot install ${ChannelName[channel]} on ${platform}`);
const scriptArgs = [];
- if (channel === 'msedge') {
+ if ((channel === 'msedge' || channel === 'msedge-beta') && platform !== 'linux') {
const products = JSON.parse(await utils.fetchData('https://edgeupdates.microsoft.com/api/products'));
- const stable = products.find((product: any) => product.Product === 'Stable');
- if (platform === 'win32') {
- const arch = os.arch() === 'x64' ? 'x64' : 'x86';
- const release = stable.Releases.find((release: any) => release.Platform === 'Windows' && release.Architecture === arch);
- const artifact = release.Artifacts.find((artifact: any) => artifact.ArtifactName === 'msi');
- scriptArgs.push(artifact.Location /* url */);
- } else if (platform === 'darwin') {
- const release = stable.Releases.find((release: any) => release.Platform === 'MacOS' && release.Architecture === 'universal');
- const artifact = release.Artifacts.find((artifact: any) => artifact.ArtifactName === 'pkg');
+ const productName = channel === 'msedge' ? 'Stable' : 'Beta';
+ const product = products.find((product: any) => product.Product === productName);
+ const searchConfig = ({
+ darwin: {platform: 'MacOS', arch: 'universal', artifact: 'pkg'},
+ win32: {platform: 'Windows', arch: os.arch() === 'x64' ? 'x64' : 'x86', artifact: 'msi'},
+ } as any)[platform];
+ const release = searchConfig ? product.Releases.find((release: any) => release.Platform === searchConfig.platform && release.Architecture === searchConfig.arch) : null;
+ const artifact = release ? release.Artifacts.find((artifact: any) => artifact.ArtifactName === searchConfig.artifact) : null;
+ if (artifact)
scriptArgs.push(artifact.Location /* url */);
- } else {
+ else
throw new Error(`Cannot install ${ChannelName[channel]} on ${platform}`);
- }
}
const shell = scriptName.endsWith('.ps1') ? 'powershell.exe' : 'bash';
diff --git a/src/server/chromium/findChromiumChannel.ts b/src/server/chromium/findChromiumChannel.ts
index ab73e016ce..47cba155f8 100644
--- a/src/server/chromium/findChromiumChannel.ts
+++ b/src/server/chromium/findChromiumChannel.ts
@@ -36,6 +36,7 @@ function linux(channel: string): string[] | undefined {
case 'chrome-beta': return ['/opt/google/chrome-beta/chrome'];
case 'chrome-dev': return ['/opt/google/chrome-unstable/chrome'];
case 'msedge-dev': return ['/opt/microsoft/msedge-dev/msedge'];
+ case 'msedge-beta': return ['/opt/microsoft/msedge-beta/msedge'];
}
}
diff --git a/tests/headful.spec.ts b/tests/headful.spec.ts
index d4cd5c0636..d2ea9dce5e 100644
--- a/tests/headful.spec.ts
+++ b/tests/headful.spec.ts
@@ -147,29 +147,3 @@ it('Page.bringToFront should work', async ({browserType, browserOptions}) => {
await browser.close();
});
-it('focused input should produce the same screenshot', async ({browserType, browserOptions, browserName, platform, channel}, testInfo) => {
- it.fail(channel === 'msedge' && platform === 'darwin', 'focus ring is black on MSEdge');
- it.fail(browserName === 'firefox' && platform === 'darwin', 'headless has thinner outline');
- it.fail(browserName === 'firefox' && platform === 'linux', 'headless has no outline');
- it.skip(browserName === 'webkit' && platform === 'linux', 'gtk vs wpe');
- it.skip(!!process.env.CRPATH);
-
- testInfo.snapshotSuffix = platform;
-
- const headful = await browserType.launch({...browserOptions, headless: false });
- const headfulPage = await headful.newPage();
- await headfulPage.setContent('<input>');
- await headfulPage.focus('input');
- const headfulScreenshot = await headfulPage.screenshot();
- await headful.close();
-
- const headless = await browserType.launch({...browserOptions, headless: true });
- const headlessPage = await headless.newPage();
- await headlessPage.setContent('<input>');
- await headlessPage.focus('input');
- const headlessScreenshot = await headlessPage.screenshot();
- await headless.close();
-
- expect(headfulScreenshot).toMatchSnapshot('focused-input.png');
- expect(headlessScreenshot).toMatchSnapshot('focused-input.png');
-});
diff --git a/tests/headful.spec.ts-snapshots/focused-input-chromium-darwin.png b/tests/headful.spec.ts-snapshots/focused-input-chromium-darwin.png
deleted file mode 100644
index 327fce8537..0000000000
Binary files a/tests/headful.spec.ts-snapshots/focused-input-chromium-darwin.png and /dev/null differ
diff --git a/tests/headful.spec.ts-snapshots/focused-input-chromium-linux.png b/tests/headful.spec.ts-snapshots/focused-input-chromium-linux.png
deleted file mode 100644
index ca5082b3bf..0000000000
Binary files a/tests/headful.spec.ts-snapshots/focused-input-chromium-linux.png and /dev/null differ
diff --git a/tests/headful.spec.ts-snapshots/focused-input-chromium-win32.png b/tests/headful.spec.ts-snapshots/focused-input-chromium-win32.png
deleted file mode 100644
index ca5082b3bf..0000000000
Binary files a/tests/headful.spec.ts-snapshots/focused-input-chromium-win32.png and /dev/null differ
diff --git a/tests/headful.spec.ts-snapshots/focused-input-firefox-darwin.png b/tests/headful.spec.ts-snapshots/focused-input-firefox-darwin.png
deleted file mode 100644
index ee6ca12b5c..0000000000
Binary files a/tests/headful.spec.ts-snapshots/focused-input-firefox-darwin.png and /dev/null differ
diff --git a/tests/headful.spec.ts-snapshots/focused-input-firefox-linux.png b/tests/headful.spec.ts-snapshots/focused-input-firefox-linux.png
deleted file mode 100644
index bcff3cba33..0000000000
Binary files a/tests/headful.spec.ts-snapshots/focused-input-firefox-linux.png and /dev/null differ
diff --git a/tests/headful.spec.ts-snapshots/focused-input-firefox-win32.png b/tests/headful.spec.ts-snapshots/focused-input-firefox-win32.png
deleted file mode 100644
index ff91c38231..0000000000
Binary files a/tests/headful.spec.ts-snapshots/focused-input-firefox-win32.png and /dev/null differ
diff --git a/tests/headful.spec.ts-snapshots/focused-input-webkit-darwin.png b/tests/headful.spec.ts-snapshots/focused-input-webkit-darwin.png
deleted file mode 100644
index 0526762bf9..0000000000
Binary files a/tests/headful.spec.ts-snapshots/focused-input-webkit-darwin.png and /dev/null differ
diff --git a/tests/headful.spec.ts-snapshots/focused-input-webkit-linux.png b/tests/headful.spec.ts-snapshots/focused-input-webkit-linux.png
deleted file mode 100644
index f76edad846..0000000000
Binary files a/tests/headful.spec.ts-snapshots/focused-input-webkit-linux.png and /dev/null differ
diff --git a/tests/headful.spec.ts-snapshots/focused-input-webkit-win32.png b/tests/headful.spec.ts-snapshots/focused-input-webkit-win32.png
deleted file mode 100644
index c587794530..0000000000
Binary files a/tests/headful.spec.ts-snapshots/focused-input-webkit-win32.png and /dev/null differ