Is there any way to close notification tray in Android using Appium?


I just want to open the notification and then close it without doing any action on it… Is there any way to do so, through appium?

Don’t suggest ADB commands, since I am running my tests over clouds.

Many thanks!

((AndroidDriver) driver).openNotifications();
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.BACK);

Yes, this worked! I completely forgot about AndroidKeyCode.

You can also use -

androidDriver.pressKey(new KeyEvent(AndroidKey.BACK));

I tried using -

((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.BACK);

but AndroidKeyCode class wasn’t available in the dependencies which I have added.

My dependencies are:

<!-- -->
1 Like