Post a message on the screen with Messenger. Arguments: message: The message to display. duration: The time until the message vanishes. (Default: 2.55s) pause: If True, the program waits until the message completes. style: "info", "success", or
(self, message, duration=None, pause=True, style="info")
| 10166 | ) |
| 10167 | |
| 10168 | def post_message(self, message, duration=None, pause=True, style="info"): |
| 10169 | """Post a message on the screen with Messenger. |
| 10170 | Arguments: |
| 10171 | message: The message to display. |
| 10172 | duration: The time until the message vanishes. (Default: 2.55s) |
| 10173 | pause: If True, the program waits until the message completes. |
| 10174 | style: "info", "success", or "error". |
| 10175 | |
| 10176 | You can also post messages by using => |
| 10177 | self.execute_script('Messenger().post("My Message")') """ |
| 10178 | self.__check_scope() |
| 10179 | if not self.__is_cdp_swap_needed(): |
| 10180 | self._check_browser() |
| 10181 | if style not in ["info", "success", "error"]: |
| 10182 | style = "info" |
| 10183 | if not duration: |
| 10184 | if not self.message_duration: |
| 10185 | duration = settings.DEFAULT_MESSAGE_DURATION |
| 10186 | else: |
| 10187 | duration = self.message_duration |
| 10188 | if ( |
| 10189 | (self.headless or self.headless2 or self.xvfb) |
| 10190 | and float(duration) > 0.75 |
| 10191 | ): |
| 10192 | duration = 0.75 |
| 10193 | try: |
| 10194 | js_utils.post_message(self.driver, message, duration, style=style) |
| 10195 | except Exception: |
| 10196 | print(" * %s message: %s" % (style.upper(), message)) |
| 10197 | if pause: |
| 10198 | duration = float(duration) + 0.15 |
| 10199 | time.sleep(float(duration)) |
| 10200 | |
| 10201 | def post_message_and_highlight(self, message, selector, by="css selector"): |
| 10202 | """Post a message on the screen and highlight an element. |
no test coverage detected