Skip to content

Commit c5f58c0

Browse files
authored
Merge pull request #347 from seleniumbase/improve-tour-export-feature
Improve the export feature for website tours
2 parents e3c0d2c + 126177d commit c5f58c0

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pip>=19.1.1
1+
pip>=19.2.1
22
setuptools>=41.0.1
33
wheel>=0.33.4
44
six

seleniumbase/core/tour_helper.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -700,11 +700,16 @@ def export_tour(tour_steps, name=None, filename="my_tour.js", url=None):
700700
backdrop_style = style_sheet.bt_backdrop_style
701701
backdrop_style = backdrop_style.replace('\n', '')
702702
backdrop_style = js_utils.escape_quotes_if_needed(backdrop_style)
703-
instructions += 'injectJS("%s");' % jquery_js
704-
instructions += '\n\n//////// Resources - Load 2 ////////\n\n'
703+
instructions += 'injectJS("%s");\n' % jquery_js
704+
instructions += '\n'
705+
instructions += 'function loadResources() { '
706+
instructions += 'if ( typeof jQuery !== "undefined" ) {\n'
705707
instructions += 'injectCSS("%s");\n' % bootstrap_tour_css
706708
instructions += 'injectStyle("%s");\n' % backdrop_style
707709
instructions += 'injectJS("%s");' % bootstrap_tour_js
710+
instructions += '} else { window.setTimeout("loadResources();",100); '
711+
instructions += '} }\n'
712+
instructions += 'loadResources()'
708713

709714
elif tour_type == "hopscotch":
710715
hopscotch_css = constants.Hopscotch.MIN_CSS
@@ -738,18 +743,36 @@ def export_tour(tour_steps, name=None, filename="my_tour.js", url=None):
738743
backdrop_style = js_utils.escape_quotes_if_needed(backdrop_style)
739744
instructions += 'injectCSS("%s");\n' % spinner_css
740745
instructions += 'injectJS("%s");\n' % jquery_js
741-
instructions += 'injectJS("%s");' % tether_js
742-
instructions += '\n\n//////// Resources - Load 2 ////////\n\n'
746+
instructions += 'injectJS("%s");\n' % tether_js
747+
instructions += '\n'
748+
instructions += 'function loadResources() { '
749+
instructions += 'if ( typeof jQuery !== "undefined" ) {\n'
743750
instructions += 'injectCSS("%s");' % sh_theme_arrows_css
744751
instructions += 'injectCSS("%s");' % sh_theme_arrows_fix_css
745752
instructions += 'injectCSS("%s");' % sh_theme_default_css
746753
instructions += 'injectCSS("%s");' % sh_theme_dark_css
747754
instructions += 'injectCSS("%s");' % sh_theme_sq_css
748755
instructions += 'injectCSS("%s");\n' % sh_theme_sq_dark_css
749756
instructions += 'injectStyle("%s");\n' % backdrop_style
750-
instructions += 'injectJS("%s");' % shepherd_js
757+
instructions += 'injectJS("%s");\n' % shepherd_js
758+
instructions += '} else { window.setTimeout("loadResources();",100); '
759+
instructions += '} }\n'
760+
instructions += 'loadResources()'
751761

752762
instructions += '\n\n//////// Tour Code ////////\n\n'
763+
if tour_type == "bootstrap":
764+
instructions += 'function loadTour() { '
765+
instructions += 'if ( typeof Tour !== "undefined" ) {\n'
766+
elif tour_type == "hopscotch":
767+
instructions += 'function loadTour() { '
768+
instructions += 'if ( typeof hopscotch !== "undefined" ) {\n'
769+
elif tour_type == "introjs":
770+
instructions += 'function loadTour() { '
771+
instructions += 'if ( typeof introJs !== "undefined" ) {\n'
772+
elif tour_type == "shepherd":
773+
instructions += 'function loadTour() { '
774+
instructions += 'if ( typeof Shepherd !== "undefined" ) {\n'
775+
753776
for tour_step in tour_steps[name]:
754777
instructions += tour_step
755778

@@ -792,6 +815,9 @@ def export_tour(tour_steps, name=None, filename="my_tour.js", url=None):
792815
$tour = tour;\n""")
793816
else:
794817
pass
818+
instructions += '\n} else { window.setTimeout("loadTour();",100); } '
819+
instructions += '}\n'
820+
instructions += 'loadTour()\n'
795821

796822
exported_tours_folder = EXPORTED_TOURS_FOLDER
797823
if exported_tours_folder.endswith("/"):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name='seleniumbase',
20-
version='1.25.5',
20+
version='1.25.6',
2121
description='Reliable Browser Automation & Testing Framework',
2222
long_description=long_description,
2323
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)