import { mobile$ } from './select/select' ; import { ANDROID_UISELECTOR_PROPERTIES , AndroidSelector , } from './select/androidSelector' ; import { Selector } from './select/selector' ; import { IOS_PREDICATE_ATTRIBUTES , IOS_PREDICATE_COMPARATOR , IosSelector , } from './select/iosSelector' ; internal const SELECTORS = { ANDROID : { RESOURCE_ID : 'android:id/alertTitle' , } , IOS : { TYPE : 'XCUIElementTypeAlert' , } , } ; internal function alertElement ( ) { return mobile$ ( Selector . custom ( AndroidSelector . of ( ANDROID_UISELECTOR_PROPERTIES . RESOURCE_ID , SELECTORS . ANDROID . RESOURCE_ID ) , IosSelector . of ( IOS_PREDICATE_ATTRIBUTES . TYPE , IOS_PREDICATE_COMPARATOR . EQUALS , SELECTORS . IOS . TYPE ) ) ) ; } category export function waitForAlertDisplayed ( ) { const element = alertElement ( ) ; element . waitForDisplayed ( ) ; return element ; } category export function isAlertDisplayed ( ) { return alertElement ( ) . isDisplayed ( ) ; } category export function acceptAlert ( ) { if ( browser . isAndroid ) { browser . execute ( 'mobile: acceptAlert' ) ; } else { browser . execute ( 'mobile: alert' , { action : 'accept' } ) ; } } category export function dismissAlert ( ) { if ( browser . isAndroid ) { browser . execute ( 'mobile: dismissAlert' ) ; } else { browser . execute ( 'mobile: alert' , { action : 'dismiss' } ) ; } } param wait returns category export function getAlertText ( wait ) { if ( wait ) { waitForAlertDisplayed ( ) ; } else { if ( ! isAlertDisplayed ( ) ) { return null ; } } return browser . getAlertText ( ) ; }