Skip to content

Commit 3ee08b3

Browse files
committed
Improve Website-TourMaker reliability
1 parent 2f7d788 commit 3ee08b3

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

seleniumbase/core/tour_helper.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,14 @@ def play_bootstrap_tour(
417417
"return $tour.ended()")
418418
else:
419419
page_actions.wait_for_element_present(
420-
driver, ".tour-tour", by=By.CSS_SELECTOR, timeout=0.4)
420+
driver, ".tour-tour", by=By.CSS_SELECTOR, timeout=0.65)
421421
result = False
422422
except Exception:
423423
tour_on = False
424424
result = None
425425
if result is False:
426426
tour_on = True
427+
time.sleep(0.05)
427428
else:
428429
try:
429430
time.sleep(0.01)
@@ -432,10 +433,10 @@ def play_bootstrap_tour(
432433
"return $tour.ended()")
433434
else:
434435
page_actions.wait_for_element_present(
435-
driver, ".tour-tour", by=By.CSS_SELECTOR, timeout=0.4)
436+
driver, ".tour-tour", by=By.CSS_SELECTOR, timeout=0.65)
436437
result = False
437438
if result is False:
438-
time.sleep(0.1)
439+
time.sleep(0.05)
439440
continue
440441
else:
441442
return
@@ -502,9 +503,9 @@ def play_driverjs_tour(
502503
result = not driver.execute_script(
503504
"return $tour.isActivated")
504505
else:
505-
page_actions.wait_for_element_present(
506+
page_actions.wait_for_element_visible(
506507
driver, "#driver-popover-item",
507-
by=By.CSS_SELECTOR, timeout=0.4)
508+
by=By.CSS_SELECTOR, timeout=1.1)
508509
result = False
509510
except Exception:
510511
tour_on = False
@@ -542,9 +543,9 @@ def play_driverjs_tour(
542543
result = not driver.execute_script(
543544
"return $tour.isActivated")
544545
else:
545-
page_actions.wait_for_element_present(
546+
page_actions.wait_for_element_visible(
546547
driver, "#driver-popover-item",
547-
by=By.CSS_SELECTOR, timeout=0.4)
548+
by=By.CSS_SELECTOR, timeout=1.1)
548549
result = False
549550
if result is False:
550551
time.sleep(0.1)

seleniumbase/fixtures/base_case.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5214,7 +5214,7 @@ def add_tour_step(self, message, selector=None, name=None,
52145214
name - If creating multiple tours at the same time,
52155215
use this to select the tour you wish to add steps to.
52165216
title - Additional header text that appears above the message.
5217-
theme - (NON-Bootstrap Tours ONLY) The styling of the tour step.
5217+
theme - (Shepherd Tours ONLY) The styling of the tour step.
52185218
Choose from "light"/"arrows", "dark", "default", "square",
52195219
and "square-dark". ("arrows" is used if None is selected.)
52205220
alignment - Choose from "top", "bottom", "left", and "right".
@@ -5284,7 +5284,7 @@ def __add_shepherd_tour_step(self, message, selector=None, name=None,
52845284
name - If creating multiple tours at the same time,
52855285
use this to select the tour you wish to add steps to.
52865286
title - Additional header text that appears above the message.
5287-
theme - (NON-Bootstrap Tours ONLY) The styling of the tour step.
5287+
theme - (Shepherd Tours ONLY) The styling of the tour step.
52885288
Choose from "light"/"arrows", "dark", "default", "square",
52895289
and "square-dark". ("arrows" is used if None is selected.)
52905290
alignment - Choose from "top", "bottom", "left", and "right".
@@ -5485,6 +5485,8 @@ def play_tour(self, name=None, interval=0):
54855485
if self.headless:
54865486
return # Tours should not run in headless mode.
54875487

5488+
self.wait_for_ready_state_complete()
5489+
54885490
if not interval:
54895491
interval = 0
54905492
if interval == 0 and self.interval:

seleniumbase/fixtures/js_utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def activate_jquery(driver):
122122
This happens because jQuery is not always defined on web sites. """
123123
try:
124124
# Let's first find out if jQuery is already defined.
125-
driver.execute_script("jQuery('html')")
125+
driver.execute_script("jQuery('html');")
126126
# Since that command worked, jQuery is defined. Let's return.
127127
return
128128
except Exception:
@@ -137,10 +137,16 @@ def activate_jquery(driver):
137137
for x in range(int(settings.MINI_TIMEOUT * 10.0)):
138138
# jQuery needs a small amount of time to activate.
139139
try:
140-
driver.execute_script("jQuery('html')")
140+
driver.execute_script("jQuery('html');")
141141
return
142142
except Exception:
143143
time.sleep(0.1)
144+
try:
145+
driver.execute_script(activate_jquery_script)
146+
time.sleep(0.1)
147+
driver.execute_script("jQuery('head');")
148+
except Exception:
149+
pass
144150
# Since jQuery still isn't activating, give up and raise an exception
145151
raise_unable_to_load_jquery_exception(driver)
146152

0 commit comments

Comments
 (0)