@limrun/appium-xcuitest-driver 10.4.3-lim.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2600 -0
- package/LICENSE +201 -0
- package/README.md +55 -0
- package/build/index.d.ts +5 -0
- package/build/index.js +41 -0
- package/build/lib/app-infos-cache.d.ts +62 -0
- package/build/lib/app-infos-cache.d.ts.map +1 -0
- package/build/lib/app-infos-cache.js +180 -0
- package/build/lib/app-infos-cache.js.map +1 -0
- package/build/lib/app-utils.d.ts +89 -0
- package/build/lib/app-utils.d.ts.map +1 -0
- package/build/lib/app-utils.js +657 -0
- package/build/lib/app-utils.js.map +1 -0
- package/build/lib/commands/active-app-info.d.ts +9 -0
- package/build/lib/commands/active-app-info.d.ts.map +1 -0
- package/build/lib/commands/active-app-info.js +14 -0
- package/build/lib/commands/active-app-info.js.map +1 -0
- package/build/lib/commands/advanced-battery-types.d.ts +444 -0
- package/build/lib/commands/advanced-battery-types.d.ts.map +1 -0
- package/build/lib/commands/advanced-battery-types.js +8 -0
- package/build/lib/commands/advanced-battery-types.js.map +1 -0
- package/build/lib/commands/alert.d.ts +45 -0
- package/build/lib/commands/alert.d.ts.map +1 -0
- package/build/lib/commands/alert.js +87 -0
- package/build/lib/commands/alert.js.map +1 -0
- package/build/lib/commands/app-management.d.ts +153 -0
- package/build/lib/commands/app-management.d.ts.map +1 -0
- package/build/lib/commands/app-management.js +323 -0
- package/build/lib/commands/app-management.js.map +1 -0
- package/build/lib/commands/app-strings.d.ts +16 -0
- package/build/lib/commands/app-strings.d.ts.map +1 -0
- package/build/lib/commands/app-strings.js +30 -0
- package/build/lib/commands/app-strings.js.map +1 -0
- package/build/lib/commands/appearance.d.ts +22 -0
- package/build/lib/commands/appearance.d.ts.map +1 -0
- package/build/lib/commands/appearance.js +74 -0
- package/build/lib/commands/appearance.js.map +1 -0
- package/build/lib/commands/audit.d.ts +43 -0
- package/build/lib/commands/audit.d.ts.map +1 -0
- package/build/lib/commands/audit.js +31 -0
- package/build/lib/commands/audit.js.map +1 -0
- package/build/lib/commands/battery.d.ts +13 -0
- package/build/lib/commands/battery.d.ts.map +1 -0
- package/build/lib/commands/battery.js +49 -0
- package/build/lib/commands/battery.js.map +1 -0
- package/build/lib/commands/bidi/constants.d.ts +6 -0
- package/build/lib/commands/bidi/constants.d.ts.map +1 -0
- package/build/lib/commands/bidi/constants.js +10 -0
- package/build/lib/commands/bidi/constants.js.map +1 -0
- package/build/lib/commands/bidi/models.d.ts +9 -0
- package/build/lib/commands/bidi/models.d.ts.map +1 -0
- package/build/lib/commands/bidi/models.js +54 -0
- package/build/lib/commands/bidi/models.js.map +1 -0
- package/build/lib/commands/bidi/types.d.ts +26 -0
- package/build/lib/commands/bidi/types.d.ts.map +1 -0
- package/build/lib/commands/bidi/types.js +4 -0
- package/build/lib/commands/bidi/types.js.map +1 -0
- package/build/lib/commands/biometric.d.ts +32 -0
- package/build/lib/commands/biometric.d.ts.map +1 -0
- package/build/lib/commands/biometric.js +54 -0
- package/build/lib/commands/biometric.js.map +1 -0
- package/build/lib/commands/certificate.d.ts +50 -0
- package/build/lib/commands/certificate.d.ts.map +1 -0
- package/build/lib/commands/certificate.js +454 -0
- package/build/lib/commands/certificate.js.map +1 -0
- package/build/lib/commands/clipboard.d.ts +21 -0
- package/build/lib/commands/clipboard.d.ts.map +1 -0
- package/build/lib/commands/clipboard.js +36 -0
- package/build/lib/commands/clipboard.js.map +1 -0
- package/build/lib/commands/condition.d.ts +102 -0
- package/build/lib/commands/condition.d.ts.map +1 -0
- package/build/lib/commands/condition.js +146 -0
- package/build/lib/commands/condition.js.map +1 -0
- package/build/lib/commands/content-size.d.ts +30 -0
- package/build/lib/commands/content-size.d.ts.map +1 -0
- package/build/lib/commands/content-size.js +67 -0
- package/build/lib/commands/content-size.js.map +1 -0
- package/build/lib/commands/context.d.ts +191 -0
- package/build/lib/commands/context.d.ts.map +1 -0
- package/build/lib/commands/context.js +625 -0
- package/build/lib/commands/context.js.map +1 -0
- package/build/lib/commands/deviceInfo.d.ts +12 -0
- package/build/lib/commands/deviceInfo.d.ts.map +1 -0
- package/build/lib/commands/deviceInfo.js +25 -0
- package/build/lib/commands/deviceInfo.js.map +1 -0
- package/build/lib/commands/element.d.ts +108 -0
- package/build/lib/commands/element.d.ts.map +1 -0
- package/build/lib/commands/element.js +395 -0
- package/build/lib/commands/element.js.map +1 -0
- package/build/lib/commands/enum.d.ts +105 -0
- package/build/lib/commands/enum.d.ts.map +1 -0
- package/build/lib/commands/enum.js +113 -0
- package/build/lib/commands/enum.js.map +1 -0
- package/build/lib/commands/execute.d.ts +33 -0
- package/build/lib/commands/execute.d.ts.map +1 -0
- package/build/lib/commands/execute.js +142 -0
- package/build/lib/commands/execute.js.map +1 -0
- package/build/lib/commands/file-movement.d.ts +90 -0
- package/build/lib/commands/file-movement.d.ts.map +1 -0
- package/build/lib/commands/file-movement.js +477 -0
- package/build/lib/commands/file-movement.js.map +1 -0
- package/build/lib/commands/find.d.ts +21 -0
- package/build/lib/commands/find.d.ts.map +1 -0
- package/build/lib/commands/find.js +199 -0
- package/build/lib/commands/find.js.map +1 -0
- package/build/lib/commands/general.d.ts +137 -0
- package/build/lib/commands/general.d.ts.map +1 -0
- package/build/lib/commands/general.js +270 -0
- package/build/lib/commands/general.js.map +1 -0
- package/build/lib/commands/geolocation.d.ts +57 -0
- package/build/lib/commands/geolocation.d.ts.map +1 -0
- package/build/lib/commands/geolocation.js +58 -0
- package/build/lib/commands/geolocation.js.map +1 -0
- package/build/lib/commands/gesture.d.ts +283 -0
- package/build/lib/commands/gesture.d.ts.map +1 -0
- package/build/lib/commands/gesture.js +565 -0
- package/build/lib/commands/gesture.js.map +1 -0
- package/build/lib/commands/hid-event.d.ts +2773 -0
- package/build/lib/commands/hid-event.d.ts.map +1 -0
- package/build/lib/commands/hid-event.js +1633 -0
- package/build/lib/commands/hid-event.js.map +1 -0
- package/build/lib/commands/increase-contrast.d.ts +24 -0
- package/build/lib/commands/increase-contrast.d.ts.map +1 -0
- package/build/lib/commands/increase-contrast.js +49 -0
- package/build/lib/commands/increase-contrast.js.map +1 -0
- package/build/lib/commands/iohid.d.ts +1372 -0
- package/build/lib/commands/iohid.d.ts.map +1 -0
- package/build/lib/commands/iohid.js +63 -0
- package/build/lib/commands/iohid.js.map +1 -0
- package/build/lib/commands/keyboard.d.ts +32 -0
- package/build/lib/commands/keyboard.d.ts.map +1 -0
- package/build/lib/commands/keyboard.js +67 -0
- package/build/lib/commands/keyboard.js.map +1 -0
- package/build/lib/commands/keychains.d.ts +10 -0
- package/build/lib/commands/keychains.d.ts.map +1 -0
- package/build/lib/commands/keychains.js +22 -0
- package/build/lib/commands/keychains.js.map +1 -0
- package/build/lib/commands/localization.d.ts +17 -0
- package/build/lib/commands/localization.d.ts.map +1 -0
- package/build/lib/commands/localization.js +34 -0
- package/build/lib/commands/localization.js.map +1 -0
- package/build/lib/commands/location.d.ts +40 -0
- package/build/lib/commands/location.d.ts.map +1 -0
- package/build/lib/commands/location.js +121 -0
- package/build/lib/commands/location.js.map +1 -0
- package/build/lib/commands/lock.d.ts +23 -0
- package/build/lib/commands/lock.d.ts.map +1 -0
- package/build/lib/commands/lock.js +49 -0
- package/build/lib/commands/lock.js.map +1 -0
- package/build/lib/commands/log.d.ts +68 -0
- package/build/lib/commands/log.d.ts.map +1 -0
- package/build/lib/commands/log.js +287 -0
- package/build/lib/commands/log.js.map +1 -0
- package/build/lib/commands/memory.d.ts +11 -0
- package/build/lib/commands/memory.d.ts.map +1 -0
- package/build/lib/commands/memory.js +49 -0
- package/build/lib/commands/memory.js.map +1 -0
- package/build/lib/commands/navigation.d.ts +44 -0
- package/build/lib/commands/navigation.d.ts.map +1 -0
- package/build/lib/commands/navigation.js +121 -0
- package/build/lib/commands/navigation.js.map +1 -0
- package/build/lib/commands/notifications.d.ts +28 -0
- package/build/lib/commands/notifications.d.ts.map +1 -0
- package/build/lib/commands/notifications.js +64 -0
- package/build/lib/commands/notifications.js.map +1 -0
- package/build/lib/commands/pasteboard.d.ts +23 -0
- package/build/lib/commands/pasteboard.d.ts.map +1 -0
- package/build/lib/commands/pasteboard.js +43 -0
- package/build/lib/commands/pasteboard.js.map +1 -0
- package/build/lib/commands/pcap.d.ts +54 -0
- package/build/lib/commands/pcap.d.ts.map +1 -0
- package/build/lib/commands/pcap.js +149 -0
- package/build/lib/commands/pcap.js.map +1 -0
- package/build/lib/commands/performance.d.ts +85 -0
- package/build/lib/commands/performance.d.ts.map +1 -0
- package/build/lib/commands/performance.js +331 -0
- package/build/lib/commands/performance.js.map +1 -0
- package/build/lib/commands/permissions.d.ts +36 -0
- package/build/lib/commands/permissions.d.ts.map +1 -0
- package/build/lib/commands/permissions.js +80 -0
- package/build/lib/commands/permissions.js.map +1 -0
- package/build/lib/commands/proxy-helper.d.ts +15 -0
- package/build/lib/commands/proxy-helper.d.ts.map +1 -0
- package/build/lib/commands/proxy-helper.js +117 -0
- package/build/lib/commands/proxy-helper.js.map +1 -0
- package/build/lib/commands/record-audio.d.ts +69 -0
- package/build/lib/commands/record-audio.d.ts.map +1 -0
- package/build/lib/commands/record-audio.js +228 -0
- package/build/lib/commands/record-audio.js.map +1 -0
- package/build/lib/commands/recordscreen.d.ts +89 -0
- package/build/lib/commands/recordscreen.d.ts.map +1 -0
- package/build/lib/commands/recordscreen.js +326 -0
- package/build/lib/commands/recordscreen.js.map +1 -0
- package/build/lib/commands/screenshots.d.ts +16 -0
- package/build/lib/commands/screenshots.d.ts.map +1 -0
- package/build/lib/commands/screenshots.js +129 -0
- package/build/lib/commands/screenshots.js.map +1 -0
- package/build/lib/commands/simctl.d.ts +27 -0
- package/build/lib/commands/simctl.d.ts.map +1 -0
- package/build/lib/commands/simctl.js +65 -0
- package/build/lib/commands/simctl.js.map +1 -0
- package/build/lib/commands/source.d.ts +16 -0
- package/build/lib/commands/source.d.ts.map +1 -0
- package/build/lib/commands/source.js +128 -0
- package/build/lib/commands/source.js.map +1 -0
- package/build/lib/commands/timeouts.d.ts +53 -0
- package/build/lib/commands/timeouts.d.ts.map +1 -0
- package/build/lib/commands/timeouts.js +71 -0
- package/build/lib/commands/timeouts.js.map +1 -0
- package/build/lib/commands/types.d.ts +539 -0
- package/build/lib/commands/types.d.ts.map +1 -0
- package/build/lib/commands/types.js +3 -0
- package/build/lib/commands/types.js.map +1 -0
- package/build/lib/commands/web.d.ts +297 -0
- package/build/lib/commands/web.d.ts.map +1 -0
- package/build/lib/commands/web.js +1029 -0
- package/build/lib/commands/web.js.map +1 -0
- package/build/lib/commands/xctest-record-screen.d.ts +92 -0
- package/build/lib/commands/xctest-record-screen.d.ts.map +1 -0
- package/build/lib/commands/xctest-record-screen.js +193 -0
- package/build/lib/commands/xctest-record-screen.js.map +1 -0
- package/build/lib/commands/xctest.d.ts +71 -0
- package/build/lib/commands/xctest.d.ts.map +1 -0
- package/build/lib/commands/xctest.js +257 -0
- package/build/lib/commands/xctest.js.map +1 -0
- package/build/lib/css-converter.d.ts +10 -0
- package/build/lib/css-converter.d.ts.map +1 -0
- package/build/lib/css-converter.js +258 -0
- package/build/lib/css-converter.js.map +1 -0
- package/build/lib/desired-caps.d.ts +506 -0
- package/build/lib/desired-caps.d.ts.map +1 -0
- package/build/lib/desired-caps.js +400 -0
- package/build/lib/desired-caps.js.map +1 -0
- package/build/lib/device-connections-factory.d.ts +13 -0
- package/build/lib/device-connections-factory.d.ts.map +1 -0
- package/build/lib/device-connections-factory.js +244 -0
- package/build/lib/device-connections-factory.js.map +1 -0
- package/build/lib/device-log/helpers.d.ts +10 -0
- package/build/lib/device-log/helpers.d.ts.map +1 -0
- package/build/lib/device-log/helpers.js +37 -0
- package/build/lib/device-log/helpers.js.map +1 -0
- package/build/lib/device-log/ios-crash-log.d.ts +34 -0
- package/build/lib/device-log/ios-crash-log.d.ts.map +1 -0
- package/build/lib/device-log/ios-crash-log.js +141 -0
- package/build/lib/device-log/ios-crash-log.js.map +1 -0
- package/build/lib/device-log/ios-device-log.d.ts +19 -0
- package/build/lib/device-log/ios-device-log.d.ts.map +1 -0
- package/build/lib/device-log/ios-device-log.js +42 -0
- package/build/lib/device-log/ios-device-log.js.map +1 -0
- package/build/lib/device-log/ios-log.d.ts +24 -0
- package/build/lib/device-log/ios-log.d.ts.map +1 -0
- package/build/lib/device-log/ios-log.js +50 -0
- package/build/lib/device-log/ios-log.js.map +1 -0
- package/build/lib/device-log/ios-performance-log.d.ts +18 -0
- package/build/lib/device-log/ios-performance-log.d.ts.map +1 -0
- package/build/lib/device-log/ios-performance-log.js +43 -0
- package/build/lib/device-log/ios-performance-log.js.map +1 -0
- package/build/lib/device-log/ios-simulator-log.d.ts +38 -0
- package/build/lib/device-log/ios-simulator-log.d.ts.map +1 -0
- package/build/lib/device-log/ios-simulator-log.js +184 -0
- package/build/lib/device-log/ios-simulator-log.js.map +1 -0
- package/build/lib/device-log/line-consuming-log.d.ts +9 -0
- package/build/lib/device-log/line-consuming-log.d.ts.map +1 -0
- package/build/lib/device-log/line-consuming-log.js +16 -0
- package/build/lib/device-log/line-consuming-log.js.map +1 -0
- package/build/lib/device-log/safari-console-log.d.ts +67 -0
- package/build/lib/device-log/safari-console-log.d.ts.map +1 -0
- package/build/lib/device-log/safari-console-log.js +81 -0
- package/build/lib/device-log/safari-console-log.js.map +1 -0
- package/build/lib/device-log/safari-network-log.d.ts +75 -0
- package/build/lib/device-log/safari-network-log.d.ts.map +1 -0
- package/build/lib/device-log/safari-network-log.js +47 -0
- package/build/lib/device-log/safari-network-log.js.map +1 -0
- package/build/lib/doctor/checks.d.ts +3 -0
- package/build/lib/doctor/checks.d.ts.map +1 -0
- package/build/lib/doctor/checks.js +39 -0
- package/build/lib/doctor/checks.js.map +1 -0
- package/build/lib/doctor/optional-checks.d.ts +46 -0
- package/build/lib/doctor/optional-checks.d.ts.map +1 -0
- package/build/lib/doctor/optional-checks.js +129 -0
- package/build/lib/doctor/optional-checks.js.map +1 -0
- package/build/lib/doctor/required-checks.d.ts +42 -0
- package/build/lib/doctor/required-checks.d.ts.map +1 -0
- package/build/lib/doctor/required-checks.js +94 -0
- package/build/lib/doctor/required-checks.js.map +1 -0
- package/build/lib/doctor/utils.d.ts +8 -0
- package/build/lib/doctor/utils.d.ts.map +1 -0
- package/build/lib/doctor/utils.js +21 -0
- package/build/lib/doctor/utils.js.map +1 -0
- package/build/lib/driver.d.ts +2429 -0
- package/build/lib/driver.d.ts.map +1 -0
- package/build/lib/driver.js +1967 -0
- package/build/lib/driver.js.map +1 -0
- package/build/lib/execute-method-map.d.ts +552 -0
- package/build/lib/execute-method-map.d.ts.map +1 -0
- package/build/lib/execute-method-map.js +586 -0
- package/build/lib/execute-method-map.js.map +1 -0
- package/build/lib/ios-fs-helpers.d.ts +75 -0
- package/build/lib/ios-fs-helpers.d.ts.map +1 -0
- package/build/lib/ios-fs-helpers.js +370 -0
- package/build/lib/ios-fs-helpers.js.map +1 -0
- package/build/lib/ios-generic-simulators.d.ts +6 -0
- package/build/lib/ios-generic-simulators.d.ts.map +1 -0
- package/build/lib/ios-generic-simulators.js +14 -0
- package/build/lib/ios-generic-simulators.js.map +1 -0
- package/build/lib/logger.d.ts +3 -0
- package/build/lib/logger.d.ts.map +1 -0
- package/build/lib/logger.js +6 -0
- package/build/lib/logger.js.map +1 -0
- package/build/lib/method-map.d.ts +229 -0
- package/build/lib/method-map.d.ts.map +1 -0
- package/build/lib/method-map.js +200 -0
- package/build/lib/method-map.js.map +1 -0
- package/build/lib/real-device-clients/base-device-client.d.ts +22 -0
- package/build/lib/real-device-clients/base-device-client.d.ts.map +1 -0
- package/build/lib/real-device-clients/base-device-client.js +14 -0
- package/build/lib/real-device-clients/base-device-client.js.map +1 -0
- package/build/lib/real-device-clients/py-ios-device-client.d.ts +21 -0
- package/build/lib/real-device-clients/py-ios-device-client.d.ts.map +1 -0
- package/build/lib/real-device-clients/py-ios-device-client.js +125 -0
- package/build/lib/real-device-clients/py-ios-device-client.js.map +1 -0
- package/build/lib/real-device-management.d.ts +53 -0
- package/build/lib/real-device-management.d.ts.map +1 -0
- package/build/lib/real-device-management.js +128 -0
- package/build/lib/real-device-management.js.map +1 -0
- package/build/lib/real-device.d.ts +112 -0
- package/build/lib/real-device.d.ts.map +1 -0
- package/build/lib/real-device.js +352 -0
- package/build/lib/real-device.js.map +1 -0
- package/build/lib/simulator-management.d.ts +96 -0
- package/build/lib/simulator-management.d.ts.map +1 -0
- package/build/lib/simulator-management.js +278 -0
- package/build/lib/simulator-management.js.map +1 -0
- package/build/lib/stubs.d.ts +3 -0
- package/build/lib/stubs.d.ts.map +1 -0
- package/build/lib/stubs.js +3 -0
- package/build/lib/stubs.js.map +1 -0
- package/build/lib/types.d.ts +31 -0
- package/build/lib/types.d.ts.map +1 -0
- package/build/lib/types.js +3 -0
- package/build/lib/types.js.map +1 -0
- package/build/lib/utils.d.ts +191 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.js +549 -0
- package/build/lib/utils.js.map +1 -0
- package/build/lib/xcrun.d.ts +3 -0
- package/build/lib/xcrun.d.ts.map +1 -0
- package/build/lib/xcrun.js +17 -0
- package/build/lib/xcrun.js.map +1 -0
- package/index.js +7 -0
- package/lib/app-infos-cache.js +187 -0
- package/lib/app-utils.js +710 -0
- package/lib/commands/active-app-info.js +12 -0
- package/lib/commands/advanced-battery-types.ts +454 -0
- package/lib/commands/alert.js +88 -0
- package/lib/commands/app-management.js +346 -0
- package/lib/commands/app-strings.js +30 -0
- package/lib/commands/appearance.js +71 -0
- package/lib/commands/audit.js +31 -0
- package/lib/commands/battery.js +45 -0
- package/lib/commands/bidi/constants.ts +6 -0
- package/lib/commands/bidi/models.ts +55 -0
- package/lib/commands/bidi/types.ts +31 -0
- package/lib/commands/biometric.js +53 -0
- package/lib/commands/certificate.js +497 -0
- package/lib/commands/clipboard.js +35 -0
- package/lib/commands/condition.js +155 -0
- package/lib/commands/content-size.js +68 -0
- package/lib/commands/context.js +705 -0
- package/lib/commands/deviceInfo.js +27 -0
- package/lib/commands/element.js +423 -0
- package/lib/commands/enum.ts +108 -0
- package/lib/commands/execute.js +153 -0
- package/lib/commands/file-movement.js +510 -0
- package/lib/commands/find.js +205 -0
- package/lib/commands/general.js +278 -0
- package/lib/commands/geolocation.js +56 -0
- package/lib/commands/gesture.js +596 -0
- package/lib/commands/hid-event.ts +1634 -0
- package/lib/commands/increase-contrast.js +50 -0
- package/lib/commands/iohid.js +64 -0
- package/lib/commands/keyboard.js +62 -0
- package/lib/commands/keychains.js +18 -0
- package/lib/commands/localization.js +30 -0
- package/lib/commands/location.js +131 -0
- package/lib/commands/lock.js +46 -0
- package/lib/commands/log.js +327 -0
- package/lib/commands/memory.js +51 -0
- package/lib/commands/navigation.js +125 -0
- package/lib/commands/notifications.js +66 -0
- package/lib/commands/pasteboard.js +42 -0
- package/lib/commands/pcap.js +168 -0
- package/lib/commands/performance.js +392 -0
- package/lib/commands/permissions.js +85 -0
- package/lib/commands/proxy-helper.js +122 -0
- package/lib/commands/record-audio.js +264 -0
- package/lib/commands/recordscreen.js +391 -0
- package/lib/commands/screenshots.js +137 -0
- package/lib/commands/simctl.js +71 -0
- package/lib/commands/source.js +131 -0
- package/lib/commands/timeouts.js +68 -0
- package/lib/commands/types.ts +648 -0
- package/lib/commands/web.js +1113 -0
- package/lib/commands/xctest-record-screen.js +204 -0
- package/lib/commands/xctest.js +285 -0
- package/lib/css-converter.js +311 -0
- package/lib/desired-caps.js +396 -0
- package/lib/device-connections-factory.js +269 -0
- package/lib/device-log/helpers.ts +40 -0
- package/lib/device-log/ios-crash-log.ts +166 -0
- package/lib/device-log/ios-device-log.ts +51 -0
- package/lib/device-log/ios-log.ts +70 -0
- package/lib/device-log/ios-performance-log.ts +50 -0
- package/lib/device-log/ios-simulator-log.ts +202 -0
- package/lib/device-log/line-consuming-log.ts +16 -0
- package/lib/device-log/safari-console-log.ts +117 -0
- package/lib/device-log/safari-network-log.ts +120 -0
- package/lib/doctor/checks.ts +3 -0
- package/lib/doctor/optional-checks.ts +173 -0
- package/lib/doctor/required-checks.ts +120 -0
- package/lib/doctor/utils.ts +18 -0
- package/lib/driver.js +2316 -0
- package/lib/execute-method-map.ts +585 -0
- package/lib/ios-fs-helpers.js +355 -0
- package/lib/ios-generic-simulators.js +11 -0
- package/lib/logger.js +5 -0
- package/lib/method-map.js +196 -0
- package/lib/real-device-clients/base-device-client.ts +34 -0
- package/lib/real-device-clients/py-ios-device-client.ts +149 -0
- package/lib/real-device-management.js +133 -0
- package/lib/real-device.js +347 -0
- package/lib/simulator-management.js +324 -0
- package/lib/stubs.ts +3 -0
- package/lib/types.ts +33 -0
- package/lib/utils.js +551 -0
- package/lib/xcrun.js +16 -0
- package/package.json +175 -0
- package/scripts/build-docs.js +56 -0
- package/scripts/build-wda.js +42 -0
- package/scripts/download-wda-sim.mjs +68 -0
- package/scripts/image-mounter.mjs +239 -0
- package/scripts/open-wda.mjs +15 -0
- package/scripts/tunnel-creation.mjs +359 -0
- package/scripts/utils.js +16 -0
|
@@ -0,0 +1,1113 @@
|
|
|
1
|
+
import {errors, isErrorType} from 'appium/driver';
|
|
2
|
+
import {timing, util} from 'appium/support';
|
|
3
|
+
import {retryInterval} from 'asyncbox';
|
|
4
|
+
import B, {TimeoutError, AggregateError} from 'bluebird';
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
|
|
7
|
+
const IPHONE_TOP_BAR_HEIGHT = 71;
|
|
8
|
+
const IPHONE_SCROLLED_TOP_BAR_HEIGHT = 41;
|
|
9
|
+
const IPHONE_X_SCROLLED_OFFSET = 55;
|
|
10
|
+
const IPHONE_X_NOTCH_OFFSET_IOS = 24;
|
|
11
|
+
const IPHONE_X_NOTCH_OFFSET_IOS_13 = 20;
|
|
12
|
+
|
|
13
|
+
const IPHONE_LANDSCAPE_TOP_BAR_HEIGHT = 51;
|
|
14
|
+
const IPHONE_BOTTOM_BAR_OFFSET = 49;
|
|
15
|
+
const TAB_BAR_OFFSET = 33;
|
|
16
|
+
const IPHONE_WEB_COORD_SMART_APP_BANNER_OFFSET = 84;
|
|
17
|
+
const IPAD_WEB_COORD_SMART_APP_BANNER_OFFSET = 95;
|
|
18
|
+
|
|
19
|
+
const CALIBRATION_TAP_DELTA_PX = 7;
|
|
20
|
+
|
|
21
|
+
const NOTCHED_DEVICE_SIZES = [
|
|
22
|
+
{w: 1125, h: 2436}, // 11 Pro, X, Xs
|
|
23
|
+
{w: 828, h: 1792}, // 11, Xr
|
|
24
|
+
{w: 1242, h: 2688}, // 11 Pro Max, Xs Max
|
|
25
|
+
{w: 1080, h: 2340}, // 13 mini, 12 mini
|
|
26
|
+
{w: 1170, h: 2532}, // 14, 13, 13 Pro, 12, 12 Pro
|
|
27
|
+
{w: 1284, h: 2778}, // 14 Plus, 13 Pro Max, 12 Pro Max
|
|
28
|
+
{w: 1179, h: 2556}, // 14 Pro
|
|
29
|
+
{w: 1290, h: 2796}, // 14 Pro Max
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const {W3C_WEB_ELEMENT_IDENTIFIER} = util;
|
|
33
|
+
|
|
34
|
+
const ATOM_WAIT_TIMEOUT_MS = 2 * 60000;
|
|
35
|
+
// This value must be greater than the alerts check interval in WDA:
|
|
36
|
+
// https://github.com/appium/WebDriverAgent/blob/8bc3135f021b529d916846477544f4b8ca890f59/WebDriverAgentLib/Utilities/FBAlertsMonitor.m#L17
|
|
37
|
+
const ATOM_INITIAL_WAIT_MS = 2100;
|
|
38
|
+
const OBSTRUCTING_ALERT_PRESENCE_CHECK_INTERVAL_MS = 500;
|
|
39
|
+
|
|
40
|
+
const ON_OBSTRUCTING_ALERT_EVENT = 'alert';
|
|
41
|
+
const ON_APP_CRASH_EVENT = 'app_crash';
|
|
42
|
+
|
|
43
|
+
const VISIBLE = 'visible';
|
|
44
|
+
const INVISIBLE = 'invisible';
|
|
45
|
+
const DETECT = 'detect';
|
|
46
|
+
const VISIBILITIES = [VISIBLE, INVISIBLE, DETECT];
|
|
47
|
+
|
|
48
|
+
// The position of Safari's tab (search bar).
|
|
49
|
+
// Since iOS 15, the bar is the bottom by default.
|
|
50
|
+
const TAB_BAR_POSITION_TOP = 'top';
|
|
51
|
+
const TAB_BAR_POSITION_BOTTOM = 'bottom';
|
|
52
|
+
const TAB_BAR_POSSITIONS = [TAB_BAR_POSITION_TOP, TAB_BAR_POSITION_BOTTOM];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @this {XCUITestDriver}
|
|
56
|
+
* @group Mobile Web Only
|
|
57
|
+
* @param {number|string|null} frame
|
|
58
|
+
* @returns {Promise<void>}
|
|
59
|
+
*/
|
|
60
|
+
export async function setFrame(frame) {
|
|
61
|
+
if (!this.isWebContext()) {
|
|
62
|
+
throw new errors.NotImplementedError();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (_.isNull(frame)) {
|
|
66
|
+
this.curWebFrames = [];
|
|
67
|
+
this.log.debug('Leaving web frame and going back to default content');
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (hasElementId(frame)) {
|
|
72
|
+
const atomsElement = this.getAtomsElement(frame);
|
|
73
|
+
const value = await this.executeAtom('get_frame_window', [atomsElement]);
|
|
74
|
+
this.log.debug(`Entering new web frame: '${value.WINDOW}'`);
|
|
75
|
+
this.curWebFrames.unshift(value.WINDOW);
|
|
76
|
+
} else {
|
|
77
|
+
const atom = _.isNumber(frame) ? 'frame_by_index' : 'frame_by_id_or_name';
|
|
78
|
+
const value = await this.executeAtom(atom, [frame]);
|
|
79
|
+
if (_.isNull(value) || _.isUndefined(value.WINDOW)) {
|
|
80
|
+
throw new errors.NoSuchFrameError();
|
|
81
|
+
}
|
|
82
|
+
this.log.debug(`Entering new web frame: '${value.WINDOW}'`);
|
|
83
|
+
this.curWebFrames.unshift(value.WINDOW);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @this {XCUITestDriver}
|
|
89
|
+
* @group Mobile Web Only
|
|
90
|
+
* @param {string} propertyName
|
|
91
|
+
* @param {Element | string} el
|
|
92
|
+
* @returns {Promise<string>}
|
|
93
|
+
*/
|
|
94
|
+
export async function getCssProperty(propertyName, el) {
|
|
95
|
+
if (!this.isWebContext()) {
|
|
96
|
+
throw new errors.NotImplementedError();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const atomsElement = this.getAtomsElement(el);
|
|
100
|
+
return await this.executeAtom('get_value_of_css_property', [atomsElement, propertyName]);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Submit the form an element is in
|
|
105
|
+
*
|
|
106
|
+
* @param {string|Element} el - the element ID
|
|
107
|
+
* @group Mobile Web Only
|
|
108
|
+
* @this {XCUITestDriver}
|
|
109
|
+
*/
|
|
110
|
+
export async function submit(el) {
|
|
111
|
+
if (!this.isWebContext()) {
|
|
112
|
+
throw new errors.NotImplementedError();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const atomsElement = this.getAtomsElement(el);
|
|
116
|
+
await this.executeAtom('submit', [atomsElement]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @this {XCUITestDriver}
|
|
121
|
+
* @group Mobile Web Only
|
|
122
|
+
*/
|
|
123
|
+
export async function refresh() {
|
|
124
|
+
if (!this.isWebContext()) {
|
|
125
|
+
throw new errors.NotImplementedError();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
await (/** @type {RemoteDebugger} */ (this.remote)).execute('window.location.reload()');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @this {XCUITestDriver}
|
|
133
|
+
* @group Mobile Web Only
|
|
134
|
+
* @returns {Promise<string>}
|
|
135
|
+
*/
|
|
136
|
+
export async function getUrl() {
|
|
137
|
+
if (!this.isWebContext()) {
|
|
138
|
+
throw new errors.NotImplementedError();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return await (/** @type {RemoteDebugger} */ (this.remote)).execute('window.location.href');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @this {XCUITestDriver}
|
|
146
|
+
* @group Mobile Web Only
|
|
147
|
+
* @returns {Promise<string>}
|
|
148
|
+
*/
|
|
149
|
+
export async function title() {
|
|
150
|
+
if (!this.isWebContext()) {
|
|
151
|
+
throw new errors.NotImplementedError();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return await (/** @type {RemoteDebugger} */ (this.remote)).execute('window.document.title');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @this {XCUITestDriver}
|
|
159
|
+
* @group Mobile Web Only
|
|
160
|
+
* @returns {Promise<import('@appium/types').Cookie[]>}
|
|
161
|
+
*/
|
|
162
|
+
export async function getCookies() {
|
|
163
|
+
if (!this.isWebContext()) {
|
|
164
|
+
throw new errors.NotImplementedError();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// get the cookies from the remote debugger, or an empty object
|
|
168
|
+
const {cookies} = await (/** @type {RemoteDebugger} */ (this.remote)).getCookies();
|
|
169
|
+
|
|
170
|
+
// the value is URI encoded, so decode it safely
|
|
171
|
+
return cookies.map((cookie) => {
|
|
172
|
+
if (!_.isEmpty(cookie.value)) {
|
|
173
|
+
try {
|
|
174
|
+
cookie.value = decodeURI(cookie.value);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
this.log.debug(
|
|
177
|
+
`Cookie ${cookie.name} was not decoded successfully. Cookie value: ${cookie.value}`,
|
|
178
|
+
);
|
|
179
|
+
this.log.warn(error);
|
|
180
|
+
// Keep the original value
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return cookie;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @this {XCUITestDriver}
|
|
189
|
+
* @group Mobile Web Only
|
|
190
|
+
* @param {import('@appium/types').Cookie} cookie
|
|
191
|
+
* @returns {Promise<void>}
|
|
192
|
+
*/
|
|
193
|
+
export async function setCookie(cookie) {
|
|
194
|
+
if (!this.isWebContext()) {
|
|
195
|
+
throw new errors.NotImplementedError();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const clonedCookie = _.clone(cookie);
|
|
199
|
+
// if `path` field is not specified, Safari will not update cookies as expected; eg issue #1708
|
|
200
|
+
if (!clonedCookie.path) {
|
|
201
|
+
clonedCookie.path = '/';
|
|
202
|
+
}
|
|
203
|
+
const jsCookie = createJSCookie(clonedCookie.name, clonedCookie.value, {
|
|
204
|
+
expires: _.isNumber(clonedCookie.expiry)
|
|
205
|
+
? new Date(clonedCookie.expiry * 1000).toUTCString()
|
|
206
|
+
: clonedCookie.expiry,
|
|
207
|
+
path: clonedCookie.path,
|
|
208
|
+
domain: clonedCookie.domain,
|
|
209
|
+
httpOnly: clonedCookie.httpOnly,
|
|
210
|
+
secure: clonedCookie.secure,
|
|
211
|
+
});
|
|
212
|
+
const script = `document.cookie = ${JSON.stringify(jsCookie)}`;
|
|
213
|
+
await this.executeAtom('execute_script', [script, []]);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @this {XCUITestDriver}
|
|
218
|
+
* @param {string} cookieName
|
|
219
|
+
* @returns {Promise<void>}
|
|
220
|
+
* @group Mobile Web Only
|
|
221
|
+
*/
|
|
222
|
+
export async function deleteCookie(cookieName) {
|
|
223
|
+
if (!this.isWebContext()) {
|
|
224
|
+
throw new errors.NotImplementedError();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const cookies = await this.getCookies();
|
|
228
|
+
const cookie = cookies.find(({name}) => name === cookieName);
|
|
229
|
+
if (!cookie) {
|
|
230
|
+
this.log.debug(`Cookie '${cookieName}' not found. Ignoring.`);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
await _deleteCookie.bind(this)(cookie);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @this {XCUITestDriver}
|
|
239
|
+
* @group Mobile Web Only
|
|
240
|
+
* @returns {Promise<void>}
|
|
241
|
+
*/
|
|
242
|
+
export async function deleteCookies() {
|
|
243
|
+
if (!this.isWebContext()) {
|
|
244
|
+
throw new errors.NotImplementedError();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const cookies = await this.getCookies();
|
|
248
|
+
await B.all(cookies.map((cookie) => _deleteCookie.bind(this)(cookie)));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @this {XCUITestDriver}
|
|
253
|
+
* @param {Element | string} el
|
|
254
|
+
* @returns {Element | string}
|
|
255
|
+
*/
|
|
256
|
+
export function cacheWebElement(el) {
|
|
257
|
+
if (!_.isPlainObject(el)) {
|
|
258
|
+
return el;
|
|
259
|
+
}
|
|
260
|
+
const elId = util.unwrapElement(el);
|
|
261
|
+
if (!isValidElementIdentifier(elId)) {
|
|
262
|
+
return el;
|
|
263
|
+
}
|
|
264
|
+
// In newer debugger releases element identifiers look like `:wdc:1628151649325`
|
|
265
|
+
// We assume it is safe to use these to identify cached elements
|
|
266
|
+
const cacheId = _.includes(elId, ':') ? elId : util.uuidV4();
|
|
267
|
+
this.webElementsCache.set(cacheId, elId);
|
|
268
|
+
return util.wrapElement(cacheId);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @this {XCUITestDriver}
|
|
273
|
+
* @param {any} response
|
|
274
|
+
* @returns {any}
|
|
275
|
+
*/
|
|
276
|
+
export function cacheWebElements(response) {
|
|
277
|
+
const toCached = (/** @type {any} */ v) => (_.isArray(v) || _.isPlainObject(v)) ? this.cacheWebElements(v) : v;
|
|
278
|
+
|
|
279
|
+
if (_.isArray(response)) {
|
|
280
|
+
return response.map(toCached);
|
|
281
|
+
} else if (_.isPlainObject(response)) {
|
|
282
|
+
const result = {...response, ...(/** @type {Element} */ (this.cacheWebElement(response)))};
|
|
283
|
+
return _.toPairs(result).reduce((acc, [key, value]) => {
|
|
284
|
+
acc[key] = toCached(value);
|
|
285
|
+
return acc;
|
|
286
|
+
}, {});
|
|
287
|
+
}
|
|
288
|
+
return response;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* @param {string} atom
|
|
293
|
+
* @param {unknown[]} args
|
|
294
|
+
* @returns {Promise<any>}
|
|
295
|
+
* @privateRemarks This should return `Promise<T>` where `T` extends `unknown`, but that's going to cause a lot of things to break.
|
|
296
|
+
* @this {XCUITestDriver}
|
|
297
|
+
*/
|
|
298
|
+
export async function executeAtom(atom, args, alwaysDefaultFrame = false) {
|
|
299
|
+
let frames = alwaysDefaultFrame === true ? [] : this.curWebFrames;
|
|
300
|
+
let promise = (/** @type {RemoteDebugger} */ (this.remote)).executeAtom(atom, args, frames);
|
|
301
|
+
return await this.waitForAtom(promise);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @this {XCUITestDriver}
|
|
306
|
+
* @param {string} atom
|
|
307
|
+
* @param {any[]} args
|
|
308
|
+
*/
|
|
309
|
+
export async function executeAtomAsync(atom, args) {
|
|
310
|
+
// save the resolve and reject methods of the promise to be waited for
|
|
311
|
+
let promise = new B((resolve, reject) => {
|
|
312
|
+
this.asyncPromise = {resolve, reject};
|
|
313
|
+
});
|
|
314
|
+
await (/** @type {RemoteDebugger} */ (this.remote)).executeAtomAsync(atom, args, this.curWebFrames);
|
|
315
|
+
return await this.waitForAtom(promise);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @template {string} S
|
|
320
|
+
* @param {S|Element<S>} elOrId
|
|
321
|
+
* @returns {import('./types').AtomsElement<S>}
|
|
322
|
+
* @this {XCUITestDriver}
|
|
323
|
+
*/
|
|
324
|
+
export function getAtomsElement(elOrId) {
|
|
325
|
+
const elId = util.unwrapElement(elOrId);
|
|
326
|
+
if (!this.webElementsCache?.has(elId)) {
|
|
327
|
+
throw new errors.StaleElementReferenceError();
|
|
328
|
+
}
|
|
329
|
+
return {ELEMENT: this.webElementsCache.get(elId)};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* @param {readonly any[]} [args]
|
|
334
|
+
* @this {XCUITestDriver}
|
|
335
|
+
*/
|
|
336
|
+
export function convertElementsForAtoms(args = []) {
|
|
337
|
+
return args.map((arg) => {
|
|
338
|
+
if (hasElementId(arg)) {
|
|
339
|
+
try {
|
|
340
|
+
return this.getAtomsElement(arg);
|
|
341
|
+
} catch (err) {
|
|
342
|
+
if (!isErrorType(err, errors.StaleElementReferenceError)) {
|
|
343
|
+
throw err;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return arg;
|
|
347
|
+
}
|
|
348
|
+
return _.isArray(arg) ? this.convertElementsForAtoms(arg) : arg;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
*
|
|
354
|
+
* @param {any} element
|
|
355
|
+
* @returns {string | undefined}
|
|
356
|
+
*/
|
|
357
|
+
export function getElementId(element) {
|
|
358
|
+
return element?.ELEMENT || element?.[W3C_WEB_ELEMENT_IDENTIFIER];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @param {any} element
|
|
363
|
+
* @returns {element is Element}
|
|
364
|
+
*/
|
|
365
|
+
export function hasElementId(element) {
|
|
366
|
+
return (
|
|
367
|
+
util.hasValue(element) &&
|
|
368
|
+
(util.hasValue(element.ELEMENT) || util.hasValue(element[W3C_WEB_ELEMENT_IDENTIFIER]))
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @this {XCUITestDriver}
|
|
374
|
+
* @param {string} strategy
|
|
375
|
+
* @param {string} selector
|
|
376
|
+
* @param {boolean} [many]
|
|
377
|
+
* @param {Element | string | null} [ctx]
|
|
378
|
+
* @returns {Promise<Element | Element[]>}
|
|
379
|
+
*/
|
|
380
|
+
export async function findWebElementOrElements(strategy, selector, many, ctx) {
|
|
381
|
+
const contextElement = _.isNil(ctx) ? null : this.getAtomsElement(ctx);
|
|
382
|
+
const atomName = many ? 'find_elements' : 'find_element_fragment';
|
|
383
|
+
let element;
|
|
384
|
+
const doFind = async () => {
|
|
385
|
+
element = await this.executeAtom(atomName, [strategy, selector, contextElement]);
|
|
386
|
+
return !_.isNull(element);
|
|
387
|
+
};
|
|
388
|
+
try {
|
|
389
|
+
await this.implicitWaitForCondition(doFind);
|
|
390
|
+
} catch (err) {
|
|
391
|
+
if (err.message && _.isFunction(err.message.match) && err.message.match(/Condition unmet/)) {
|
|
392
|
+
// condition was not met setting res to empty array
|
|
393
|
+
element = [];
|
|
394
|
+
} else {
|
|
395
|
+
throw err;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (many) {
|
|
400
|
+
return this.cacheWebElements(element);
|
|
401
|
+
}
|
|
402
|
+
if (_.isEmpty(element)) {
|
|
403
|
+
throw new errors.NoSuchElementError();
|
|
404
|
+
}
|
|
405
|
+
return this.cacheWebElements(element);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* @this {XCUITestDriver}
|
|
410
|
+
* @param {number} x
|
|
411
|
+
* @param {number} y
|
|
412
|
+
*/
|
|
413
|
+
export async function clickWebCoords(x, y) {
|
|
414
|
+
const {x: translatedX, y: translatedY} = await this.translateWebCoords(x, y);
|
|
415
|
+
await this.mobileTap(translatedX, translatedY);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* @this {XCUITestDriver}
|
|
420
|
+
* @returns {Promise<boolean>}
|
|
421
|
+
*/
|
|
422
|
+
export async function getSafariIsIphone() {
|
|
423
|
+
if (_.isBoolean(this._isSafariIphone)) {
|
|
424
|
+
return this._isSafariIphone;
|
|
425
|
+
}
|
|
426
|
+
try {
|
|
427
|
+
const userAgent = /** @type {string} */ (await this.execute('return navigator.userAgent'));
|
|
428
|
+
this._isSafariIphone = userAgent.toLowerCase().includes('iphone');
|
|
429
|
+
} catch (err) {
|
|
430
|
+
this.log.warn(`Unable to find device type from useragent. Assuming iPhone`);
|
|
431
|
+
this.log.debug(`Error: ${err.message}`);
|
|
432
|
+
}
|
|
433
|
+
return this._isSafariIphone ?? true;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @this {XCUITestDriver}
|
|
438
|
+
* @returns {Promise<import('@appium/types').Size>}
|
|
439
|
+
*/
|
|
440
|
+
export async function getSafariDeviceSize() {
|
|
441
|
+
const script =
|
|
442
|
+
'return {height: window.screen.availHeight * window.devicePixelRatio, width: window.screen.availWidth * window.devicePixelRatio};';
|
|
443
|
+
const {width, height} = /** @type {import('@appium/types').Size} */ (
|
|
444
|
+
await this.execute(script)
|
|
445
|
+
);
|
|
446
|
+
const [normHeight, normWidth] = height > width ? [height, width] : [width, height];
|
|
447
|
+
return {
|
|
448
|
+
width: normWidth,
|
|
449
|
+
height: normHeight,
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* @this {XCUITestDriver}
|
|
455
|
+
* @returns {Promise<boolean>}
|
|
456
|
+
*/
|
|
457
|
+
export async function getSafariIsNotched() {
|
|
458
|
+
if (_.isBoolean(this._isSafariNotched)) {
|
|
459
|
+
return this._isSafariNotched;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
try {
|
|
463
|
+
const {width, height} = await this.getSafariDeviceSize();
|
|
464
|
+
for (const device of NOTCHED_DEVICE_SIZES) {
|
|
465
|
+
if (device.w === width && device.h === height) {
|
|
466
|
+
this._isSafariNotched = true;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
} catch (err) {
|
|
470
|
+
this.log.warn(
|
|
471
|
+
`Unable to find device type from dimensions. Assuming the device is not notched`,
|
|
472
|
+
);
|
|
473
|
+
this.log.debug(`Error: ${err.message}`);
|
|
474
|
+
}
|
|
475
|
+
return this._isSafariNotched ?? false;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* @this {XCUITestDriver}
|
|
480
|
+
*/
|
|
481
|
+
export async function getExtraTranslateWebCoordsOffset(wvPos, realDims) {
|
|
482
|
+
let topOffset = 0;
|
|
483
|
+
let bottomOffset = 0;
|
|
484
|
+
|
|
485
|
+
const isIphone = await this.getSafariIsIphone();
|
|
486
|
+
|
|
487
|
+
// No need to check whether the Smart App Banner or Tab Bar is visible or not
|
|
488
|
+
// if already defined by nativeWebTapTabBarVisibility or nativeWebTapSmartAppBannerVisibility in settings.
|
|
489
|
+
const {
|
|
490
|
+
nativeWebTapTabBarVisibility,
|
|
491
|
+
nativeWebTapSmartAppBannerVisibility,
|
|
492
|
+
safariTabBarPosition = util.compareVersions(/** @type {string} */ (this.opts.platformVersion), '>=', '15.0') &&
|
|
493
|
+
isIphone
|
|
494
|
+
? TAB_BAR_POSITION_BOTTOM
|
|
495
|
+
: TAB_BAR_POSITION_TOP,
|
|
496
|
+
} = this.settings.getSettings();
|
|
497
|
+
let tabBarVisibility = _.lowerCase(String(nativeWebTapTabBarVisibility));
|
|
498
|
+
let bannerVisibility = _.lowerCase(String(nativeWebTapSmartAppBannerVisibility));
|
|
499
|
+
const tabBarPosition = _.lowerCase(String(safariTabBarPosition));
|
|
500
|
+
|
|
501
|
+
if (!VISIBILITIES.includes(tabBarVisibility)) {
|
|
502
|
+
tabBarVisibility = DETECT;
|
|
503
|
+
}
|
|
504
|
+
if (!VISIBILITIES.includes(bannerVisibility)) {
|
|
505
|
+
bannerVisibility = DETECT;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (!TAB_BAR_POSSITIONS.includes(tabBarPosition)) {
|
|
509
|
+
throw new errors.InvalidArgumentError(
|
|
510
|
+
`${safariTabBarPosition} is invalid as Safari tab bar position. Available positions are ${TAB_BAR_POSSITIONS}.`,
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const isNotched = isIphone && (await this.getSafariIsNotched());
|
|
515
|
+
|
|
516
|
+
const orientation = realDims.h > realDims.w ? 'PORTRAIT' : 'LANDSCAPE';
|
|
517
|
+
|
|
518
|
+
const notchOffset = isNotched
|
|
519
|
+
? util.compareVersions(/** @type {string} */ (this.opts.platformVersion), '=', '13.0')
|
|
520
|
+
? IPHONE_X_NOTCH_OFFSET_IOS_13
|
|
521
|
+
: IPHONE_X_NOTCH_OFFSET_IOS
|
|
522
|
+
: 0;
|
|
523
|
+
|
|
524
|
+
const isScrolled = await this.execute('return document.documentElement.scrollTop > 0');
|
|
525
|
+
if (isScrolled) {
|
|
526
|
+
topOffset = IPHONE_SCROLLED_TOP_BAR_HEIGHT + notchOffset;
|
|
527
|
+
|
|
528
|
+
if (isNotched) {
|
|
529
|
+
topOffset -= IPHONE_X_SCROLLED_OFFSET;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// If the iPhone is landscape then there is no top bar
|
|
533
|
+
if (orientation === 'LANDSCAPE' && isIphone) {
|
|
534
|
+
topOffset = 0;
|
|
535
|
+
}
|
|
536
|
+
} else {
|
|
537
|
+
topOffset = tabBarPosition === TAB_BAR_POSITION_BOTTOM ? 0 : IPHONE_TOP_BAR_HEIGHT;
|
|
538
|
+
topOffset += notchOffset;
|
|
539
|
+
this.log.debug(`tabBarPosition and topOffset: ${tabBarPosition}, ${topOffset}`);
|
|
540
|
+
|
|
541
|
+
if (isIphone) {
|
|
542
|
+
if (orientation === 'PORTRAIT') {
|
|
543
|
+
// The bottom bar is only visible when portrait
|
|
544
|
+
bottomOffset = IPHONE_BOTTOM_BAR_OFFSET;
|
|
545
|
+
} else {
|
|
546
|
+
topOffset = IPHONE_LANDSCAPE_TOP_BAR_HEIGHT;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (orientation === 'LANDSCAPE' || !isIphone) {
|
|
551
|
+
if (tabBarVisibility === VISIBLE) {
|
|
552
|
+
topOffset += TAB_BAR_OFFSET;
|
|
553
|
+
} else if (tabBarVisibility === DETECT) {
|
|
554
|
+
// Tabs only appear if the device is landscape or if it's an iPad so we only check visibility in this case
|
|
555
|
+
// Assume that each tab bar is a WebView
|
|
556
|
+
const contextsAndViews = await this.getContextsAndViews();
|
|
557
|
+
const tabs = contextsAndViews.filter((ctx) => ctx.id.startsWith('WEBVIEW_'));
|
|
558
|
+
|
|
559
|
+
if (tabs.length > 1) {
|
|
560
|
+
this.log.debug(`Found ${tabs.length} tabs. Assuming the tab bar is visible`);
|
|
561
|
+
topOffset += TAB_BAR_OFFSET;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
topOffset += await this.getExtraNativeWebTapOffset(isIphone, bannerVisibility);
|
|
568
|
+
|
|
569
|
+
wvPos.y += topOffset;
|
|
570
|
+
realDims.h -= topOffset + bottomOffset;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* @this {XCUITestDriver}
|
|
575
|
+
* @param {boolean} isIphone
|
|
576
|
+
* @param {string} bannerVisibility
|
|
577
|
+
* @returns {Promise<number>}
|
|
578
|
+
*/
|
|
579
|
+
export async function getExtraNativeWebTapOffset(isIphone, bannerVisibility) {
|
|
580
|
+
let offset = 0;
|
|
581
|
+
|
|
582
|
+
if (bannerVisibility === VISIBLE) {
|
|
583
|
+
offset += isIphone
|
|
584
|
+
? IPHONE_WEB_COORD_SMART_APP_BANNER_OFFSET
|
|
585
|
+
: IPAD_WEB_COORD_SMART_APP_BANNER_OFFSET;
|
|
586
|
+
} else if (bannerVisibility === DETECT) {
|
|
587
|
+
// try to see if there is an Smart App Banner
|
|
588
|
+
const banners = /** @type {import('@appium/types').Element[]} */ (
|
|
589
|
+
await this.findNativeElementOrElements('accessibility id', 'Close app download offer', true)
|
|
590
|
+
);
|
|
591
|
+
if (banners?.length) {
|
|
592
|
+
offset += isIphone
|
|
593
|
+
? IPHONE_WEB_COORD_SMART_APP_BANNER_OFFSET
|
|
594
|
+
: IPAD_WEB_COORD_SMART_APP_BANNER_OFFSET;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
this.log.debug(`Additional native web tap offset computed: ${offset}`);
|
|
599
|
+
return offset;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* @this {XCUITestDriver}
|
|
604
|
+
* @param {any} el
|
|
605
|
+
* @returns {Promise<void>}
|
|
606
|
+
*/
|
|
607
|
+
export async function nativeWebTap(el) {
|
|
608
|
+
const atomsElement = this.getAtomsElement(el);
|
|
609
|
+
|
|
610
|
+
// if strict native tap, do not try to do it with WDA directly
|
|
611
|
+
if (
|
|
612
|
+
!(this.settings.getSettings()).nativeWebTapStrict &&
|
|
613
|
+
(await tapWebElementNatively.bind(this)(atomsElement))
|
|
614
|
+
) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
this.log.warn('Unable to do simple native web tap. Attempting to convert coordinates');
|
|
618
|
+
|
|
619
|
+
const [size, coordinates] =
|
|
620
|
+
/** @type {[import('@appium/types').Size, import('@appium/types').Position]} */ (
|
|
621
|
+
await B.Promise.all([
|
|
622
|
+
this.executeAtom('get_size', [atomsElement]),
|
|
623
|
+
this.executeAtom('get_top_left_coordinates', [atomsElement]),
|
|
624
|
+
])
|
|
625
|
+
);
|
|
626
|
+
const {width, height} = size;
|
|
627
|
+
const {x, y} = coordinates;
|
|
628
|
+
await this.clickWebCoords(x + width / 2, y + height / 2);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* @this {XCUITestDriver}
|
|
633
|
+
* @param {number} x
|
|
634
|
+
* @param {number} y
|
|
635
|
+
* @returns {Promise<import('@appium/types').Position>}
|
|
636
|
+
*/
|
|
637
|
+
export async function translateWebCoords(x, y) {
|
|
638
|
+
this.log.debug(`Translating web coordinates (${JSON.stringify({x, y})}) to native coordinates`);
|
|
639
|
+
|
|
640
|
+
if (this.webviewCalibrationResult) {
|
|
641
|
+
this.log.debug(`Will use the recent calibration result: ${JSON.stringify(this.webviewCalibrationResult)}`);
|
|
642
|
+
const { offsetX, offsetY, pixelRatioX, pixelRatioY } = this.webviewCalibrationResult;
|
|
643
|
+
const cmd = '(function () {return {innerWidth: window.innerWidth, innerHeight: window.innerHeight, ' +
|
|
644
|
+
'outerWidth: window.outerWidth, outerHeight: window.outerHeight}; })()';
|
|
645
|
+
const wvDims = await (/** @type {RemoteDebugger} */ (this.remote)).execute(cmd);
|
|
646
|
+
// https://tripleodeon.com/2011/12/first-understand-your-screen/
|
|
647
|
+
const shouldApplyPixelRatio = wvDims.innerWidth > wvDims.outerWidth
|
|
648
|
+
|| wvDims.innerHeight > wvDims.outerHeight;
|
|
649
|
+
return {
|
|
650
|
+
x: offsetX + x * (shouldApplyPixelRatio ? pixelRatioX : 1),
|
|
651
|
+
y: offsetY + y * (shouldApplyPixelRatio ? pixelRatioY : 1),
|
|
652
|
+
};
|
|
653
|
+
} else {
|
|
654
|
+
this.log.debug(
|
|
655
|
+
`Using the legacy algorithm for coordinates translation. ` +
|
|
656
|
+
`Invoke 'mobile: calibrateWebToRealCoordinatesTranslation' to change that.`
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// absolutize web coords
|
|
661
|
+
/** @type {import('@appium/types').Element|undefined|string} */
|
|
662
|
+
let webview;
|
|
663
|
+
try {
|
|
664
|
+
webview = /** @type {import('@appium/types').Element|undefined} */ (
|
|
665
|
+
await retryInterval(
|
|
666
|
+
5,
|
|
667
|
+
100,
|
|
668
|
+
async () =>
|
|
669
|
+
await this.findNativeElementOrElements('class name', 'XCUIElementTypeWebView', false),
|
|
670
|
+
)
|
|
671
|
+
);
|
|
672
|
+
} catch {}
|
|
673
|
+
|
|
674
|
+
if (!webview) {
|
|
675
|
+
throw new Error(`No WebView found. Unable to translate web coordinates for native web tap.`);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
webview = util.unwrapElement(webview);
|
|
679
|
+
|
|
680
|
+
const rect = /** @type {Rect} */ (await this.proxyCommand(`/element/${webview}/rect`, 'GET'));
|
|
681
|
+
const wvPos = {x: rect.x, y: rect.y};
|
|
682
|
+
const realDims = {w: rect.width, h: rect.height};
|
|
683
|
+
|
|
684
|
+
const cmd = '(function () { return {w: window.innerWidth, h: window.innerHeight}; })()';
|
|
685
|
+
const wvDims = await (/** @type {RemoteDebugger} */ (this.remote)).execute(cmd);
|
|
686
|
+
|
|
687
|
+
// keep track of implicit wait, and set locally to 0
|
|
688
|
+
// https://github.com/appium/appium/issues/14988
|
|
689
|
+
const implicitWaitMs = this.implicitWaitMs;
|
|
690
|
+
this.setImplicitWait(0);
|
|
691
|
+
try {
|
|
692
|
+
await this.getExtraTranslateWebCoordsOffset(wvPos, realDims);
|
|
693
|
+
} finally {
|
|
694
|
+
this.setImplicitWait(implicitWaitMs);
|
|
695
|
+
}
|
|
696
|
+
if (!wvDims || !realDims || !wvPos) {
|
|
697
|
+
throw new Error(
|
|
698
|
+
`Web coordinates ${JSON.stringify({x, y})} cannot be translated into real coordinates. ` +
|
|
699
|
+
`Try to invoke 'mobile: calibrateWebToRealCoordinatesTranslation' or consider translating the ` +
|
|
700
|
+
`coordinates from the client code.`
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
const xRatio = realDims.w / wvDims.w;
|
|
705
|
+
const yRatio = realDims.h / wvDims.h;
|
|
706
|
+
const newCoords = {
|
|
707
|
+
x: wvPos.x + Math.round(xRatio * x),
|
|
708
|
+
y: wvPos.y + Math.round(yRatio * y),
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
// additional logging for coordinates, since it is sometimes broken
|
|
712
|
+
// see https://github.com/appium/appium/issues/9159
|
|
713
|
+
this.log.debug(`Converted coordinates: ${JSON.stringify(newCoords)}`);
|
|
714
|
+
this.log.debug(` rect: ${JSON.stringify(rect)}`);
|
|
715
|
+
this.log.debug(` wvPos: ${JSON.stringify(wvPos)}`);
|
|
716
|
+
this.log.debug(` realDims: ${JSON.stringify(realDims)}`);
|
|
717
|
+
this.log.debug(` wvDims: ${JSON.stringify(wvDims)}`);
|
|
718
|
+
this.log.debug(` xRatio: ${JSON.stringify(xRatio)}`);
|
|
719
|
+
this.log.debug(` yRatio: ${JSON.stringify(yRatio)}`);
|
|
720
|
+
|
|
721
|
+
this.log.debug(
|
|
722
|
+
`Converted web coords ${JSON.stringify({x, y})} into real coords ${JSON.stringify(
|
|
723
|
+
newCoords,
|
|
724
|
+
)}`,
|
|
725
|
+
);
|
|
726
|
+
return newCoords;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* @this {XCUITestDriver}
|
|
731
|
+
* @returns {Promise<boolean>}
|
|
732
|
+
*/
|
|
733
|
+
export async function checkForAlert() {
|
|
734
|
+
return _.isString(await this.getAlertText());
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* @param {Promise<any>} promise
|
|
739
|
+
* @this {XCUITestDriver}
|
|
740
|
+
*/
|
|
741
|
+
export async function waitForAtom(promise) {
|
|
742
|
+
const timer = new timing.Timer().start();
|
|
743
|
+
|
|
744
|
+
const atomWaitTimeoutMs = _.isNumber(this.opts.webviewAtomWaitTimeout) && this.opts.webviewAtomWaitTimeout > 0
|
|
745
|
+
? this.opts.webviewAtomWaitTimeout
|
|
746
|
+
: ATOM_WAIT_TIMEOUT_MS;
|
|
747
|
+
// need to check for alert while the atom is being executed.
|
|
748
|
+
// so notify ourselves when it happens
|
|
749
|
+
const timedAtomPromise = B.resolve(promise).timeout(atomWaitTimeoutMs);
|
|
750
|
+
const handlePromiseError = async (p) => {
|
|
751
|
+
try {
|
|
752
|
+
return await p;
|
|
753
|
+
} catch (err) {
|
|
754
|
+
const originalError = err instanceof AggregateError ? err[0] : err;
|
|
755
|
+
this.log.debug(`Error received while executing atom: ${originalError.message}`);
|
|
756
|
+
throw (
|
|
757
|
+
originalError instanceof TimeoutError
|
|
758
|
+
? (await generateAtomTimeoutError.bind(this)(timer))
|
|
759
|
+
: originalError
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
// if the atom promise is fulfilled within ATOM_INITIAL_WAIT_MS
|
|
764
|
+
// then we don't need to check for an alert presence
|
|
765
|
+
await handlePromiseError(B.any([B.delay(ATOM_INITIAL_WAIT_MS), timedAtomPromise]));
|
|
766
|
+
if (timedAtomPromise.isFulfilled()) {
|
|
767
|
+
return await timedAtomPromise;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// ...otherwise make sure there is no unexpected alert covering the element
|
|
771
|
+
this._waitingAtoms.count++;
|
|
772
|
+
|
|
773
|
+
let onAlertCallback;
|
|
774
|
+
let onAppCrashCallback;
|
|
775
|
+
try {
|
|
776
|
+
// only restart the monitor if it is not running already
|
|
777
|
+
if (this._waitingAtoms.alertMonitor.isResolved()) {
|
|
778
|
+
this._waitingAtoms.alertMonitor = B.resolve(
|
|
779
|
+
(async () => {
|
|
780
|
+
while (this._waitingAtoms.count > 0) {
|
|
781
|
+
try {
|
|
782
|
+
if (await this.checkForAlert()) {
|
|
783
|
+
this._waitingAtoms.alertNotifier.emit(ON_OBSTRUCTING_ALERT_EVENT);
|
|
784
|
+
}
|
|
785
|
+
} catch (err) {
|
|
786
|
+
if (isErrorType(err, errors.InvalidElementStateError)) {
|
|
787
|
+
this._waitingAtoms.alertNotifier.emit(ON_APP_CRASH_EVENT, err);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
await B.delay(OBSTRUCTING_ALERT_PRESENCE_CHECK_INTERVAL_MS);
|
|
791
|
+
}
|
|
792
|
+
})(),
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
return await new B((resolve, reject) => {
|
|
797
|
+
onAlertCallback = () => reject(new errors.UnexpectedAlertOpenError());
|
|
798
|
+
onAppCrashCallback = reject;
|
|
799
|
+
this._waitingAtoms.alertNotifier.once(ON_OBSTRUCTING_ALERT_EVENT, onAlertCallback);
|
|
800
|
+
this._waitingAtoms.alertNotifier.once(ON_APP_CRASH_EVENT, onAppCrashCallback);
|
|
801
|
+
handlePromiseError(timedAtomPromise)
|
|
802
|
+
.then(resolve)
|
|
803
|
+
.catch(reject);
|
|
804
|
+
});
|
|
805
|
+
} finally {
|
|
806
|
+
if (onAlertCallback) {
|
|
807
|
+
this._waitingAtoms.alertNotifier.removeListener(
|
|
808
|
+
ON_OBSTRUCTING_ALERT_EVENT,
|
|
809
|
+
onAlertCallback,
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
if (onAppCrashCallback) {
|
|
813
|
+
this._waitingAtoms.alertNotifier.removeListener(ON_APP_CRASH_EVENT, onAppCrashCallback);
|
|
814
|
+
}
|
|
815
|
+
this._waitingAtoms.count--;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* @param {string} navType
|
|
821
|
+
* @this {XCUITestDriver}
|
|
822
|
+
*/
|
|
823
|
+
export async function mobileWebNav(navType) {
|
|
824
|
+
(/** @type {RemoteDebugger} */ (this.remote)).allowNavigationWithoutReload = true;
|
|
825
|
+
try {
|
|
826
|
+
await this.executeAtom('execute_script', [`history.${navType}();`, null]);
|
|
827
|
+
} finally {
|
|
828
|
+
(/** @type {RemoteDebugger} */ (this.remote)).allowNavigationWithoutReload = false;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* @this {XCUITestDriver}
|
|
834
|
+
* @returns {string} The base url which could be used to access WDA HTTP endpoints.
|
|
835
|
+
*/
|
|
836
|
+
export function getWdaLocalhostRoot() {
|
|
837
|
+
const remotePort =
|
|
838
|
+
((this.isRealDevice() ? this.opts.wdaRemotePort : null)
|
|
839
|
+
?? this.wda?.url?.port
|
|
840
|
+
?? this.opts.wdaLocalPort)
|
|
841
|
+
|| 8100;
|
|
842
|
+
const remoteIp = this.opts.wdaBindingIP ?? '127.0.0.1';
|
|
843
|
+
return `http://${remoteIp}:${remotePort}`;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Calibrates web to real coordinates translation.
|
|
848
|
+
* This API can only be called from Safari web context.
|
|
849
|
+
* It must load a custom page to the browser, and then restore
|
|
850
|
+
* the original one, so don't call it if you can potentially
|
|
851
|
+
* lose the current web app state.
|
|
852
|
+
* The outcome of this API is then used in nativeWebTap mode.
|
|
853
|
+
* The returned value could also be used to manually transform web coordinates
|
|
854
|
+
* to real devices ones in client scripts.
|
|
855
|
+
*
|
|
856
|
+
* @this {XCUITestDriver}
|
|
857
|
+
* @returns {Promise<import('../types').CalibrationData>}
|
|
858
|
+
*/
|
|
859
|
+
export async function mobileCalibrateWebToRealCoordinatesTranslation() {
|
|
860
|
+
if (!this.isWebContext()) {
|
|
861
|
+
throw new errors.NotImplementedError('This API can only be called from a web context');
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
const currentUrl = await this.getUrl();
|
|
865
|
+
await this.setUrl(`${this.getWdaLocalhostRoot()}/calibrate`);
|
|
866
|
+
const {width, height} = /** @type {import('@appium/types').Rect} */(
|
|
867
|
+
await this.proxyCommand('/window/rect', 'GET')
|
|
868
|
+
);
|
|
869
|
+
const [centerX, centerY] = [width / 2, height / 2];
|
|
870
|
+
const errorPrefix = 'Cannot determine web view coordinates offset. Are you in Safari context?';
|
|
871
|
+
|
|
872
|
+
const performCalibrationTap = async (/** @type {number} */ tapX, /** @type {number} */ tapY) => {
|
|
873
|
+
await this.mobileTap(tapX, tapY);
|
|
874
|
+
/** @type {import('@appium/types').Position} */
|
|
875
|
+
let result;
|
|
876
|
+
try {
|
|
877
|
+
const title = await this.title();
|
|
878
|
+
this.log.debug(JSON.stringify(title));
|
|
879
|
+
result = _.isPlainObject(title) ? title : JSON.parse(title);
|
|
880
|
+
} catch (e) {
|
|
881
|
+
throw new Error(`${errorPrefix} Original error: ${e.message}`);
|
|
882
|
+
}
|
|
883
|
+
const {x, y} = result;
|
|
884
|
+
if (!_.isInteger(x) || !_.isInteger(y)) {
|
|
885
|
+
throw new Error(errorPrefix);
|
|
886
|
+
}
|
|
887
|
+
return result;
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
await retryInterval(
|
|
891
|
+
6,
|
|
892
|
+
500,
|
|
893
|
+
async () => {
|
|
894
|
+
const {x: x0, y: y0} = await performCalibrationTap(
|
|
895
|
+
centerX - CALIBRATION_TAP_DELTA_PX, centerY - CALIBRATION_TAP_DELTA_PX
|
|
896
|
+
);
|
|
897
|
+
const {x: x1, y: y1} = await performCalibrationTap(
|
|
898
|
+
centerX + CALIBRATION_TAP_DELTA_PX, centerY + CALIBRATION_TAP_DELTA_PX
|
|
899
|
+
);
|
|
900
|
+
const pixelRatioX = CALIBRATION_TAP_DELTA_PX * 2 / (x1 - x0);
|
|
901
|
+
const pixelRatioY = CALIBRATION_TAP_DELTA_PX * 2 / (y1 - y0);
|
|
902
|
+
this.webviewCalibrationResult = {
|
|
903
|
+
offsetX: centerX - CALIBRATION_TAP_DELTA_PX - x0 * pixelRatioX,
|
|
904
|
+
offsetY: centerY - CALIBRATION_TAP_DELTA_PX - y0 * pixelRatioY,
|
|
905
|
+
pixelRatioX,
|
|
906
|
+
pixelRatioY,
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
);
|
|
910
|
+
|
|
911
|
+
if (currentUrl) {
|
|
912
|
+
// restore the previous url
|
|
913
|
+
await this.setUrl(currentUrl);
|
|
914
|
+
}
|
|
915
|
+
const result = /** @type {import('../types').CalibrationData} */ (this.webviewCalibrationResult);
|
|
916
|
+
return {
|
|
917
|
+
...result,
|
|
918
|
+
offsetX: Math.round(result.offsetX),
|
|
919
|
+
offsetY: Math.round(result.offsetY),
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* @typedef {Object} SafariOpts
|
|
925
|
+
* @property {object} preferences An object containing Safari settings to be updated.
|
|
926
|
+
* The list of available setting names and their values could be retrieved by
|
|
927
|
+
* changing the corresponding Safari settings in the UI and then inspecting
|
|
928
|
+
* 'Library/Preferences/com.apple.mobilesafari.plist' file inside of
|
|
929
|
+
* com.apple.mobilesafari app container.
|
|
930
|
+
* The full path to the Mobile Safari's container could be retrieved from
|
|
931
|
+
* `xcrun simctl get_app_container <sim_udid> com.apple.mobilesafari data`
|
|
932
|
+
* command output.
|
|
933
|
+
* Use the `xcrun simctl spawn <sim_udid> defaults read <path_to_plist>` command
|
|
934
|
+
* to print the plist content to the Terminal.
|
|
935
|
+
*/
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Updates Mobile Safari preferences on an iOS Simulator
|
|
939
|
+
*
|
|
940
|
+
* @param {import('@appium/types').StringRecord} preferences - An object containing Safari settings to be updated.
|
|
941
|
+
* The list of available setting names and their values can be retrieved by changing the
|
|
942
|
+
* corresponding Safari settings in the UI and then inspecting
|
|
943
|
+
* `Library/Preferences/com.apple.mobilesafari.plist` file inside of the `com.apple.mobilesafari`
|
|
944
|
+
* app container within the simulator filesystem. The full path to Mobile Safari's container can
|
|
945
|
+
* be retrieved by running `xcrun simctl get_app_container <sim_udid> com.apple.mobilesafari
|
|
946
|
+
* data`. Use the `xcrun simctl spawn <sim_udid> defaults read <path_to_plist>` command to print
|
|
947
|
+
* the plist content to the Terminal.
|
|
948
|
+
*
|
|
949
|
+
* @group Simulator Only
|
|
950
|
+
* @returns {Promise<void>}
|
|
951
|
+
* @throws {Error} if run on a real device or if the preferences argument is invalid
|
|
952
|
+
* @this {XCUITestDriver}
|
|
953
|
+
*/
|
|
954
|
+
export async function mobileUpdateSafariPreferences(preferences) {
|
|
955
|
+
if (!this.isSimulator()) {
|
|
956
|
+
throw new Error('This extension is only available for Simulator');
|
|
957
|
+
}
|
|
958
|
+
if (!_.isPlainObject(preferences)) {
|
|
959
|
+
throw new errors.InvalidArgumentError('"preferences" argument must be a valid object');
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
this.log.debug(`About to update Safari preferences: ${JSON.stringify(preferences)}`);
|
|
963
|
+
await /** @type {import('../driver').Simulator} */ (this.device).updateSafariSettings(preferences);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* @this {XCUITestDriver}
|
|
968
|
+
* @param {timing.Timer} timer
|
|
969
|
+
* @returns {Promise<InstanceType<typeof errors.TimeoutError>>}
|
|
970
|
+
*/
|
|
971
|
+
async function generateAtomTimeoutError(timer) {
|
|
972
|
+
let message = (
|
|
973
|
+
`The remote Safari debugger did not respond to the requested ` +
|
|
974
|
+
`command after ${timer.getDuration().asMilliSeconds}ms. `
|
|
975
|
+
);
|
|
976
|
+
message += (await this.remote?.isJavascriptExecutionBlocked()) ? (
|
|
977
|
+
`It appears that JavaScript execution is blocked, ` +
|
|
978
|
+
`which could be caused by either a modal dialog obstructing the current page, ` +
|
|
979
|
+
`or a JavaScript routine monopolizing the event loop.`
|
|
980
|
+
) : (
|
|
981
|
+
`However, the debugger still responds to JavaScript commands, ` +
|
|
982
|
+
`which suggests that the provided atom script is taking too long to execute.`
|
|
983
|
+
);
|
|
984
|
+
if (_.isUndefined(this.opts.webviewAtomWaitTimeout)) {
|
|
985
|
+
message += (
|
|
986
|
+
` You may also consider adjusting the timeout by setting the ` +
|
|
987
|
+
`'webviewAtomWaitTimeout' driver capability.`
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
return new errors.TimeoutError(message);
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* @this {XCUITestDriver}
|
|
995
|
+
* @param {any} atomsElement
|
|
996
|
+
* @returns {Promise<boolean>}
|
|
997
|
+
*/
|
|
998
|
+
async function tapWebElementNatively(atomsElement) {
|
|
999
|
+
// try to get the text of the element, which will be accessible in the
|
|
1000
|
+
// native context
|
|
1001
|
+
try {
|
|
1002
|
+
const [text1, text2] = await B.all([
|
|
1003
|
+
this.executeAtom('get_text', [atomsElement]),
|
|
1004
|
+
this.executeAtom('get_attribute_value', [atomsElement, 'value'])
|
|
1005
|
+
]);
|
|
1006
|
+
const text = text1 || text2;
|
|
1007
|
+
if (!text) {
|
|
1008
|
+
return false;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
const els = await this.findNativeElementOrElements('accessibility id', text, true);
|
|
1012
|
+
if (![1, 2].includes(els.length)) {
|
|
1013
|
+
return false;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
const el = els[0];
|
|
1017
|
+
// use tap because on iOS 11.2 and below `nativeClick` crashes WDA
|
|
1018
|
+
const rect = /** @type {import('@appium/types').Rect} */ (await this.proxyCommand(
|
|
1019
|
+
`/element/${util.unwrapElement(el)}/rect`, 'GET'
|
|
1020
|
+
));
|
|
1021
|
+
if (els.length > 1) {
|
|
1022
|
+
const el2 = els[1];
|
|
1023
|
+
const rect2 = /** @type {import('@appium/types').Rect} */ (await this.proxyCommand(
|
|
1024
|
+
`/element/${util.unwrapElement(el2)}/rect`, 'GET',
|
|
1025
|
+
));
|
|
1026
|
+
|
|
1027
|
+
if (
|
|
1028
|
+
rect.x !== rect2.x || rect.y !== rect2.y
|
|
1029
|
+
|| rect.width !== rect2.width || rect.height !== rect2.height
|
|
1030
|
+
) {
|
|
1031
|
+
// These 2 native elements are not referring to the same web element
|
|
1032
|
+
return false;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
await this.mobileTap(rect.x + rect.width / 2, rect.y + rect.height / 2);
|
|
1036
|
+
return true;
|
|
1037
|
+
} catch (err) {
|
|
1038
|
+
// any failure should fall through and trigger the more elaborate
|
|
1039
|
+
// method of clicking
|
|
1040
|
+
this.log.warn(`Error attempting to click: ${err.message}`);
|
|
1041
|
+
}
|
|
1042
|
+
return false;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* @param {any} id
|
|
1047
|
+
* @returns {boolean}
|
|
1048
|
+
*/
|
|
1049
|
+
function isValidElementIdentifier(id) {
|
|
1050
|
+
if (!_.isString(id) && !_.isNumber(id)) {
|
|
1051
|
+
return false;
|
|
1052
|
+
}
|
|
1053
|
+
if (_.isString(id) && _.isEmpty(id)) {
|
|
1054
|
+
return false;
|
|
1055
|
+
}
|
|
1056
|
+
if (_.isNumber(id) && isNaN(id)) {
|
|
1057
|
+
return false;
|
|
1058
|
+
}
|
|
1059
|
+
return true;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* Creates a JavaScript Cookie
|
|
1064
|
+
*
|
|
1065
|
+
* @param {string} key
|
|
1066
|
+
* @param {string} value
|
|
1067
|
+
* @param {CookieOptions} [options={}]
|
|
1068
|
+
* @returns {string}
|
|
1069
|
+
*/
|
|
1070
|
+
function createJSCookie(key, value, options = {}) {
|
|
1071
|
+
return [
|
|
1072
|
+
encodeURIComponent(key),
|
|
1073
|
+
'=',
|
|
1074
|
+
value,
|
|
1075
|
+
options.expires ? `; expires=${options.expires}` : '',
|
|
1076
|
+
options.path ? `; path=${options.path}` : '',
|
|
1077
|
+
options.domain ? `; domain=${options.domain}` : '',
|
|
1078
|
+
options.secure ? '; secure' : '',
|
|
1079
|
+
].join('');
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* @this {XCUITestDriver}
|
|
1084
|
+
* @param {import('@appium/types').Cookie} cookie
|
|
1085
|
+
* @returns {Promise<any>}
|
|
1086
|
+
*/
|
|
1087
|
+
async function _deleteCookie(cookie) {
|
|
1088
|
+
const url = `http${cookie.secure ? 's' : ''}://${cookie.domain}${cookie.path}`;
|
|
1089
|
+
return await (/** @type {RemoteDebugger} */ (this.remote)).deleteCookie(cookie.name, url);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* @typedef {Object} CookieOptions
|
|
1094
|
+
* @property {string} [expires]
|
|
1095
|
+
* @property {string} [path]
|
|
1096
|
+
* @property {string} [domain]
|
|
1097
|
+
* @property {boolean} [secure]
|
|
1098
|
+
* @property {boolean} [httpOnly]
|
|
1099
|
+
*/
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
1103
|
+
* @typedef {import('@appium/types').Rect} Rect
|
|
1104
|
+
*/
|
|
1105
|
+
|
|
1106
|
+
/**
|
|
1107
|
+
* @template {string} [S=string]
|
|
1108
|
+
* @typedef {import('@appium/types').Element<S>} Element
|
|
1109
|
+
*/
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* @typedef {import('appium-remote-debugger').RemoteDebugger} RemoteDebugger
|
|
1113
|
+
*/
|