Open dostrander opened 4 years ago
Hi @dostrander! Did you have a chance to look into this issue?
I had a quick look at it yesterday, but the only other way I know of to access alerts is through XCUIApplication
which is only available in a UI Test Target. But KIF is using a Unit Test Target to drive the UI.
@pquillere I have not unfortunately. Hopefully going to have time in the coming weeks. Might have to think of another way to go about this.
If we can't find a way we may have to deprecate clicking on system alerts and resort to exposing a suppression of the system alerts rather than a mechanism to click on them. Open to suggestions on this!
KIF uses the unit test framework by design. As long as I’ve used KIF we have not ever been able to interact with system prompts. If the UI test framework can, then I wonder if we can utilize the API there without compromising KIF?
Sent from my iPhone
On Sep 15, 2020, at 1:59 PM, Pierre-Jean Quilleré notifications@github.com wrote:
Hi @dostrander! Did you have a chance to look into this issue?
I had a quick look at it yesterday, but the only other way I know of to access alerts is through XCUIApplication which is only available in a UI Test Target. But KIF is using a Unit Test Target to drive the UI.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
@mikelupo We've been able to use it for the push notification authorization alert. That would only work on a simulator though. What work around have you been using to interact with system alerts during UI testing?
@dostrander How would the "suppression of the system alerts" work?
Yes, a simulator does not have system UI barriers like an actual device does. Sorry I was not specific about that. I have always tested on a farm of real hardware. Never tested on simulators as the desktop on corporate machines, even in our labs, are required to be locked out.
Sent from my iPhone
On Sep 15, 2020, at 5:02 PM, Pierre-Jean Quilleré notifications@github.com wrote:
@mikelupo We've been able to use it for the push notification authorization alert. That would only work on a simulator though. What work around have you been using to interact with system alerts during UI testing?
@dostrander How would the "suppression of the system alerts" work?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
@pquillere To possibly swizzle the asking of permissions of system alerts to automatically give the permission. Need to look into it more
Running -[SystemAlertTests testAuthorizingLocationServicesAndNotificationsScheduling]
make 100% cpu due to this loop:
UIATarget *target = nil;
while (!target) {
@try {
target = [self target];
}
@catch (NSException *exception) { }
@finally { }
}
as [self target]
is:
- (UIATarget *)target {
return [NSClassFromString(@"UIATarget") localTarget];
}
Because class UIATarget doesn't exists as UIAutomation framework not available on iOS 14
From what I looked at, after viewing APIs offered for UI Tests (https://developer.apple.com/documentation/xctest/xctestcase/handling_ui_interruptions)
Your app performs an action that causes the operating system to present a modal UI. An example is an action that presents a photo picker, which may make the system request access to photos if the user hasn’t already granted it.
is coded in XCTest framework, so I tried to use it:
[self addUIInterruptionMonitorWithDescription:@"somedesc" handler:^BOOL(XCUIElement * _Nonnull interruptingElement) {
NSLog(@"UIInterruptionMonitor : %@", interruptingElement);
return false;
}];
But the handler never gets executed
As it works on UI Test bundle
, not Unit Test
one, I think it is related to how the UI tested app is launched (and you can launch your app multiple times per test)
Any news or ideas on how to solve this issue?
I have used https://github.com/wix/AppleSimulatorUtils in Test Pre-Action as WorkAround
Any news on this issue ? Until now I was using XCUI to dismiss the system alerts, But I started running the tests on firebase testlab and the app gets stuck on the alert sometimes.
AFAIK firebase uses real devices which you may be hitting this: https://github.com/kif-framework/KIF/issues/1156#issuecomment-693003450
However, i have not been able to look into this issue yet. It is likely going to require some reverse engineering into what XCUI does to dismiss alerts
Thank you @dostrander . Looking forward to this. Currently we are running KIF on firebase using flank.
Also, Im curious how others run KIF tests.
It would be super useful for us to learn about what others follow because the only issue with running them on firebase is that its run on real device and we can't close the alerts.
@sai-kishore-swaminathan I'm moving my tests over to the same setup (KIF on firebase with Flank). Also being hit by failures with permissions alerts. Were you able to resolve this?
Hey @evandorn essentially no we can't do this from KIF right this second. However if we can resolve https://github.com/kif-framework/KIF/issues/1267 and https://github.com/kif-framework/KIF/issues/1266 we should be also able to get this to work again.
These dialogs (along with the other issues) are out of process and since we are an in process test we can't access them currently. We need to do some reverse engineering on how XCUI works and see if we can mimic that behavior using private APIs. Once we do that I think we will be able to resolve these types of issues 🤞
In Xcode12 it seems that UIAutomation has been removed which is the mechanism we use to click on system alerts.
We need to look into another mechanism to click on system alerts in Xcode12.