How to handle push notification?
Posted on April 1, 2019
By Shibu Panda
Code Snippet:
//Here we have Initialized driver as AppiumDriver
driver.findElement(By.id("doc.saulmm.notification:id/simple_notification")).click();
((AndroidDriver) driver).openNotifications();
ListnotificationTitles = driver.findElements(By.id("android:id/title"));
for (WebElement title: notificationTitles) {
String extractTitle = title.getText();
if (extractTitle.contains("I'm a simple notification")) {
driver.findElement(By.id("com.android.systemui:id/clear_notification")).click();
}
}
*** Users can get the apk
from https://github.com/saulmm/Android-Notification-Example