@@ -121,20 +121,30 @@ def test_community_mute_community_and_channel(self):
121
121
self .home .mute_chat_long_press (chat_name = self .community_name , mute_period = "mute-for-1-hour" , community = True )
122
122
device_time = self .home .driver .device_time
123
123
current_time = datetime .datetime .strptime (device_time , "%Y-%m-%dT%H:%M:%S%z" )
124
- expected_time = current_time + datetime .timedelta (hours = 1 )
125
- expected_text = "Muted until %s %s" % (
126
- expected_time .strftime ('%H:%M' ),
127
- "today" if current_time . hour < 23 else "tomorrow"
128
- )
124
+ expected_times = [ current_time + datetime .timedelta (minutes = i ) for i in range ( 59 , 62 )]
125
+ expected_texts = [ "Muted until %s %s" % (
126
+ exp_time .strftime ('%H:%M' ), "today" if current_time . hour < 23 else "tomorrow"
127
+ ) for exp_time in expected_times ]
128
+
129
129
self .home .get_chat (self .community_name , community = True ).long_press_element ()
130
- if not self .home .element_by_text (expected_text ).is_element_displayed ():
131
- self .errors .append ("Text '%s' is not shown for muted community" % expected_text )
130
+ self .home .unmute_community_button .wait_for_visibility_of_element ()
131
+ try :
132
+ current_text = self .home .unmute_community_button .unmute_caption_text
133
+ if current_text not in expected_texts :
134
+ self .errors .append ("Text '%s' is not shown for muted community" % expected_texts [1 ])
135
+ except NoSuchElementException :
136
+ self .errors .append ("Caption with text 'Muted until...' is not shown for muted community" )
132
137
self .home .click_system_back_button ()
133
138
134
139
self .home .get_chat (self .community_name , community = True ).click ()
135
140
self .community_view .get_channel (self .channel_name ).long_press_element ()
136
- if not self .home .element_by_text (expected_text ).is_element_displayed ():
137
- self .errors .append ("Text '%s' is not shown for a channel in muted community" % expected_text )
141
+ self .home .mute_channel_button .wait_for_visibility_of_element ()
142
+ try :
143
+ current_text = self .home .mute_channel_button .unmute_caption_text
144
+ if current_text not in expected_texts :
145
+ self .errors .append ("Text '%s' is not shown for a channel in muted community" % expected_texts [1 ])
146
+ except NoSuchElementException :
147
+ self .errors .append ("Caption with text 'Muted until...' is not shown for a channel in muted community" )
138
148
139
149
self .home .just_fyi ("Unmute channel and check that the community is also unmuted" )
140
150
self .home .mute_channel_button .click ()
@@ -154,8 +164,13 @@ def test_community_mute_community_and_channel(self):
154
164
expected_time = current_time + datetime .timedelta (days = 7 )
155
165
expected_text = "Muted until %s" % expected_time .strftime ('%H:%M %a %-d %b' )
156
166
self .community_view .get_channel (self .channel_name ).long_press_element ()
157
- if not self .home .element_by_text (expected_text ).is_element_displayed ():
158
- self .errors .append ("Text '%s' is not shown for a muted community channel" % expected_text )
167
+ self .home .mute_channel_button .wait_for_visibility_of_element ()
168
+ try :
169
+ current_text = self .home .mute_channel_button .unmute_caption_text
170
+ if current_text != expected_text :
171
+ self .errors .append ("Text '%s' is not shown for a muted community channel" % expected_text )
172
+ except NoSuchElementException :
173
+ self .errors .append ("Caption with text '%s' is not shown for a muted community channel" % expected_text )
159
174
self .home .click_system_back_button ()
160
175
self .home .navigate_back_to_home_view ()
161
176
self .home .communities_tab .click ()
0 commit comments