@@ -5,7 +5,7 @@ import {elementClick, execute, findElement, getPageSource} from '../../command.j
55import { generateAllElementLocators } from '../../locators/generate-all-locators.js' ;
66import { getPlatformName , PLATFORM } from '../../session-store.js' ;
77import type { DriverInstance } from '../../session-store.js' ;
8- import { resolveDriver , textResult , errorResult , toolErrorMessage } from '../tool-response.js' ;
8+ import { readWebElementId , resolveDriver , textResult , errorResult , toolErrorMessage } from '../tool-response.js' ;
99
1010const ANDROID_LOCATOR_STRATEGY_ORDER = [ 'accessibility id' , 'id' , 'xpath' , '-android uiautomator' , 'class name' ] ;
1111
@@ -99,8 +99,11 @@ async function handleAndroidAlert(driver: DriverInstance, action: string, button
9999 if ( ! button ) {
100100 throw new Error ( 'Could not find element with any generated locator; it may have disappeared' ) ;
101101 }
102- const buttonUUID = button . ELEMENT || button ;
103- await elementClick ( driver , buttonUUID ) ;
102+ const buttonId = readWebElementId ( button ) ;
103+ if ( ! buttonId ) {
104+ throw new Error ( 'Element was returned without a valid element ID' ) ;
105+ }
106+ await elementClick ( driver , buttonId ) ;
104107 } else {
105108 if ( action === 'accept' ) {
106109 await execute ( driver , 'mobile: acceptAlert' , { } ) ;
0 commit comments