1
- """
2
- This module contains methods for running website tours.
3
- These helper methods SHOULD NOT be called directly from tests.
4
- """
1
+ """This module contains methods for running website tours.
2
+ These helper methods SHOULD NOT be called directly from tests."""
5
3
import os
6
4
import re
7
5
import textwrap
16
14
EXPORTED_TOURS_FOLDER = constants .Tours .EXPORTED_TOURS_FOLDER
17
15
18
16
19
- def activate_bootstrap (driver ):
17
+ def activate_bootstrap (driver , pgkeys = False ):
20
18
"""Allows you to use Bootstrap Tours with SeleniumBase
21
19
http://bootstraptour.com/
22
20
"""
23
21
bootstrap_tour_css = constants .BootstrapTour .MIN_CSS
24
22
bootstrap_tour_js = constants .BootstrapTour .MIN_JS
23
+ if pgkeys :
24
+ bootstrap_tour_js = constants .BootstrapTour .MIN_JS_SB
25
25
26
26
verify_script = """// Verify Bootstrap Tour activated
27
27
var tour2 = new Tour({
@@ -58,19 +58,20 @@ def is_bootstrap_activated(driver):
58
58
return False
59
59
60
60
61
- def activate_driverjs (driver ):
61
+ def activate_driverjs (driver , pgkeys = False ):
62
62
"""Allows you to use DriverJS Tours with SeleniumBase
63
63
https://kamranahmed.info/driver.js/
64
64
"""
65
65
backdrop_style = style_sheet .get_dt_backdrop_style ()
66
66
driverjs_css = constants .DriverJS .MIN_CSS
67
67
driverjs_js = constants .DriverJS .MIN_JS
68
+ if pgkeys :
69
+ driverjs_js = constants .DriverJS .MIN_JS_SB
68
70
69
71
verify_script = """// Verify DriverJS activated
70
72
var driverjs2 = Driver.name;
71
73
"""
72
74
73
- activate_bootstrap (driver )
74
75
js_utils .wait_for_ready_state_complete (driver )
75
76
js_utils .wait_for_angularjs (driver )
76
77
js_utils .add_css_style (driver , backdrop_style )
@@ -115,7 +116,6 @@ def activate_hopscotch(driver):
115
116
var hops = hopscotch.isActive;
116
117
"""
117
118
118
- activate_bootstrap (driver )
119
119
js_utils .wait_for_ready_state_complete (driver )
120
120
js_utils .wait_for_angularjs (driver )
121
121
js_utils .add_css_style (driver , backdrop_style )
@@ -148,12 +148,14 @@ def is_hopscotch_activated(driver):
148
148
return False
149
149
150
150
151
- def activate_introjs (driver ):
151
+ def activate_introjs (driver , pgkeys = False ):
152
152
"""Allows you to use IntroJS Tours with SeleniumBase
153
153
https://introjs.com/
154
154
"""
155
155
intro_css = constants .IntroJS .MIN_CSS
156
156
intro_js = constants .IntroJS .MIN_JS
157
+ if pgkeys :
158
+ intro_js = constants .IntroJS .MIN_JS_SB
157
159
158
160
theme_color = sb_config .introjs_theme_color
159
161
hover_color = sb_config .introjs_hover_color
@@ -169,7 +171,6 @@ def activate_introjs(driver):
169
171
var intro2 = introJs();
170
172
"""
171
173
172
- activate_bootstrap (driver )
173
174
js_utils .wait_for_ready_state_complete (driver )
174
175
js_utils .wait_for_angularjs (driver )
175
176
js_utils .add_css_style (driver , backdrop_style )
@@ -218,7 +219,6 @@ def activate_shepherd(driver):
218
219
sh_style = style_sheet .get_sh_style_test ()
219
220
backdrop_style = style_sheet .get_sh_backdrop_style ()
220
221
221
- activate_bootstrap (driver )
222
222
js_utils .wait_for_ready_state_complete (driver )
223
223
js_utils .wait_for_angularjs (driver )
224
224
js_utils .add_css_style (driver , backdrop_style )
@@ -389,7 +389,13 @@ def play_shepherd_tour(driver, tour_steps, msg_dur, name=None, interval=0):
389
389
390
390
391
391
def play_bootstrap_tour (
392
- driver , tour_steps , browser , msg_dur , name = None , interval = 0
392
+ driver ,
393
+ tour_steps ,
394
+ browser ,
395
+ msg_dur ,
396
+ name = None ,
397
+ interval = 0 ,
398
+ pgkeys = False ,
393
399
):
394
400
"""Plays a Bootstrap tour on the current website."""
395
401
instructions = ""
@@ -414,7 +420,7 @@ def play_bootstrap_tour(
414
420
)
415
421
416
422
if not is_bootstrap_activated (driver ):
417
- activate_bootstrap (driver )
423
+ activate_bootstrap (driver , pgkeys )
418
424
419
425
if len (tour_steps [name ]) > 1 :
420
426
try :
@@ -444,14 +450,24 @@ def play_bootstrap_tour(
444
450
445
451
driver .execute_script (instructions )
446
452
tour_on = True
453
+ try :
454
+ page_actions .wait_for_element_visible (
455
+ driver , ".tour-tour" , by = "css selector" , timeout = 1.2
456
+ )
457
+ except Exception :
458
+ pass
459
+ try :
460
+ driver .execute_script ('document.activeElement.blur();' )
461
+ except Exception :
462
+ pass
447
463
while tour_on :
448
464
try :
449
465
time .sleep (0.01 )
450
466
if browser != "firefox" :
451
467
result = driver .execute_script ("return $tour.ended()" )
452
468
else :
453
469
page_actions .wait_for_element_present (
454
- driver , ".tour-tour" , by = "css selector" , timeout = 0.65
470
+ driver , ".tour-tour" , by = "css selector" , timeout = 0.48
455
471
)
456
472
result = False
457
473
except Exception :
@@ -467,7 +483,7 @@ def play_bootstrap_tour(
467
483
result = driver .execute_script ("return $tour.ended()" )
468
484
else :
469
485
page_actions .wait_for_element_present (
470
- driver , ".tour-tour" , by = "css selector" , timeout = 0.65
486
+ driver , ".tour-tour" , by = "css selector" , timeout = 0.48
471
487
)
472
488
result = False
473
489
if result is False :
@@ -481,7 +497,13 @@ def play_bootstrap_tour(
481
497
482
498
483
499
def play_driverjs_tour (
484
- driver , tour_steps , browser , msg_dur , name = None , interval = 0
500
+ driver ,
501
+ tour_steps ,
502
+ browser ,
503
+ msg_dur ,
504
+ name = None ,
505
+ interval = 0 ,
506
+ pgkeys = False ,
485
507
):
486
508
"""Plays a DriverJS tour on the current website."""
487
509
instructions = ""
@@ -500,7 +522,7 @@ def play_driverjs_tour(
500
522
interval = 0.5
501
523
502
524
if not is_driverjs_activated (driver ):
503
- activate_driverjs (driver )
525
+ activate_driverjs (driver , pgkeys )
504
526
505
527
if len (tour_steps [name ]) > 1 :
506
528
try :
@@ -727,7 +749,13 @@ def play_hopscotch_tour(
727
749
728
750
729
751
def play_introjs_tour (
730
- driver , tour_steps , browser , msg_dur , name = None , interval = 0
752
+ driver ,
753
+ tour_steps ,
754
+ browser ,
755
+ msg_dur ,
756
+ name = None ,
757
+ interval = 0 ,
758
+ pgkeys = False ,
731
759
):
732
760
"""Plays an IntroJS tour on the current website."""
733
761
instructions = ""
@@ -759,7 +787,7 @@ def play_introjs_tour(
759
787
interval = 0.5
760
788
761
789
if not is_introjs_activated (driver ):
762
- activate_introjs (driver )
790
+ activate_introjs (driver , pgkeys )
763
791
764
792
if len (tour_steps [name ]) > 1 :
765
793
try :
0 commit comments