@@ -1213,22 +1213,78 @@ def activate_messenger(self):
12131213
12141214 def set_messenger_theme (self , theme = "default" , location = "default" ,
12151215 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"
12161227 js_utils .set_messenger_theme (
12171228 self .driver , theme = theme ,
12181229 location = location , max_messages = max_messages )
12191230
1220- def post_message (self , message , style = "info" , duration = None ):
1231+ def post_message (self , message , duration = None , pause = True , style = "info" ):
12211232 """ Post a message on the screen with Messenger.
12221233 Arguments:
12231234 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.
12241237 style: "info", "success", or "error".
1225- duration: The time until the message vanishes.
12261238
12271239 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
12291265 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 ))
12321288
12331289 def get_property_value (self , selector , property , by = By .CSS_SELECTOR ,
12341290 timeout = settings .SMALL_TIMEOUT ):
@@ -2618,14 +2674,6 @@ def __scroll_to_element(self, element):
26182674 def __slow_scroll_to_element (self , element ):
26192675 js_utils .slow_scroll_to_element (self .driver , element , self .browser )
26202676
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-
26292677 def __highlight_with_assert_success (
26302678 self , message , selector , by = By .CSS_SELECTOR ):
26312679 selector , by = self .__recalculate_selector (selector , by )
0 commit comments