Skip to content

Commit c2e32d4

Browse files
committed
fix(android): handle optional duration parameter in longPress and enforce direction parameter in pull action
1 parent ec14e62 commit c2e32d4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/android/src/page/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class AndroidDevice implements AndroidDevicePage {
111111
);
112112
}
113113
const [x, y] = element.center;
114-
await this.longPress(x, y, param.duration);
114+
await this.longPress(x, y, param?.duration);
115115
},
116116
} as DeviceAction<{ duration?: number }>,
117117
{
@@ -129,6 +129,9 @@ export class AndroidDevice implements AndroidDevicePage {
129129
const startPoint = element
130130
? { left: element.center[0], top: element.center[1] }
131131
: undefined;
132+
if (!param || !param.direction) {
133+
throw new Error('AndroidPull requires a direction parameter');
134+
}
132135
if (param.direction === 'down') {
133136
await this.pullDown(startPoint, param.distance, param.duration);
134137
} else if (param.direction === 'up') {

packages/android/tests/ai/setting.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ describe(
1616
});
1717

1818
await agent.launch('com.android.settings/.Settings');
19+
await agent.aiAction('pull down to refresh');
20+
await agent.aiAction('long press chat list first chat');
21+
await agent.aiAction('click recent apps button');
22+
await agent.aiAction('click android home button');
1923
await agent.aiAction('scroll list to bottom');
2024
await agent.aiAction('open "More settings"');
2125
await agent.aiAction('scroll left until left edge');

0 commit comments

Comments
 (0)