Hi,
In Android appium, i know how to open the notifications screen (driver.openNotifications(); )
Is there is a way to clear all Notifications from screen ?
Thanks !
created
Mar '18
last reply
Jul '18
- 9
replies
- 983
views
- 5
users
Hi,
In Android appium, i know how to open the notifications screen (driver.openNotifications(); )
Is there is a way to clear all Notifications from screen ?
Thanks !
@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);
}
}
@shilpi driver.openNotifications opens Android! notification panel with most of Appium users :-). If it does not work with your case you should more investigate by yourself. Provide your code and Appium server logs. We are not possible to help you without zero knowledge about what device you have, what logs and what code.