Skip to content

Commit fe866ac

Browse files
authored
Merge pull request #231 from seleniumbase/shepherd-tour-update
Shepherd tour update
2 parents ef9e3e5 + 6bc6afa commit fe866ac

File tree

3 files changed

+57
-29
lines changed

3 files changed

+57
-29
lines changed

examples/tour_examples/shepherd_google_tour.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ def test_google_tour(self):
2727
self.highlight_update_text('input[title="Search"]', "GitHub\n")
2828
self.wait_for_element("#search")
2929

30-
self.create_shepherd_tour(theme="dark")
30+
self.create_shepherd_tour(theme="square-dark")
3131
self.add_tour_step(
3232
"Search results appear here!", title="(5-second autoplay on)")
33-
self.add_tour_step("Let's take another tour:", theme="light")
33+
self.add_tour_step(
34+
"The next tour begins in a few seconds...", theme="square",
35+
title="(5-second autoplay on)")
3436
self.play_tour(interval=5) # Tour automatically continues after 5 sec
3537

3638
self.open("https://www.google.com/maps/@42.3598616,-71.0912631,15z")

seleniumbase/fixtures/base_case.py

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,8 @@ def create_tour(self, name=None, theme=None):
757757
""" Creates a tour for a website. By default, the Shepherd Javascript
758758
Library is used with the Shepherd "Light" / "Arrows" theme.
759759
@Params
760-
name - If creating multiple tours, use this to select the
761-
tour you wish to add steps to.
760+
name - If creating multiple tours at the same time,
761+
use this to select the tour you wish to add steps to.
762762
theme - Sets the default theme for the tour.
763763
Choose from "light"/"arrows", "dark", "default", "square",
764764
and "square-dark". ("arrows" is used if None is selected.)
@@ -793,8 +793,8 @@ def create_tour(self, name=None, theme=None):
793793
def create_shepherd_tour(self, name=None, theme=None):
794794
""" Creates a Shepherd JS website tour.
795795
@Params
796-
name - If creating multiple tours, use this to select the
797-
tour you wish to add steps to.
796+
name - If creating multiple tours at the same time,
797+
use this to select the tour you wish to add steps to.
798798
theme - Sets the default theme for the tour.
799799
Choose from "light"/"arrows", "dark", "default", "square",
800800
and "square-dark". ("light" is used if None is selected.)
@@ -826,16 +826,36 @@ def create_shepherd_tour(self, name=None, theme=None):
826826
classes: '%s',
827827
scrollTo: true
828828
}
829-
});""" % shepherd_theme)
829+
});
830+
var allButtons = {
831+
skip: {
832+
text: "Skip",
833+
action: tour.cancel,
834+
classes: 'shepherd-button-secondary tour-button-left'
835+
},
836+
back: {
837+
text: "Back",
838+
action: tour.back,
839+
classes: 'shepherd-button-secondary'
840+
},
841+
next: {
842+
text: "Next",
843+
action: tour.next,
844+
classes: 'shepherd-button-primary tour-button-right'
845+
},
846+
};
847+
var firstStepButtons = [allButtons.skip, allButtons.next];
848+
var midTourButtons = [allButtons.back, allButtons.next];
849+
""" % shepherd_theme)
830850

831851
self._tour_steps[name] = []
832852
self._tour_steps[name].append(new_tour)
833853

834854
def create_bootstrap_tour(self, name=None):
835855
""" Creates a Bootstrap tour for a website.
836856
@Params
837-
name - If creating multiple tours, use this to select the
838-
tour you wish to add steps to.
857+
name - If creating multiple tours at the same time,
858+
use this to select the tour you wish to add steps to.
839859
"""
840860
if not name:
841861
name = "default"
@@ -854,8 +874,8 @@ def create_bootstrap_tour(self, name=None):
854874
def create_hopscotch_tour(self, name=None):
855875
""" Creates an Hopscotch tour for a website.
856876
@Params
857-
name - If creating multiple tours, use this to select the
858-
tour you wish to add steps to.
877+
name - If creating multiple tours at the same time,
878+
use this to select the tour you wish to add steps to.
859879
"""
860880
if not name:
861881
name = "default"
@@ -874,8 +894,8 @@ def create_hopscotch_tour(self, name=None):
874894
def create_introjs_tour(self, name=None):
875895
""" Creates an IntroJS tour for a website.
876896
@Params
877-
name - If creating multiple tours, use this to select the
878-
tour you wish to add steps to.
897+
name - If creating multiple tours at the same time,
898+
use this to select the tour you wish to add steps to.
879899
"""
880900
if not name:
881901
name = "default"
@@ -898,8 +918,8 @@ def add_tour_step(self, message, selector=None, name=None,
898918
@Params
899919
message - The message to display.
900920
selector - The CSS Selector of the Element to attach to.
901-
name - If creating multiple tours, use this to select the
902-
tour you wish to add steps to.
921+
name - If creating multiple tours at the same time,
922+
use this to select the tour you wish to add steps to.
903923
title - Additional header text that appears above the message.
904924
theme - (NON-Bootstrap Tours ONLY) The styling of the tour step.
905925
Choose from "light"/"arrows", "dark", "default", "square",
@@ -960,8 +980,8 @@ def __add_shepherd_tour_step(self, message, selector=None, name=None,
960980
@Params
961981
message - The message to display.
962982
selector - The CSS Selector of the Element to attach to.
963-
name - If creating multiple tours, use this to select the
964-
tour you wish to add steps to.
983+
name - If creating multiple tours at the same time,
984+
use this to select the tour you wish to add steps to.
965985
title - Additional header text that appears above the message.
966986
theme - (NON-Bootstrap Tours ONLY) The styling of the tour step.
967987
Choose from "light"/"arrows", "dark", "default", "square",
@@ -990,15 +1010,21 @@ def __add_shepherd_tour_step(self, message, selector=None, name=None,
9901010
shepherd_classes = shepherd_theme
9911011
if selector == "html":
9921012
shepherd_classes += " shepherd-orphan"
1013+
buttons = "firstStepButtons"
1014+
if len(self._tour_steps[name]) > 1:
1015+
buttons = "midTourButtons"
1016+
9931017
step = ("""
9941018
tour.addStep('%s', {
9951019
title: '%s',
9961020
classes: '%s',
9971021
text: '%s',
9981022
attachTo: {element: '%s', on: '%s'},
1023+
buttons: %s,
9991024
advanceOn: '.docs-link click'
10001025
});""" % (
1001-
name, title, shepherd_classes, message, selector, alignment))
1026+
name, title, shepherd_classes, message, selector, alignment,
1027+
buttons))
10021028

10031029
self._tour_steps[name].append(step)
10041030

@@ -1008,8 +1034,8 @@ def __add_bootstrap_tour_step(self, message, selector=None, name=None,
10081034
@Params
10091035
message - The message to display.
10101036
selector - The CSS Selector of the Element to attach to.
1011-
name - If creating multiple tours, use this to select the
1012-
tour you wish to add steps to.
1037+
name - If creating multiple tours at the same time,
1038+
use this to select the tour you wish to add steps to.
10131039
title - Additional header text that appears above the message.
10141040
alignment - Choose from "top", "bottom", "left", and "right".
10151041
("top" is the default alignment).
@@ -1044,8 +1070,8 @@ def __add_hopscotch_tour_step(self, message, selector=None, name=None,
10441070
@Params
10451071
message - The message to display.
10461072
selector - The CSS Selector of the Element to attach to.
1047-
name - If creating multiple tours, use this to select the
1048-
tour you wish to add steps to.
1073+
name - If creating multiple tours at the same time,
1074+
use this to select the tour you wish to add steps to.
10491075
title - Additional header text that appears above the message.
10501076
alignment - Choose from "top", "bottom", "left", and "right".
10511077
("bottom" is the default alignment).
@@ -1076,8 +1102,8 @@ def __add_introjs_tour_step(self, message, selector=None, name=None,
10761102
@Params
10771103
message - The message to display.
10781104
selector - The CSS Selector of the Element to attach to.
1079-
name - If creating multiple tours, use this to select the
1080-
tour you wish to add steps to.
1105+
name - If creating multiple tours at the same time,
1106+
use this to select the tour you wish to add steps to.
10811107
title - Additional header text that appears above the message.
10821108
alignment - Choose from "top", "bottom", "left", and "right".
10831109
("top" is the default alignment).
@@ -1102,8 +1128,8 @@ def __add_introjs_tour_step(self, message, selector=None, name=None,
11021128
def play_tour(self, name=None, interval=0):
11031129
""" Plays a tour on the current website.
11041130
@Params
1105-
name - If creating multiple tours, use this to select the
1106-
tour you wish to play.
1131+
name - If creating multiple tours at the same time,
1132+
use this to select the tour you wish to add steps to.
11071133
interval - The delay time between autoplaying tour steps.
11081134
If set to 0 (default), the tour is fully manual control.
11091135
"""
@@ -1141,8 +1167,8 @@ def export_tour(self, name=None, filename="my_tour.js"):
11411167
You'll be able to copy the tour directly into the Console of
11421168
any web browser to play the tour outside of SeleniumBase runs.
11431169
@Params
1144-
name - If creating multiple tours, use this to select the
1145-
tour you wish to play.
1170+
name - If creating multiple tours at the same time,
1171+
use this to select the tour you wish to add steps to.
11461172
filename - The name of the javascript file that you wish to
11471173
save the tour to. """
11481174
tour_helper.export_tour(self._tour_steps, name=name, filename=filename)

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.16.13',
20+
version='1.16.14',
2121
description='All-In-One Test Automation Framework',
2222
long_description=long_description,
2323
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)