Skip to main content

alert · answerAlert · pressAlertButton

This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET

Read a system dialog, or answer it. These call app_alert.

alert​

alert(): Promise<string>

answerAlert​

answerAlert(accept?: boolean, options?: { text?: string }): Promise<Data>

text is typed into a prompt's field before it is answered.

pressAlertButton​

pressAlertButton(button: string | number, options?: { text?: string }): Promise<Data>

By caption (any case, straight or curly quotes) or position from 1; the result's pressed is the caption pressed.

Examples​

Ask whether a dialog is up, what it says, and its buttons​

const text = await device.alert()
if (text) console.log(`A dialog is up: ${text}`)

The same call from the command line, mobium alert, printed on an Android 15 emulator:

a dialog is on screen: "Discard changes?\nThey will be lost."
buttons: "KEEP EDITING", "DISCARD"

mobium alert on an Android 15 emulator

mobium alert on an Android 15 emulator

Say yes to a dialog of one or two buttons​

await device.answerAlert(true)

The same call from the command line, mobium alert accept, printed on an Android 15 emulator:

accepted the dialog "Discard changes?\nThey will be lost.": pressed "DISCARD"
BeforeAfter
Before: mobium alert accept on an Android 15 emulatorAfter: mobium alert accept on an Android 15 emulator

mobium alert accept on an Android 15 emulator

Press a button by its caption, on a dialog of three​

const result = await device.pressAlertButton("Don't Save")
console.log(`pressed ${result.pressed}`)

The same call from the command line, mobium alert --button "Don't Save", printed on an Android 15 emulator:

pressed "DON'T SAVE" on the dialog "Save this draft?\nYou can come back to it later."
BeforeAfter
Before: mobium alert --button &quot;Don&#39;t Save&quot; on an Android 15 emulatorAfter: mobium alert --button &quot;Don&#39;t Save&quot; on an Android 15 emulator

mobium alert --button "Don't Save" on an Android 15 emulator

More examples​

Fill a prompt's field and accept it, in one call​

await device.answerAlert(true, { text: 'Groceries' })