/**
 * Get the time difference in seconds
 */ export function timeDifference ( string , start , end ) { const elapsed = ( end - start ) / 1000 ; console . log ( `${ string } It took ${ elapsed } seconds.` ) ; } /**
 * Create a cross platform solution for opening a deep link
 */ export async function openDeepLinkUrl ( url ) { const prefix = 'wdio://' ; if ( driver . isAndroid ) { return driver . execute ( 'mobile:deepLink' , { url : `${ prefix }${ url }` , package : 'com.wdiodemoapp' , } ) ; } const simulatorRegex = new RegExp ( '(.*-.*){2,}' ) ; if ( 'udid' in driver . capabilities && simulatorRegex . test ( driver . capabilities . udid as string ) ) { await driver . url ( `${ prefix }${ url }` ) ; } else { await driver . execute ( 'mobile: launchApp' , { bundleId : 'com.apple.mobilesafari' } ) ; const addressBarSelector = 'label == "Address" OR name == "URL"' ; const urlFieldSelector = 'type == "XCUIElementTypeTextField" && name CONTAINS "URL"' ; const addressBar = $ ( `-ios predicate string:${ addressBarSelector }` ) ; const urlField = $ ( `-ios predicate string:${ urlFieldSelector }` ) ; if ( ! ( await driver . isKeyboardShown ( ) ) ) { await addressBar . waitForDisplayed ( ) ; await addressBar . click ( ) ; } await urlField . setValue ( `${ prefix }${ url }\uE007` ) ; } /**
     * PRO TIP:
     * if you started the iOS device with `autoAcceptAlerts:true` in the capabilities then Appium will auto accept the alert that should
     * be shown now. You can then comment out the code below
     */ try { const openSelector = 'type == \'XCUIElementTypeButton\' && name CONTAINS \'Open\'' ; const openButton = $ ( `-ios predicate string:${ openSelector }` ) ; await openButton . waitForDisplayed ( { timeout : 2000 } ) ; await openButton . click ( ) ; } catch ( e ) { } }