addDialogRule · dialogRules · clearDialogRules
This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET
Declare how to answer a dialog, so an action that meets it carries on: when a dialog whose text contains when is in the way of a tap, a type or any action with a target, the button captioned press is pressed, the dialog is confirmed gone, and the action continues — and its result says which dialog was answered. These call app_dialogs.
addDialogRule
public void addDialogRule(String when, String press)
Declares how to answer a dialog, so an action that meets it carries on:
when a dialog whose text contains when is in the way, press the
button captioned press. It names a button, not accept or
dismiss, because which button those press differs by platform and by
dialog. Captions match ignoring case.
@param when text the dialog contains, ignoring case @param press the caption of the button to press, ignoring case
dialogRules
public List<Map<String, Object>> dialogRules()
The declared rules, each with how often it has answered.
@return the rules, each with how often it has answered
clearDialogRules
public void clearDialogRules()
Removes every rule for this device.
Examples
Answer a dialog whenever it gets in the way
device.addDialogRule("Save password", "Not now");
The same call from the command line, mobium dialogs --when "Save password" --press "Not now", printed on an Android 15 emulator:
1 dialog rule(s)
when "Save password": press "Not now" (answered 0)
Remove every rule
device.clearDialogRules();
The same call from the command line, mobium dialogs --clear, printed on an Android 15 emulator:
no dialog rules
On a device
| Before | After |
|---|---|
![]() | ![]() |
With mobium dialogs --when "Discard changes" --press "Keep Editing" declared, mobium tap testid=oneButtonBtn met the Discard dialog in its way, pressed Keep Editing, and went on — its own alert is up, and the line under the title says what the app received — on an Android 15 emulator

