1414EXPORTED_TOURS_FOLDER = constants .Tours .EXPORTED_TOURS_FOLDER
1515
1616
17- def activate_bootstrap (driver , pgkeys = False ):
17+ def activate_bootstrap (driver ):
1818 """Allows you to use Bootstrap Tours with SeleniumBase
1919 http://bootstraptour.com/
2020 """
2121 bootstrap_tour_css = constants .BootstrapTour .MIN_CSS
2222 bootstrap_tour_js = constants .BootstrapTour .MIN_JS
23- if pgkeys :
24- bootstrap_tour_js = constants .BootstrapTour .MIN_JS_SB
2523
2624 verify_script = """// Verify Bootstrap Tour activated
2725 var tour2 = new Tour({
@@ -58,15 +56,13 @@ def is_bootstrap_activated(driver):
5856 return False
5957
6058
61- def activate_driverjs (driver , pgkeys = False ):
59+ def activate_driverjs (driver ):
6260 """Allows you to use DriverJS Tours with SeleniumBase
6361 https://kamranahmed.info/driver.js/
6462 """
6563 backdrop_style = style_sheet .get_dt_backdrop_style ()
6664 driverjs_css = constants .DriverJS .MIN_CSS
6765 driverjs_js = constants .DriverJS .MIN_JS
68- if pgkeys :
69- driverjs_js = constants .DriverJS .MIN_JS_SB
7066
7167 verify_script = """// Verify DriverJS activated
7268 var driverjs2 = Driver.name;
@@ -148,14 +144,12 @@ def is_hopscotch_activated(driver):
148144 return False
149145
150146
151- def activate_introjs (driver , pgkeys = False ):
147+ def activate_introjs (driver ):
152148 """Allows you to use IntroJS Tours with SeleniumBase
153149 https://introjs.com/
154150 """
155151 intro_css = constants .IntroJS .MIN_CSS
156152 intro_js = constants .IntroJS .MIN_JS
157- if pgkeys :
158- intro_js = constants .IntroJS .MIN_JS_SB
159153
160154 theme_color = sb_config .introjs_theme_color
161155 hover_color = sb_config .introjs_hover_color
@@ -269,6 +263,13 @@ def play_shepherd_tour(driver, tour_steps, msg_dur, name=None, interval=0):
269263 // Start the tour
270264 tour.start();
271265 $tour = tour;"""
266+ instructions += """
267+ document.body.addEventListener('keyup', function (event) {
268+ if (event.key === 'PageUp' || event.key === 'ArrowLeft') {
269+ Shepherd.activeTour.back(); }
270+ if (event.key === 'PageDown' || event.key === 'ArrowRight') {
271+ Shepherd.activeTour.next(); }
272+ })"""
272273 autoplay = False
273274 if interval and interval > 0 :
274275 autoplay = True
@@ -302,6 +303,16 @@ def play_shepherd_tour(driver, tour_steps, msg_dur, name=None, interval=0):
302303 "" % selector
303304 )
304305 driver .execute_script (instructions )
306+ try :
307+ page_actions .wait_for_element_visible (
308+ driver , "a.tour-button-right" , by = "css selector" , timeout = 1.2
309+ )
310+ except Exception :
311+ pass
312+ try :
313+ driver .execute_script ('document.activeElement.blur();' )
314+ except Exception :
315+ pass
305316 tour_on = True
306317 if autoplay :
307318 start_ms = time .time () * 1000.0
@@ -389,13 +400,7 @@ def play_shepherd_tour(driver, tour_steps, msg_dur, name=None, interval=0):
389400
390401
391402def play_bootstrap_tour (
392- driver ,
393- tour_steps ,
394- browser ,
395- msg_dur ,
396- name = None ,
397- interval = 0 ,
398- pgkeys = False ,
403+ driver , tour_steps , browser , msg_dur , name = None , interval = 0
399404):
400405 """Plays a Bootstrap tour on the current website."""
401406 instructions = ""
@@ -410,18 +415,15 @@ def play_bootstrap_tour(
410415 tour.restart();
411416 // Save for later
412417 $tour = tour;"""
413-
414418 if interval and interval > 0 :
415419 if interval < 1 :
416420 interval = 1
417421 interval = str (float (interval ) * 1000.0 )
418422 instructions = instructions .replace (
419423 "duration: 0," , "duration: %s," % interval
420424 )
421-
422425 if not is_bootstrap_activated (driver ):
423- activate_bootstrap (driver , pgkeys )
424-
426+ activate_bootstrap (driver )
425427 if len (tour_steps [name ]) > 1 :
426428 try :
427429 if "element: " in tour_steps [name ][1 ]:
@@ -447,7 +449,6 @@ def play_bootstrap_tour(
447449 "Exiting due to failure on first tour step!"
448450 "" % selector
449451 )
450-
451452 driver .execute_script (instructions )
452453 tour_on = True
453454 try :
@@ -497,13 +498,7 @@ def play_bootstrap_tour(
497498
498499
499500def play_driverjs_tour (
500- driver ,
501- tour_steps ,
502- browser ,
503- msg_dur ,
504- name = None ,
505- interval = 0 ,
506- pgkeys = False ,
501+ driver , tour_steps , browser , msg_dur , name = None , interval = 0
507502):
508503 """Plays a DriverJS tour on the current website."""
509504 instructions = ""
@@ -514,6 +509,11 @@ def play_driverjs_tour(
514509 // Start the tour!
515510 tour.start();
516511 $tour = tour;"""
512+ instructions += """
513+ document.body.addEventListener('keyup', function (event) {
514+ if (event.key === 'PageUp') { $tour.movePrevious(); }
515+ if (event.key === 'PageDown') { $tour.moveNext(); }
516+ })"""
517517 autoplay = False
518518 if interval and interval > 0 :
519519 autoplay = True
@@ -522,7 +522,7 @@ def play_driverjs_tour(
522522 interval = 0.5
523523
524524 if not is_driverjs_activated (driver ):
525- activate_driverjs (driver , pgkeys )
525+ activate_driverjs (driver )
526526
527527 if len (tour_steps [name ]) > 1 :
528528 try :
@@ -641,6 +641,13 @@ def play_hopscotch_tour(
641641 // Start the tour!
642642 hopscotch.startTour(tour);
643643 $tour = hopscotch;"""
644+ instructions += """
645+ document.body.addEventListener('keyup', function (event) {
646+ if (event.key === 'PageUp' || event.key === 'ArrowLeft') {
647+ $tour.prevStep(); }
648+ if (event.key === 'PageDown' || event.key === 'ArrowRight') {
649+ $tour.nextStep(); }
650+ })"""
644651 autoplay = False
645652 if interval and interval > 0 :
646653 autoplay = True
@@ -678,6 +685,16 @@ def play_hopscotch_tour(
678685 )
679686
680687 driver .execute_script (instructions )
688+ try :
689+ page_actions .wait_for_element_visible (
690+ driver , "button.hopscotch-next" , by = "css selector" , timeout = 1.2
691+ )
692+ except Exception :
693+ pass
694+ try :
695+ driver .execute_script ('document.activeElement.blur();' )
696+ except Exception :
697+ pass
681698 tour_on = True
682699 if autoplay :
683700 start_ms = time .time () * 1000.0
@@ -749,13 +766,7 @@ def play_hopscotch_tour(
749766
750767
751768def play_introjs_tour (
752- driver ,
753- tour_steps ,
754- browser ,
755- msg_dur ,
756- name = None ,
757- interval = 0 ,
758- pgkeys = False ,
769+ driver , tour_steps , browser , msg_dur , name = None , interval = 0
759770):
760771 """Plays an IntroJS tour on the current website."""
761772 instructions = ""
@@ -779,6 +790,11 @@ def play_introjs_tour(
779790 // Start the tour
780791 startIntro();
781792 """
793+ instructions += """
794+ document.body.addEventListener('keyup', function (event) {
795+ if (event.key === 'PageUp') { $tour.previousStep(); }
796+ if (event.key === 'PageDown') { $tour.nextStep(); }
797+ })"""
782798 autoplay = False
783799 if interval and interval > 0 :
784800 autoplay = True
@@ -787,7 +803,7 @@ def play_introjs_tour(
787803 interval = 0.5
788804
789805 if not is_introjs_activated (driver ):
790- activate_introjs (driver , pgkeys )
806+ activate_introjs (driver )
791807
792808 if len (tour_steps [name ]) > 1 :
793809 try :
0 commit comments