Skip to content

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

chore: fix Android 13 compatibility (#16139)

Max Schmitt153670978d84
diff --git a/packages/playwright-core/src/server/android/android.ts b/packages/playwright-core/src/server/android/android.ts
index bf26c93b7c..996b007902 100644
--- a/packages/playwright-core/src/server/android/android.ts
+++ b/packages/playwright-core/src/server/android/android.ts
@@ -250,7 +250,7 @@ export class AndroidDevice extends SdkObject {
const commandLine = `_ --disable-fre --no-default-browser-check --no-first-run --remote-debugging-socket-name=${socketName}`;
debug('pw:android')('Starting', pkg, commandLine);
await this._backend.runCommand(`shell:echo "${commandLine}" > /data/local/tmp/chrome-command-line`);
- await this._backend.runCommand(`shell:am start -n ${pkg}/com.google.android.apps.chrome.Main about:blank`);
+ await this._backend.runCommand(`shell:am start -a android.intent.action.VIEW -d about:blank ${pkg}`);
return await this._connectToBrowser(socketName, options);
}
diff --git a/tests/android/device.spec.ts b/tests/android/device.spec.ts
index 23e2562473..7cc43f51f4 100644
--- a/tests/android/device.spec.ts
+++ b/tests/android/device.spec.ts
@@ -67,7 +67,7 @@ test('androidDevice.options.omitDriverInstall', async function({ playwright }) {
await androidDevice.shell(`cmd package uninstall com.microsoft.playwright.androiddriver`);
await androidDevice.shell(`cmd package uninstall com.microsoft.playwright.androiddriver.test`);
- await androidDevice.shell('am start -n com.android.chrome/com.google.android.apps.chrome.Main about:blank');
+ await androidDevice.shell('am start -a android.intent.action.VIEW -d about:blank com.android.chrome');
let fillStatus = '';
androidDevice.fill({ res: 'com.android.chrome:id/url_bar' }, 'Hello').then(() => {
diff --git a/utils/avd_install.sh b/utils/avd_install.sh
index ba0b749589..09fe871e41 100755
--- a/utils/avd_install.sh
+++ b/utils/avd_install.sh
@@ -24,7 +24,7 @@ echo Installing emulator...
yes | ${ANDROID_HOME}/tools/bin/sdkmanager --install platform-tools emulator
echo Installing platform SDK...
-yes | ${ANDROID_HOME}/tools/bin/sdkmanager --install "platforms;android-32"
+yes | ${ANDROID_HOME}/tools/bin/sdkmanager --install "platforms;android-33"
echo Starting ADB...
${ANDROID_HOME}/platform-tools/adb devices
diff --git a/utils/avd_recreate.sh b/utils/avd_recreate.sh
index 23df4626a1..a69d986a37 100755
--- a/utils/avd_recreate.sh
+++ b/utils/avd_recreate.sh
@@ -8,7 +8,7 @@ if [[ -z "${ANDROID_HOME}" ]]; then
export ANDROID_SDK_ROOT=${SDKDIR}
fi
-${ANDROID_HOME}/tools/bin/avdmanager delete avd --name android32 || true
-echo "y" | ${ANDROID_HOME}/tools/bin/sdkmanager --install "system-images;android-32;google_apis;x86_64"
-echo "no" | ${ANDROID_HOME}/tools/bin/avdmanager create avd --force --name android32 --device "Nexus 5X" --package "system-images;android-32;google_apis;x86_64"
+${ANDROID_HOME}/tools/bin/avdmanager delete avd --name android33 || true
+echo "y" | ${ANDROID_HOME}/tools/bin/sdkmanager --install "system-images;android-33;google_apis;x86_64"
+echo "no" | ${ANDROID_HOME}/tools/bin/avdmanager create avd --force --name android33 --device "Nexus 5X" --package "system-images;android-33;google_apis;x86_64"
${ANDROID_HOME}/emulator/emulator -list-avds
diff --git a/utils/avd_start.sh b/utils/avd_start.sh
index ac342d36e8..ed3352bbbb 100755
--- a/utils/avd_start.sh
+++ b/utils/avd_start.sh
@@ -16,7 +16,17 @@ if [[ -n "${GITHUB_ACTIONS}" ]]; then
fi
echo "Starting emulator"
-nohup ${ANDROID_HOME}/emulator/emulator -avd android32 -no-audio -no-window -gpu ${EMULATOR_GPU} -no-boot-anim &
+nohup ${ANDROID_HOME}/emulator/emulator -avd android33 -no-audio -no-window -gpu ${EMULATOR_GPU} -no-boot-anim &
${ANDROID_HOME}/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
${ANDROID_HOME}/platform-tools/adb devices
-echo "Emulator started"
\ No newline at end of file
+echo "Emulator started"
+
+echo "Installing Chromium WebView"
+CHROMIUM_ANDROID_REVISION="1030456"
+WEBVIEW_TMP_DIR="$(mktemp -d)"
+WEBVIEW_TMP_FILE="$WEBVIEW_TMP_DIR/chrome-android-zip"
+curl -s -o "${WEBVIEW_TMP_FILE}" "https://storage.googleapis.com/chromium-browser-snapshots/Android/${CHROMIUM_ANDROID_REVISION}/chrome-android.zip"
+unzip -q "${WEBVIEW_TMP_FILE}" -d "${WEBVIEW_TMP_DIR}"
+${ANDROID_HOME}/platform-tools/adb install -r "${WEBVIEW_TMP_DIR}/chrome-android/apks/SystemWebViewShell.apk"
+rm -rf "${WEBVIEW_TMP_DIR}"
+echo "Chromium WebView installed"