@gilb i do it manually with:
public void clearNotifications(AndroidDriver driver) {
System.out.println(" clearNotifications()");
driver.openNotifications();
nativeNotificationPage = new NativeNotificationPage(driver);
assertTrue("Native notification page is NOT loaded", nativeNotificationPage.isNativeNotificationPage());
if (nativeNotificationPage.isClearAllBtnLoaded()) {
nativeNotificationPage.tapClearAllBtn();
} else {
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.BACK);
sleep(1);
}
System.out.println(" notifications cleared");
}
where Notification Page is (you can take all locators or use it as is):
public class NativeNotificationPage extends Page {
@AndroidFindBy(id= "com.android.systemui:id/notification_panel")
private List<AndroidElement> notificationPanel;
//settings data
@HowToUseLocators(androidAutomation = LocatorGroupStrategy.ALL_POSSIBLE)
@AndroidFindBy(id = "com.android.systemui:id/clear_all_button")
@AndroidFindBy(id = "com.android.systemui:id/dismiss_text")
private List<AndroidElement> clearAllBtn;
public NativeNotificationPage(WebDriver driver) {
super(driver);
}
public boolean isNativeNotificationPage() {
System.out.println(" check 'Notification' Screen loaded");
return !notificationPanel.isEmpty();
}
public boolean isClearAllBtnLoaded() {
return !clearAllBtn.isEmpty();
}
public boolean tapClearAllBtn() {
return tapElementInList_Android(clearAllBtn, 0);
}
}