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 < WebElement > ) driver).openNotifications(); List < WebElement > notificationTitles = 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