@@ -271,7 +271,8 @@ def __init__(self, driver):
271271
272272 # Notification centre
273273 self .notifications_button = Button (self .driver , accessibility_id = "notifications-button" )
274- self .notifications_unread_badge = BaseElement (self .driver , accessibility_id = "activity-center-unread-count" )
274+ self .notifications_unread_badge = BaseElement (
275+ self .driver , xpath = "//*[@content-desc='activity-center-unread-count']/android.widget.TextView" )
275276 self .open_activity_center_button = Button (self .driver , accessibility_id = "open-activity-center-button" )
276277 self .close_activity_centre = Button (self .driver , accessibility_id = "close-activity-center" )
277278
@@ -375,11 +376,11 @@ def get_element_from_activity_center_view(self, message_body):
375376 chat_element = self .get_activity_center_element_by_text (message_body )
376377 return chat_element
377378
378- def handle_contact_request (self , username : str , action = 'accept' ):
379+ def handle_contact_request (self , username : str , action : str = 'accept' , notifications_count : int = 1 ):
379380 if self .toast_content_element .is_element_displayed (10 ):
380381 self .toast_content_element .wait_for_invisibility_of_element ()
381382 try :
382- self .notifications_unread_badge .wait_for_visibility_of_element ( 120 )
383+ self .notifications_unread_badge .wait_for_element_text ( text = str ( notifications_count ), wait_time = 120 )
383384 except TimeoutException :
384385 pass
385386 self .open_activity_center_button .click_until_presence_of_element (self .close_activity_centre )
@@ -396,7 +397,7 @@ def handle_contact_request(self, username: str, action='accept'):
396397 chat_element .cancel_contact_request ()
397398 else :
398399 self .driver .fail ("Illegal option for CR!" )
399- except NoSuchElementException :
400+ except ( NoSuchElementException , TimeoutException ) :
400401 self .driver .fail ("No contact request received from %s" % username )
401402 finally :
402403 self .close_activity_centre .wait_for_rendering_ended_and_click ()
0 commit comments