Skip to content

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

fix(android): pass the call timeout to the driver (#43228)

Pavel Feldman75638b218746
diff --git a/packages/playwright-core/src/server/android/android.ts b/packages/playwright-core/src/server/android/android.ts
index 7a6e96bb92..af30700646 100644
--- a/packages/playwright-core/src/server/android/android.ts
+++ b/packages/playwright-core/src/server/android/android.ts
@@ -230,15 +230,12 @@ export class AndroidDevice extends SdkObject {
}
async send(progress: Progress, method: string, params: any = {}): Promise<any> {
- return await progress.race(this._send(method, params));
+ // The driver waits for the selector for "timeout" ms, use the timeout of the call.
+ return await progress.race(this._send(method, { ...params, timeout: progress.timeout }));
}
private async _send(method: string, params: any = {}): Promise<any> {
- params = {
- ...params,
- // Patch the timeout in, just in case it's missing in one of the commands.
- timeout: params.timeout || 0,
- };
+ params = { ...params };
if (params.androidSelector) {
params.selector = params.androidSelector;
delete params.androidSelector;
diff --git a/tests/android/device.spec.ts b/tests/android/device.spec.ts
index 8b750ca115..c4c8c23401 100644
--- a/tests/android/device.spec.ts
+++ b/tests/android/device.spec.ts
@@ -58,3 +58,17 @@ test('androidDevice.fill', async function({ androidDevice }) {
await androidDevice.fill({ res: 'org.chromium.webview_shell:id/url_field' }, 'Hello', { timeout: test.info().timeout });
expect((await androidDevice.info({ res: 'org.chromium.webview_shell:id/url_field' })).text).toBe('Hello');
});
+
+test('androidDevice.wait should wait for the default timeout', {
+ annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43218' },
+}, async function({ androidDevice }) {
+ androidDevice.setDefaultTimeout(10000);
+ try {
+ const start = Date.now();
+ const error = await androidDevice.wait({ res: 'org.chromium.webview_shell:id/does_not_exist' }).catch(e => e);
+ expect(error.message).toContain('androidDevice.wait');
+ expect(Date.now() - start).toBeGreaterThan(9000);
+ } finally {
+ androidDevice.setDefaultTimeout(90000);
+ }
+});