From 501b24a078948e8d4eda174809e06d9410fea1f1 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 20 Jul 2022 18:27:08 +0200 Subject: [PATCH] test: android test enhancements (#15797) --- .github/workflows/tests_android.yml | 3 +- tests/android/browser.spec.ts | 6 +++ tests/android/device.spec.ts | 4 +- tests/android/webview.spec.ts | 2 +- tests/page/locator-convenience.spec.ts | 4 +- tests/page/locator-highlight.spec.ts | 24 ++++++++-- utils/avd_install.sh | 3 +- utils/avd_start.sh | 3 +- utils/avd_stop.sh | 12 +++++ utils/avd_test.js | 63 -------------------------- 10 files changed, 49 insertions(+), 75 deletions(-) create mode 100755 utils/avd_stop.sh delete mode 100644 utils/avd_test.js diff --git a/.github/workflows/tests_android.yml b/.github/workflows/tests_android.yml index 28502ddf40..34e9559e68 100644 --- a/.github/workflows/tests_android.yml +++ b/.github/workflows/tests_android.yml @@ -11,7 +11,7 @@ on: - release-* paths: - "**android**" - - "utils/avd_*.js" + - "utils/avd_*" - ".github/workflows/tests_android.yml" env: @@ -38,7 +38,6 @@ jobs: env: DEBUG: pw:install - run: npm run build - - run: npx playwright install-deps - name: Create Android Emulator run: utils/avd_recreate.sh - name: Start Android Emulator diff --git a/tests/android/browser.spec.ts b/tests/android/browser.spec.ts index cb0a07a4b8..493d2a89b1 100644 --- a/tests/android/browser.spec.ts +++ b/tests/android/browser.spec.ts @@ -17,6 +17,10 @@ import net from 'net'; import { androidTest as test, expect } from './androidTest'; +test.afterAll(async ({ androidDevice }) => { + await androidDevice.shell('am force-stop com.android.chrome'); +}); + test('androidDevice.model', async function({ androidDevice }) { expect(androidDevice.model()).toBe('sdk_gphone64_x86_64'); }); @@ -55,6 +59,7 @@ test('should be able to send CDP messages', async ({ androidDevice }) => { await client.send('Runtime.enable'); const evalResponse = await client.send('Runtime.evaluate', { expression: '1 + 2', returnByValue: true }); expect(evalResponse.result.value).toBe(3); + await context.close(); }); test('should be able to use a custom port', async function({ playwright }) { @@ -102,4 +107,5 @@ test('should be able to pass context options', async ({ androidDevice, httpsServ expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches)).toBe(false); + await context.close(); }); diff --git a/tests/android/device.spec.ts b/tests/android/device.spec.ts index c8011b4aea..23e2562473 100644 --- a/tests/android/device.spec.ts +++ b/tests/android/device.spec.ts @@ -52,7 +52,7 @@ test('androidDevice.push', async function({ androidDevice }) { }); test('androidDevice.fill', async function({ androidDevice }) { - test.fixme(!!process.env.CI, 'Hangs on the bots'); + test.fixme(true, 'Hangs on the bots'); await androidDevice.shell('am start org.chromium.webview_shell/.WebViewBrowserActivity'); await androidDevice.fill({ res: 'org.chromium.webview_shell:id/url_field' }, 'Hello'); @@ -81,7 +81,7 @@ test('androidDevice.options.omitDriverInstall', async function({ playwright }) { const filePath = join(require.resolve('playwright-core'), '..', 'bin', file); await androidDevice.installApk(await fs.promises.readFile(filePath)); } - androidDevice.shell('am instrument -w com.microsoft.playwright.androiddriver.test/androidx.test.runner.AndroidJUnitRunner').catch(e => console.error); + androidDevice.shell('am instrument -w com.microsoft.playwright.androiddriver.test/androidx.test.runner.AndroidJUnitRunner').catch(e => console.error(e)); // wait for finishing fill operation while (!fillStatus) diff --git a/tests/android/webview.spec.ts b/tests/android/webview.spec.ts index fdedccaecf..ccc5ebf75a 100644 --- a/tests/android/webview.spec.ts +++ b/tests/android/webview.spec.ts @@ -48,7 +48,7 @@ test('should navigate page internally', async function({ androidDevice }) { }); test('should navigate page externally', async function({ androidDevice }) { - test.fixme(!!process.env.CI, 'Hangs on the bots'); + test.fixme(true, 'Hangs on the bots'); expect(androidDevice.webViews().length).toBe(0); await androidDevice.shell('am start org.chromium.webview_shell/.WebViewBrowserActivity'); diff --git a/tests/page/locator-convenience.spec.ts b/tests/page/locator-convenience.spec.ts index 39986e6526..540d9b163c 100644 --- a/tests/page/locator-convenience.spec.ts +++ b/tests/page/locator-convenience.spec.ts @@ -202,7 +202,9 @@ it('allInnerTexts should work', async ({ page }) => { expect(await page.locator('div').allInnerTexts()).toEqual(['A', 'B', 'C']); }); -it('isVisible and isHidden should work with details', async ({ page }) => { +it('isVisible and isHidden should work with details', async ({ page, isAndroid }) => { + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/10674' }); + it.skip(isAndroid, 'We can\'t disable the AutoExpandDetailsElement feature on Android'); await page.setContent(`
click to open