Post an error message on the screen with Messenger. Arguments: message: The error message to display. duration: The time until the message vanishes. (Default: 2.55s) pause: If True, the program waits until the message completes.
(self, message, duration=None, pause=True)
| 10236 | time.sleep(float(duration)) |
| 10237 | |
| 10238 | def post_error_message(self, message, duration=None, pause=True): |
| 10239 | """Post an error message on the screen with Messenger. |
| 10240 | Arguments: |
| 10241 | message: The error message to display. |
| 10242 | duration: The time until the message vanishes. (Default: 2.55s) |
| 10243 | pause: If True, the program waits until the message completes.""" |
| 10244 | self.__check_scope() |
| 10245 | self._check_browser() |
| 10246 | if not duration: |
| 10247 | if not self.message_duration: |
| 10248 | duration = settings.DEFAULT_MESSAGE_DURATION |
| 10249 | else: |
| 10250 | duration = self.message_duration |
| 10251 | if ( |
| 10252 | (self.headless or self.headless2 or self.xvfb) |
| 10253 | and float(duration) > 0.75 |
| 10254 | ): |
| 10255 | duration = 0.75 |
| 10256 | try: |
| 10257 | js_utils.post_message( |
| 10258 | self.driver, message, duration, style="error" |
| 10259 | ) |
| 10260 | except Exception: |
| 10261 | print(" * ERROR message: %s" % message) |
| 10262 | if pause: |
| 10263 | duration = float(duration) + 0.15 |
| 10264 | time.sleep(float(duration)) |
| 10265 | |
| 10266 | ############ |
| 10267 |