Skip to content

Commit 334396e

Browse files
committed
Speed up messages in Headless Mode
1 parent 360d80c commit 334396e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8528,6 +8528,8 @@ def post_message(self, message, duration=None, pause=True, style="info"):
85288528
duration = settings.DEFAULT_MESSAGE_DURATION
85298529
else:
85308530
duration = self.message_duration
8531+
if (self.headless or self.xvfb) and float(duration) > 0.75:
8532+
duration = 0.75
85318533
try:
85328534
js_utils.post_message(self.driver, message, duration, style=style)
85338535
except Exception:
@@ -8562,6 +8564,8 @@ def post_success_message(self, message, duration=None, pause=True):
85628564
duration = settings.DEFAULT_MESSAGE_DURATION
85638565
else:
85648566
duration = self.message_duration
8567+
if (self.headless or self.xvfb) and float(duration) > 0.75:
8568+
duration = 0.75
85658569
try:
85668570
js_utils.post_message(
85678571
self.driver, message, duration, style="success"
@@ -8586,6 +8590,8 @@ def post_error_message(self, message, duration=None, pause=True):
85868590
duration = settings.DEFAULT_MESSAGE_DURATION
85878591
else:
85888592
duration = self.message_duration
8593+
if (self.headless or self.xvfb) and float(duration) > 0.75:
8594+
duration = 0.75
85898595
try:
85908596
js_utils.post_message(
85918597
self.driver, message, duration, style="error"
@@ -10406,13 +10412,23 @@ def __highlight_with_assert_success(
1040610412
time.sleep(0.065)
1040710413

1040810414
def __highlight_with_js_2(self, message, selector, o_bs):
10415+
duration = self.message_duration
10416+
if not duration:
10417+
duration = settings.DEFAULT_MESSAGE_DURATION
10418+
if (self.headless or self.xvfb) and float(duration) > 0.75:
10419+
duration = 0.75
1040910420
js_utils.highlight_with_js_2(
10410-
self.driver, message, selector, o_bs, self.message_duration
10421+
self.driver, message, selector, o_bs, duration
1041110422
)
1041210423

1041310424
def __highlight_with_jquery_2(self, message, selector, o_bs):
10425+
duration = self.message_duration
10426+
if not duration:
10427+
duration = settings.DEFAULT_MESSAGE_DURATION
10428+
if (self.headless or self.xvfb) and float(duration) > 0.75:
10429+
duration = 0.75
1041410430
js_utils.highlight_with_jquery_2(
10415-
self.driver, message, selector, o_bs, self.message_duration
10431+
self.driver, message, selector, o_bs, duration
1041610432
)
1041710433

1041810434
############

0 commit comments

Comments
 (0)