Tag: uitesting

是否有可能使用EarlGrey(iOS UItesting)解除系统警报?

我现在已经开始尝试使用XCUITest几个月的UItesting了一下EarlGrey。 我遇到了无法解除系统警报的经典问题,这很奇怪,因为Google似乎为系统警报(称为grey_systemAlertViewShown())实施了匹配器。 我正在尝试使用GREYCondition检测系统警报。 以下是我所尝试的: – (void)waitForAndDismissSystemAlertForSeconds:(NSInteger)seconds { GREYCondition *interactableCondition = [GREYCondition conditionWithName:@"isInteractable" block:^BOOL{ // Fails if element is not interactable NSError *error; [[EarlGrey selectElementWithMatcher:grey_systemAlertViewShown()] assertWithMatcher:grey_interactable() error:&error]; if (error) { return NO; } else { NSError *allowButtonError; [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Allow")] assertWithMatcher:grey_notNil() error:&allowButtonError]; if (!allowButtonError) { [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Allow")] performAction:grey_tap()]; } return YES; }]; [interactableCondition waitWithTimeout:seconds]; } 我也尝试使用addUIInterruptionMonitorWithDescription(如下所示)(但使用EarlGrey代码基本上是在中断监视器上做的事情): Xcode […]