Skip to content

feat(interactions): add handle alert tool for system alerts and permission dialogs#57

Merged
SrinivasanTarget merged 1 commit intoappium:mainfrom
Mochxd:feat/interactions-handle-alert
Feb 15, 2026
Merged

feat(interactions): add handle alert tool for system alerts and permission dialogs#57
SrinivasanTarget merged 1 commit intoappium:mainfrom
Mochxd:feat/interactions-handle-alert

Conversation

@Mochxd
Copy link
Contributor

@Mochxd Mochxd commented Dec 23, 2025

Adding a new appium_handle_alert tool for handling system alerts and dialogs on mobile devices.

Features:

  • support for accepting or dismissing system alerts programmatically
  • platform-specific implementations:
    • Android: Uses mobile: acceptAlert / mobile: dismissAlert for default actions; for specific button labels, finds elements by text or content-desc in the current page source, then uses generated locators (id, accessibility id, xpath, -android uiautomator, class name) to find and click—no hardcoded resource IDs or XPaths
    • iOS: Uses mobile: alert execute command with action and optional buttonLabel parameters
  • support for common permission dialog buttons:
    • Android: "While using the app", "Only this time", "Don't allow"
    • iOS: "Always", "Allow Once", "Don't allow"
    • Standard: "OK", "Cancel", "Allow", "Deny"
  • graceful error handling when no alert is present
  • generated locators for Android button detection by text or content-desc (no predefined resource-ID mapping)
  • updated main README with tool entry in the tools table and tool registered in src/tools/index.ts

} else {
button = await driver.findElement(
'xpath',
`//android.widget.Button[contains(@text, "${buttonLabel}")]`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contains might match multiple elements as well, doesnt look like a concrete solution here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do u think we can do? @SrinivasanTarget

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check the new behavior and if there are other comments.. @SrinivasanTarget

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SrinivasanTarget Any Updates?

const resourceId = resourceIdMap[buttonLabel];
if (resourceId) {
try {
button = await driver.findElement('id', resourceId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardcoded resource IDs might not work across all Android versions

@Mochxd Mochxd force-pushed the feat/interactions-handle-alert branch 7 times, most recently from f37e426 to 8b0939f Compare January 28, 2026 00:54
@Mochxd Mochxd force-pushed the feat/interactions-handle-alert branch from 8b0939f to 46c9181 Compare February 15, 2026 11:47
@SrinivasanTarget SrinivasanTarget merged commit 966d035 into appium:main Feb 15, 2026
6 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 15, 2026
## [1.15.0](v1.14.0...v1.15.0) (2026-02-15)

### Features

* **interactions:** add handle-alert tool ([#57](#57)) ([966d035](966d035))
@github-actions
Copy link

🎉 This PR is included in version 1.15.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments