- The
NotificationBarclass is used to interact with the notification bar. - In order to get the notification bar for a device, you should use the constructor of the
NotificationBarclass which requires a device as parameter:
NotificationBar notificationBar = new NotificationBar(device);- Now that you have a
NotificationBarinstance, you can use the methods provided in the class. - The methods
open()orclearAllNotifications()do nothing if the notification bar is already opened or the notifications are all cleared respectively, so you do not have to worry about that. - In order to get a single notification, you should use one of the get notification methods provided. You don't have to use these methods with parameters that describe the full size notification, they can be used with parameters that describe a part of the notification and the returned result will be the full size notification as an
UiElement:
UiElement notification = notificationBar.getNotificationByText("Sample");- The notification instance supports some of the regular
UiElementmethods. For example thetap()ortapOnChildElement()methods can be used to tap on a specific button in the notification andpinchIn()orpinchOut()can be used to make the notification bigger or smaller.
Note: The notification bar methods use functionality from
UiAutomatorrequiring API 18 or above, so the notification bar class should be used only on a device with API 18 or higher.