appium-uiautomator2-driver
Version:
UiAutomator2 integration for Appium
34 lines • 1.19 kB
JavaScript
/**
* Gets the text of the currently displayed alert.
* @returns The alert text as a string.
*/
export async function getAlertText() {
return String(await this.uiautomator2.jwproxy.command('/alert/text', 'GET', {}));
}
/**
* Accepts the currently displayed alert.
* @param buttonLabel - Optional label of the button to click. If not provided, the button will be detected automatically.
*/
export async function mobileAcceptAlert(buttonLabel) {
await this.uiautomator2.jwproxy.command('/alert/accept', 'POST', { buttonLabel });
}
/**
* Accepts the currently displayed alert (W3C endpoint).
*/
export async function postAcceptAlert() {
await this.mobileAcceptAlert();
}
/**
* Dismisses the currently displayed alert.
* @param buttonLabel - Optional label of the button to click. If not provided, the button will be detected automatically.
*/
export async function mobileDismissAlert(buttonLabel) {
await this.uiautomator2.jwproxy.command('/alert/dismiss', 'POST', { buttonLabel });
}
/**
* Dismisses the currently displayed alert (W3C endpoint).
*/
export async function postDismissAlert() {
await this.mobileDismissAlert();
}
//# sourceMappingURL=alert.js.map