Read Push Notification from Notification draw

I need a help to read Push Notification from the Notification draw.

Now I am using ((AndroidDriver) drv).openNotifications(); with time delay of 10 sec After launching the My App.

But while launching the app itself all notification are getting closed or disappearing from the Notification draw. so I need a help to read the Notification text and do some operation like Click, cancel or Go to some app page.

How are you triggering the notification?

The way I do is I first launch the app, trigger the notification from an external service and finally verify the received notification on my test app.

The previous notifications associated with the app clear if you are starting the test from the clean state. So, so try launching the specific notifications “after” you open your app.

Thanku mayu, I have tried it and working fine. :slight_smile:

Is there any other way to verify, in case push notification received before we launching the app. In My test case there are possibility to occurs above explained scenario.

You may want to make sure that Appium does not reinstall the test app when you start your appium test. If you uninstall and reinstall the app, there is no way to check the previously received notifications associated with the test app.

Ya every time I am not installing the App, just I will install Once and Reuse the same app. I hope My below code will be able to get the clear Idea. My Understanding about below code is, I will Just launch the app not going to install the app every run. If I am wrong please correct my understanding.

WebDriver drv;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“deviceName”, “DeviceName”);
capabilities.setCapability(CapabilityType.BROWSER_NAME, “Android”); capabilities.setCapability(CapabilityType.VERSION, “5.1.1”);
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“appPackage”, “MyappAppPackage”);
capabilities.setCapability(“appActivity”, “MyAppActivity”);
drv = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

Ok. Are you able to accomplish what you are trying to do, if you omit tearDown?

Yes I am able to do.