Skip to content

Commit d422186

Browse files
author
Feroz Khan
committed
Workaround for mac click operation when clicked on flutter elements which open native UI
1 parent 4d34ead commit d422186

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

src/commands/element.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,38 @@ export async function findElOrEls(
6565

6666
export async function click(this: AppiumFlutterDriver, element: string) {
6767
const driver = ELEMENT_CACHE.get(element);
68-
return await driver.command(`/element/${element}/click`, 'POST', {
69-
element,
70-
});
68+
69+
if (this.proxydriver instanceof Mac2Driver) {
70+
this.log.debug('Mac2Driver detected, using non-blocking click');
71+
72+
try {
73+
// Working around Mac2Driver issues which is blocking click request when clicking on Flutter elements opens native dialog
74+
// For Flutter elements, we just verify the element is in our cache
75+
if (!ELEMENT_CACHE.has(element)) {
76+
throw new Error('Element not found in cache');
77+
}
78+
79+
// Element exists, send click command
80+
driver.command(`/element/${element}/click`, 'POST', {
81+
element,
82+
}).catch((err: Error) => {
83+
// Log error but don't block
84+
this.log.debug(`Click command sent (non-blocking). Any error: ${err.message}`);
85+
});
86+
87+
// Return success since element check passed
88+
return true;
89+
} catch (err) {
90+
// Element check failed - this is a legitimate error we should report
91+
this.log.error('Element validation failed before click:', err);
92+
throw new Error(`Element validation failed: ${err.message}`);
93+
}
94+
} else {
95+
// For other drivers, proceed with normal click behavior
96+
return await driver.command(`/element/${element}/click`, 'POST', {
97+
element,
98+
});
99+
}
71100
}
72101

73102
export async function getText(this: AppiumFlutterDriver, elementId: string) {

0 commit comments

Comments
 (0)