How to handle push notification? – pCloudy – Question and Answers
Home >> Appium Tricks and Tricks >> How to handle push notification? ...

How to handle push notification?


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

Leave a Reply

Your email address will not be published. Required fields are marked *