appium / WebDriverAgent

A WebDriver server for iOS and tvOS
Other
1.19k stars 371 forks source link

feat: Add a setting to respect system alerts while detecting active apps #907

Closed mykola-mokhnach closed 4 months ago

mykola-mokhnach commented 4 months ago

Currently we detect the app under test as active if XCTest returns RunningInForeground state for it. In case the app is covered by a system alert from springboard this might be confusing as we cannot interact with it unless an alert is properly handled. The new setting called respectSystemAlerts being set to true (by default it is false) forces WDA to verify the presence of alerts shown by springboard and return the latter if an alert is shown. This affects the performance of active app detection, but might be more convenient for writing test script (e.g. eliminates the need of proactive switching between system and custom apps).

mykola-mokhnach commented 4 months ago

Thanks for doing this. From what I can tell this only handles XCUIElementTypeAlert elements, which should cover most cases, but I vaguely recall (from my own projects) that there may be some other element types as well (e.g. picker wheels or file sharing modals). I will check this on Monday/Tuesday, but those can also be handled in a separate PR if necessary.

I don't remember any cases where springboard shows something different from an alert. Please provide examples of the system app page source for such cases.

KazuCocoa commented 4 months ago

I'm also curious about other cases.

So far, I have checked like below share features before. They were not managed by springboard, so the same app scope worked. Default photos, a couple of 3rd party apps. Actually, they could depend on the app implementation so this might not be the all cases.

Screenshot 2024-06-01 at 10 54 29 AM Screenshot 2024-06-01 at 10 56 00 AM

After seeing the comment, I checked some data picker (XCUIElementTypeDatePicker, XCUIElementTypePickerWheel) implementations in a few apps like apple's calender and 3rd party apps I knew of, they worked in their own scope (so not springboard)

Screenshot 2024-06-01 at 11 43 26 AM
eglitise commented 4 months ago

I will check my project on Monday/Tuesday, but I don't think it should block this PR.

github-actions[bot] commented 4 months ago

:tada: This PR is included in version 8.7.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

eglitise commented 4 months ago

Okay, I have checked a bit and found 2 cases where springboard places something other than an alert over the app:

I will have more time to investigate the XMLs tomorrow.

eglitise commented 4 months ago

@mykola-mokhnach here is a gist with XMLs for the two TestFlight screens mentioned above (edited for privacy): https://gist.github.com/eglitise/4704401148fef1db400e8e6be782973b