Skip to content

Improve the export feature for website tours #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pip>=19.1.1
pip>=19.2.1
setuptools>=41.0.1
wheel>=0.33.4
six
Expand Down
36 changes: 31 additions & 5 deletions seleniumbase/core/tour_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,11 +700,16 @@ def export_tour(tour_steps, name=None, filename="my_tour.js", url=None):
backdrop_style = style_sheet.bt_backdrop_style
backdrop_style = backdrop_style.replace('\n', '')
backdrop_style = js_utils.escape_quotes_if_needed(backdrop_style)
instructions += 'injectJS("%s");' % jquery_js
instructions += '\n\n//////// Resources - Load 2 ////////\n\n'
instructions += 'injectJS("%s");\n' % jquery_js
instructions += '\n'
instructions += 'function loadResources() { '
instructions += 'if ( typeof jQuery !== "undefined" ) {\n'
instructions += 'injectCSS("%s");\n' % bootstrap_tour_css
instructions += 'injectStyle("%s");\n' % backdrop_style
instructions += 'injectJS("%s");' % bootstrap_tour_js
instructions += '} else { window.setTimeout("loadResources();",100); '
instructions += '} }\n'
instructions += 'loadResources()'

elif tour_type == "hopscotch":
hopscotch_css = constants.Hopscotch.MIN_CSS
Expand Down Expand Up @@ -738,18 +743,36 @@ def export_tour(tour_steps, name=None, filename="my_tour.js", url=None):
backdrop_style = js_utils.escape_quotes_if_needed(backdrop_style)
instructions += 'injectCSS("%s");\n' % spinner_css
instructions += 'injectJS("%s");\n' % jquery_js
instructions += 'injectJS("%s");' % tether_js
instructions += '\n\n//////// Resources - Load 2 ////////\n\n'
instructions += 'injectJS("%s");\n' % tether_js
instructions += '\n'
instructions += 'function loadResources() { '
instructions += 'if ( typeof jQuery !== "undefined" ) {\n'
instructions += 'injectCSS("%s");' % sh_theme_arrows_css
instructions += 'injectCSS("%s");' % sh_theme_arrows_fix_css
instructions += 'injectCSS("%s");' % sh_theme_default_css
instructions += 'injectCSS("%s");' % sh_theme_dark_css
instructions += 'injectCSS("%s");' % sh_theme_sq_css
instructions += 'injectCSS("%s");\n' % sh_theme_sq_dark_css
instructions += 'injectStyle("%s");\n' % backdrop_style
instructions += 'injectJS("%s");' % shepherd_js
instructions += 'injectJS("%s");\n' % shepherd_js
instructions += '} else { window.setTimeout("loadResources();",100); '
instructions += '} }\n'
instructions += 'loadResources()'

instructions += '\n\n//////// Tour Code ////////\n\n'
if tour_type == "bootstrap":
instructions += 'function loadTour() { '
instructions += 'if ( typeof Tour !== "undefined" ) {\n'
elif tour_type == "hopscotch":
instructions += 'function loadTour() { '
instructions += 'if ( typeof hopscotch !== "undefined" ) {\n'
elif tour_type == "introjs":
instructions += 'function loadTour() { '
instructions += 'if ( typeof introJs !== "undefined" ) {\n'
elif tour_type == "shepherd":
instructions += 'function loadTour() { '
instructions += 'if ( typeof Shepherd !== "undefined" ) {\n'

for tour_step in tour_steps[name]:
instructions += tour_step

Expand Down Expand Up @@ -792,6 +815,9 @@ def export_tour(tour_steps, name=None, filename="my_tour.js", url=None):
$tour = tour;\n""")
else:
pass
instructions += '\n} else { window.setTimeout("loadTour();",100); } '
instructions += '}\n'
instructions += 'loadTour()\n'

exported_tours_folder = EXPORTED_TOURS_FOLDER
if exported_tours_folder.endswith("/"):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name='seleniumbase',
version='1.25.5',
version='1.25.6',
description='Reliable Browser Automation & Testing Framework',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down