Skip to content

Commit fcb419f

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

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
@@ -110,7 +110,7 @@ export class AndroidDevice implements AndroidDevicePage {
110110
);
111111
}
112112
const [x, y] = element.center;
113-
await this.longPress(x, y, param.duration);
113+
await this.longPress(x, y, param?.duration);
114114
},
115115
} as DeviceAction<{ duration?: number }>,
116116
{
@@ -128,6 +128,9 @@ export class AndroidDevice implements AndroidDevicePage {
128128
const startPoint = element
129129
? { left: element.center[0], top: element.center[1] }
130130
: undefined;
131+
if (!param || !param.direction) {
132+
throw new Error('AndroidPull requires a direction parameter');
133+
}
131134
if (param.direction === 'down') {
132135
await this.pullDown(startPoint, param.distance, param.duration);
133136
} 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)