iOS Push-уведомления UITesting - PullRequest
0 голосов
/ 23 октября 2018

Я создаю тесты автоматизации и тестирую их на нескольких устройствах.У меня проблема при тестировании на iOS 10.

В моих тестах я отправляю Push-уведомление.Он корректно отображается на устройствах.

Я жду существования этого нажатия следующим образом:

    XCUIElement *push = [XCUIElement pushNotificationWithTitle:message.title message:message.body];

if (![push waitForExistenceWithTimeout:30]) {
    XCTFail(@"Push not visible");
}

Моя проблема в том, что мои методы "waitForExistenceWithTimeout" всегда возвращают false на iOS 10 и прекрасноработает на iOS 11.

Почему?

Редактировать : Вот моя реализация pushNotificationWithTitle:

+ (XCUIElement *)pushNotificationWithAppName:(NSString *)appName receptionDate:(NSString *)receptionDate title:(NSString *)title message:(NSString *)message {
XCUIApplication *springboard = [XCUIApplication springboardApp];

XCUIElementQuery *elementQuery = [springboard.otherElements matchingIdentifier:@"NotificationShortLookView"];
return elementQuery[[NSString stringWithFormat:@"%@, %@, %@, %@", appName, receptionDate, title, message]];}

и

+ (XCUIElement *)pushNotificationWithTitle:(NSString *)title message:(NSString *)message {
return [self pushNotificationWithAppName:APP_NAME receptionDate:[XCUILocalizationHelpers localizedStringForKey:@"NOTIFICATION_BANNER_DATE_RECEPTION_TITLE"] title:title message:message];}

Редактировать 2: Вот трамплинApp:

+ (XCUIApplication *)springboardApp {
return [[XCUIApplication alloc] initWithBundleIdentifier:@"com.apple.springboard"];}
...