@@ -1213,22 +1213,78 @@ def activate_messenger(self):
1213
1213
1214
1214
def set_messenger_theme (self , theme = "default" , location = "default" ,
1215
1215
max_messages = "default" ):
1216
+ """ Sets a theme for posting messages.
1217
+ Themes: ["flat", "future", "block", "air", "ice"]
1218
+ Locations: ["top_left", "top_center", "top_right",
1219
+ "bottom_left", "bottom_center", "bottom_right"]
1220
+ max_messages is the limit of concurrent messages to display. """
1221
+ if not theme :
1222
+ theme = "default" # "future"
1223
+ if not location :
1224
+ location = "default" # "bottom_right"
1225
+ if not max_messages :
1226
+ max_messages = "default" # "8"
1216
1227
js_utils .set_messenger_theme (
1217
1228
self .driver , theme = theme ,
1218
1229
location = location , max_messages = max_messages )
1219
1230
1220
- def post_message (self , message , style = "info" , duration = None ):
1231
+ def post_message (self , message , duration = None , pause = True , style = "info" ):
1221
1232
""" Post a message on the screen with Messenger.
1222
1233
Arguments:
1223
1234
message: The message to display.
1235
+ duration: The time until the message vanishes. (Default: 2.55s)
1236
+ pause: If True, the program waits until the message completes.
1224
1237
style: "info", "success", or "error".
1225
- duration: The time until the message vanishes.
1226
1238
1227
1239
You can also post messages by using =>
1228
- self.execute_script('Messenger().post("My Message")') """
1240
+ self.execute_script('Messenger().post("My Message")')
1241
+ """
1242
+ if not duration :
1243
+ if not self .message_duration :
1244
+ duration = settings .DEFAULT_MESSAGE_DURATION
1245
+ else :
1246
+ duration = self .message_duration
1247
+ js_utils .post_message (
1248
+ self .driver , message , duration , style = style )
1249
+ if pause :
1250
+ duration = float (duration ) + 0.15
1251
+ time .sleep (float (duration ))
1252
+
1253
+ def post_success_message (self , message , duration = None , pause = True ):
1254
+ """ Post a success message on the screen with Messenger.
1255
+ Arguments:
1256
+ message: The success message to display.
1257
+ duration: The time until the message vanishes. (Default: 2.55s)
1258
+ pause: If True, the program waits until the message completes.
1259
+ """
1260
+ if not duration :
1261
+ if not self .message_duration :
1262
+ duration = settings .DEFAULT_MESSAGE_DURATION
1263
+ else :
1264
+ duration = self .message_duration
1229
1265
js_utils .post_message (
1230
- self .driver , message , self .message_duration ,
1231
- style = style , duration = duration )
1266
+ self .driver , message , duration , style = "success" )
1267
+ if pause :
1268
+ duration = float (duration ) + 0.15
1269
+ time .sleep (float (duration ))
1270
+
1271
+ def post_error_message (self , message , duration = None , pause = True ):
1272
+ """ Post an error message on the screen with Messenger.
1273
+ Arguments:
1274
+ message: The error message to display.
1275
+ duration: The time until the message vanishes. (Default: 2.55s)
1276
+ pause: If True, the program waits until the message completes.
1277
+ """
1278
+ if not duration :
1279
+ if not self .message_duration :
1280
+ duration = settings .DEFAULT_MESSAGE_DURATION
1281
+ else :
1282
+ duration = self .message_duration
1283
+ js_utils .post_message (
1284
+ self .driver , message , duration , style = "error" )
1285
+ if pause :
1286
+ duration = float (duration ) + 0.15
1287
+ time .sleep (float (duration ))
1232
1288
1233
1289
def get_property_value (self , selector , property , by = By .CSS_SELECTOR ,
1234
1290
timeout = settings .SMALL_TIMEOUT ):
@@ -2618,14 +2674,6 @@ def __scroll_to_element(self, element):
2618
2674
def __slow_scroll_to_element (self , element ):
2619
2675
js_utils .slow_scroll_to_element (self .driver , element , self .browser )
2620
2676
2621
- def __post_messenger_success_message (self , message , duration = None ):
2622
- js_utils .post_messenger_success_message (
2623
- self .driver , message , self .message_duration , duration = duration )
2624
-
2625
- def __post_messenger_error_message (self , message , duration = None ):
2626
- js_utils .post_messenger_error_message (
2627
- self .driver , message , self .message_duration , duration = duration )
2628
-
2629
2677
def __highlight_with_assert_success (
2630
2678
self , message , selector , by = By .CSS_SELECTOR ):
2631
2679
selector , by = self .__recalculate_selector (selector , by )
0 commit comments