@@ -886,7 +886,7 @@ def post_message(self, message, style="info", duration=None):
886
886
duration = self .message_duration
887
887
messenger_script = ('''Messenger().post({message: "%s", type: "%s", '''
888
888
'''hideAfter: %s, hideOnNavigate: true});'''
889
- % (message , style , duration ))
889
+ % (re . escape ( message ) , style , duration ))
890
890
try :
891
891
self .execute_script (messenger_script )
892
892
except Exception :
@@ -2181,15 +2181,27 @@ def _slow_scroll_to_element(self, element):
2181
2181
# Add small recovery time for long-distance slow-scrolling
2182
2182
time .sleep (0.162 )
2183
2183
2184
- def _post_messenger_success_message (self , message , duration = None ):
2184
+ def __post_messenger_success_message (self , message , duration = None ):
2185
2185
if not duration :
2186
2186
if not self .message_duration :
2187
2187
duration = settings .DEFAULT_MESSAGE_DURATION
2188
2188
else :
2189
2189
duration = self .message_duration
2190
2190
try :
2191
- self .post_message (
2192
- re .escape (message ), style = "success" , duration = duration )
2191
+ self .post_message (message , style = "success" , duration = duration )
2192
+ time .sleep (duration )
2193
+ except Exception :
2194
+ pass
2195
+
2196
+ def __post_messenger_error_message (self , message , duration = None ):
2197
+ if not duration :
2198
+ if not self .message_duration :
2199
+ duration = settings .DEFAULT_MESSAGE_DURATION
2200
+ else :
2201
+ duration = self .message_duration
2202
+ try :
2203
+ self .set_messenger_theme (theme = "block" , location = "top_center" )
2204
+ self .post_message (message , style = "error" , duration = duration )
2193
2205
time .sleep (duration )
2194
2206
except Exception :
2195
2207
pass
@@ -2253,7 +2265,7 @@ def __highlight_with_js_2(self, message, selector, o_bs):
2253
2265
self .execute_script (script )
2254
2266
time .sleep (0.0181 )
2255
2267
2256
- self ._post_messenger_success_message (message )
2268
+ self .__post_messenger_success_message (message )
2257
2269
2258
2270
script = ("""document.querySelector('%s').style =
2259
2271
'box-shadow: %s';"""
@@ -2282,7 +2294,7 @@ def __highlight_with_jquery_2(self, message, selector, o_bs):
2282
2294
self .execute_script (script )
2283
2295
time .sleep (0.0181 )
2284
2296
2285
- self ._post_messenger_success_message (message )
2297
+ self .__post_messenger_success_message (message )
2286
2298
2287
2299
script = """jQuery('%s').css('box-shadow', '%s');""" % (selector , o_bs )
2288
2300
self .execute_script (script )
0 commit comments