Skip to content

Commit e37766f

Browse files
authored
Merge pull request #208 from seleniumbase/tour-updates
Tour updates
2 parents a2e14cc + d7d2413 commit e37766f

File tree

8 files changed

+55
-55
lines changed

8 files changed

+55
-55
lines changed

examples/boilerplates/samples/google_objects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class HomePage(object):
77
dialog_box = '[role="dialog"] div'
88
search_box = 'input[title="Search"]'
9+
list_box = '[role="listbox"]'
910
search_button = 'input[value="Google Search"]'
1011
feeling_lucky_button = '''input[value="I'm Feeling Lucky"]'''
1112

examples/boilerplates/samples/google_test.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ class GoogleTests(BaseCase):
1010

1111
def test_google_dot_com(self):
1212
self.open('https://google.com')
13-
try:
14-
# Remove the Privacy Checkup box if present.
15-
self.assert_text('Privacy Checkup', HomePage.dialog_box, timeout=2)
16-
self.click('link=NO, THANKS')
17-
except Exception:
18-
pass # Google may have removed the Privacy Checkup. Continue test.
13+
self.update_text(HomePage.search_box, 'github')
14+
self.assert_element(HomePage.list_box)
1915
self.assert_element(HomePage.search_button)
2016
self.assert_element(HomePage.feeling_lucky_button)
21-
self.update_text(HomePage.search_box, 'github\n')
17+
self.click(HomePage.search_button)
2218
self.assert_text('github.com', ResultsPage.search_results)
2319
self.click_link_text('Images')
24-
self.assert_element('img[alt="Image result for github"]')
20+
source = self.get_page_source()
21+
self.assertTrue("Image result for github" in source)

examples/tour_examples/ReadMe.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Here's how you play a tour:
3030

3131
``self.play_tour(interval)``
3232

33-
With the ``create_tour()`` method, you can pass a default theme to change the look & feel of the tour steps. Valid themes are ``dark``, ``default``, ``arrows``, ``square``, and ``square-dark``.
33+
With the ``create_tour()`` method, you can pass a default theme to change the look & feel of the tour steps. Valid themes for Shepherd Tours are ``dark``, ``light`` / ``arrows``, ``default``, ``square``, and ``square-dark``.
3434

3535
With the ``self.add_tour_step()`` method, you must first pass a message to display. You can then specify a web element to attach to (by using [CSS selectors](https://www.w3schools.com/cssref/css_selectors.asp)). If no element is specified, the tour step will tether to the top of the screen by default. You can also add an optional title above the message to display with the tour step, as well as change the theme for that step, and even specify the alignment (which is the side of the element that you want the tour message to tether to).
3636

@@ -50,12 +50,20 @@ class MyTourClass(BaseCase):
5050
self.wait_for_element('input[title="Search"]')
5151

5252
self.create_tour(theme="dark")
53-
self.add_tour_step("Click to begin the Google Tour!", title="SeleniumBase Tours")
54-
self.add_tour_step("Type in your search query here.", 'input[title="Search"]')
55-
self.add_tour_step("Then click here to search!", 'input[value="Google Search"]',
56-
alignment="bottom", theme="arrows")
57-
self.add_tour_step("Or click here to see the top result.",
58-
'''[value="I'm Feeling Lucky"]''', alignment="bottom", theme="arrows")
53+
self.add_tour_step(
54+
"Click to begin the Google Tour!", title="SeleniumBase Tours")
55+
self.add_tour_step(
56+
"Type in your search query here.", 'input[title="Search"]')
57+
self.play_tour()
58+
59+
self.highlight_update_text('input[title="Search"]', "Google")
60+
self.wait_for_element('[role="listbox"]') # Wait for autocomplete
61+
62+
self.create_tour(theme="light")
63+
self.add_tour_step(
64+
"Then click here to search.", 'input[value="Google Search"]')
65+
self.add_tour_step(
66+
"Or press [ENTER] after typing.", '[title="Search"]', theme="dark")
5967
self.play_tour()
6068
```
6169

examples/tour_examples/bootstrap_google_tour.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,14 @@ def test_google_tour(self):
1212
"Click to begin the Google Tour!", title="SeleniumBase Tours")
1313
self.add_tour_step(
1414
"Type in your search query here.", 'input[title="Search"]')
15-
self.add_tour_step(
16-
"Then click here to search!", 'input[value="Google Search"]',
17-
alignment="bottom")
18-
self.add_tour_step(
19-
"Or click here to see the top result.",
20-
'''[value="I'm Feeling Lucky"]''',
21-
alignment="bottom")
22-
self.add_tour_step("Here's an example Google search:")
15+
self.add_tour_step('Then click "Google Search" or press [ENTER].')
2316
self.play_tour()
2417

2518
self.highlight_update_text('input[title="Search"]', "GitHub")
19+
self.wait_for_element('[role="listbox"]') # Wait for autocomplete
2620
self.highlight_click('input[value="Google Search"]')
2721

28-
self.create_bootstrap_tour() # OR self.create_tour(theme="bootstrap")
22+
self.create_bootstrap_tour()
2923
self.add_tour_step(
3024
"Search results appear here!", title="(5-second autoplay on)")
3125
self.add_tour_step("Let's take another tour:")
@@ -34,7 +28,7 @@ def test_google_tour(self):
3428
self.open("https://www.google.com/maps/@42.3598616,-71.0912631,15z")
3529
self.wait_for_element('input#searchboxinput')
3630

37-
self.create_bootstrap_tour() # OR self.create_tour(theme="bootstrap")
31+
self.create_bootstrap_tour()
3832
self.add_tour_step("Welcome to Google Maps!")
3933
self.add_tour_step(
4034
"Type in a location here.", "#searchboxinput", title="Search Box")

examples/tour_examples/google_tour.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,24 @@ def test_google_tour(self):
1212
"Click to begin the Google Tour!", title="SeleniumBase Tours")
1313
self.add_tour_step(
1414
"Type in your search query here.", 'input[title="Search"]')
15+
self.play_tour()
16+
17+
self.highlight_update_text('input[title="Search"]', "Google")
18+
self.wait_for_element('[role="listbox"]') # Wait for autocomplete
19+
20+
self.create_tour(theme="light")
1521
self.add_tour_step(
16-
"Then click here to search!", 'input[value="Google Search"]',
17-
alignment="bottom", theme="arrows")
22+
"Then click here to search.", 'input[value="Google Search"]')
1823
self.add_tour_step(
19-
"Or click here to see the top result.",
20-
'''[value="I'm Feeling Lucky"]''',
21-
alignment="bottom", theme="arrows")
22-
self.add_tour_step("Here's an example Google search:", theme="arrows")
23-
self.play_tour(interval=0) # If interval is 0, tour is fully manual
24+
"Or press [ENTER] after typing.", '[title="Search"]', theme="dark")
25+
self.play_tour()
2426

25-
self.highlight_update_text('input[title="Search"]', "GitHub")
26-
self.highlight_click('input[value="Google Search"]')
27+
self.highlight_update_text('input[title="Search"]', "GitHub\n")
2728

2829
self.create_tour(theme="dark")
2930
self.add_tour_step(
3031
"Search results appear here!", title="(5-second autoplay on)")
31-
self.add_tour_step("Let's take another tour:", theme="arrows")
32+
self.add_tour_step("Let's take another tour:", theme="light")
3233
self.play_tour(interval=5) # tour automatically continues after 5 sec
3334

3435
self.open("https://www.google.com/maps/@42.3598616,-71.0912631,15z")
@@ -61,5 +62,5 @@ def test_google_tour(self):
6162
alignment="left")
6263
self.add_tour_step(
6364
"Thanks for trying out SeleniumBase Tours!",
64-
title="End of Guided Tour", theme="arrows")
65+
title="End of Guided Tour", theme="light")
6566
self.play_tour() # If interval isn't set, tour is fully manual

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,26 +217,20 @@ def main():
217217
data.append("")
218218
data.append(" def test_google_dot_com(self):")
219219
data.append(" self.open('https://google.com')")
220-
data.append(" try:")
221-
data.append(" # Remove the Privacy Checkup box if present.")
222-
data.append(" self.assert_text('Privacy Checkup', "
223-
"HomePage.dialog_box, timeout=3)")
224-
data.append(" self.click('link=NO, THANKS')")
225-
data.append(" except Exception:")
226-
data.append(" # Google may have removed it. Continue test.")
227-
data.append(" pass")
220+
data.append(
221+
" self.update_text(HomePage.search_box, 'github')")
222+
data.append(" self.assert_element(HomePage.list_box)")
228223
data.append(" self.assert_element(HomePage.search_button)")
229224
data.append(
230225
" self.assert_element(HomePage.feeling_lucky_button)")
231-
data.append(
232-
" self.update_text(HomePage.search_box, 'github\\n')")
226+
data.append(" self.click(HomePage.search_button)")
233227
data.append(
234228
" self.assert_text('github.com', "
235229
"ResultsPage.search_results)")
236230
data.append(" self.click_link_text('Images')")
231+
data.append(" source = self.get_page_source()")
237232
data.append(
238-
" self.assert_element("
239-
"'img[alt=\"Image result for github\"]')")
233+
" self.assertTrue('Image result for github' in source)")
240234
data.append("")
241235
file_path = "%s/%s" % (dir_name_3, "google_test.py")
242236
file = codecs.open(file_path, "w+", "utf-8")
@@ -247,6 +241,7 @@ def main():
247241
data.append("class HomePage(object):")
248242
data.append(" dialog_box = '[role=\"dialog\"] div'")
249243
data.append(" search_box = 'input[title=\"Search\"]'")
244+
data.append(" list_box = '[role=\"listbox\"]'")
250245
data.append(" search_button = 'input[value=\"Google Search\"]'")
251246
data.append(
252247
" feeling_lucky_button = "

seleniumbase/fixtures/base_case.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,8 @@ def create_tour(self, name=None, theme=None):
932932
name - If creating multiple tours, use this to select the
933933
tour you wish to add steps to.
934934
theme - Sets the default theme for the tour.
935-
Choose from "arrows", "dark", "default", "square", and
936-
"square-dark". ("arrows" is used if None is selected.)
935+
Choose from "light"/"arrows", "dark", "default", "square",
936+
and "square-dark". ("arrows" is used if None is selected.)
937937
"""
938938
if not name:
939939
name = "default"
@@ -947,6 +947,8 @@ def create_tour(self, name=None, theme=None):
947947
shepherd_theme = "shepherd-theme-default"
948948
elif theme == "dark":
949949
shepherd_theme = "shepherd-theme-dark"
950+
elif theme == "light":
951+
shepherd_theme = "shepherd-theme-arrows"
950952
elif theme == "arrows":
951953
shepherd_theme = "shepherd-theme-arrows"
952954
elif theme == "square":
@@ -995,8 +997,8 @@ def add_tour_step(self, message, selector=None, name=None,
995997
tour you wish to add steps to.
996998
title - Additional header text that appears above the message.
997999
theme - (NON-Bootstrap Tours ONLY) The styling of the tour step.
998-
Choose from "arrows", "dark", "default", "square", and
999-
"square-dark". ("arrows" is used if None is selected.)
1000+
Choose from "light"/"arrows", "dark", "default", "square",
1001+
and "square-dark". ("arrows" is used if None is selected.)
10001002
alignment - Choose from "top", "bottom", "left", and "right".
10011003
("top" is the default alignment).
10021004
duration - (Bootstrap Tours ONLY) The amount of time, in seconds,
@@ -1047,15 +1049,17 @@ def __add_shepherd_tour_step(self, message, selector=None, name=None,
10471049
tour you wish to add steps to.
10481050
title - Additional header text that appears above the message.
10491051
theme - (NON-Bootstrap Tours ONLY) The styling of the tour step.
1050-
Choose from "arrows", "dark", "default", "square", and
1051-
"square-dark". ("arrows" is used if None is selected.)
1052+
Choose from "light"/"arrows", "dark", "default", "square",
1053+
and "square-dark". ("arrows" is used if None is selected.)
10521054
alignment - Choose from "top", "bottom", "left", and "right".
10531055
("top" is the default alignment).
10541056
"""
10551057
if theme == "default":
10561058
shepherd_theme = "shepherd-theme-default"
10571059
elif theme == "dark":
10581060
shepherd_theme = "shepherd-theme-dark"
1061+
elif theme == "light":
1062+
shepherd_theme = "shepherd-theme-arrows"
10591063
elif theme == "arrows":
10601064
shepherd_theme = "shepherd-theme-arrows"
10611065
elif theme == "square":

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.15.8',
20+
version='1.15.9',
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)