Skip to content

Tour updates #208

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 4 commits into from
Sep 20, 2018
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
1 change: 1 addition & 0 deletions examples/boilerplates/samples/google_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class HomePage(object):
dialog_box = '[role="dialog"] div'
search_box = 'input[title="Search"]'
list_box = '[role="listbox"]'
search_button = 'input[value="Google Search"]'
feeling_lucky_button = '''input[value="I'm Feeling Lucky"]'''

Expand Down
13 changes: 5 additions & 8 deletions examples/boilerplates/samples/google_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ class GoogleTests(BaseCase):

def test_google_dot_com(self):
self.open('https://google.com')
try:
# Remove the Privacy Checkup box if present.
self.assert_text('Privacy Checkup', HomePage.dialog_box, timeout=2)
self.click('link=NO, THANKS')
except Exception:
pass # Google may have removed the Privacy Checkup. Continue test.
self.update_text(HomePage.search_box, 'github')
self.assert_element(HomePage.list_box)
self.assert_element(HomePage.search_button)
self.assert_element(HomePage.feeling_lucky_button)
self.update_text(HomePage.search_box, 'github\n')
self.click(HomePage.search_button)
self.assert_text('github.com', ResultsPage.search_results)
self.click_link_text('Images')
self.assert_element('img[alt="Image result for github"]')
source = self.get_page_source()
self.assertTrue("Image result for github" in source)
22 changes: 15 additions & 7 deletions examples/tour_examples/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Here's how you play a tour:

``self.play_tour(interval)``

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``.
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``.

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).

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

self.create_tour(theme="dark")
self.add_tour_step("Click to begin the Google Tour!", title="SeleniumBase Tours")
self.add_tour_step("Type in your search query here.", 'input[title="Search"]')
self.add_tour_step("Then click here to search!", 'input[value="Google Search"]',
alignment="bottom", theme="arrows")
self.add_tour_step("Or click here to see the top result.",
'''[value="I'm Feeling Lucky"]''', alignment="bottom", theme="arrows")
self.add_tour_step(
"Click to begin the Google Tour!", title="SeleniumBase Tours")
self.add_tour_step(
"Type in your search query here.", 'input[title="Search"]')
self.play_tour()

self.highlight_update_text('input[title="Search"]', "Google")
self.wait_for_element('[role="listbox"]') # Wait for autocomplete

self.create_tour(theme="light")
self.add_tour_step(
"Then click here to search.", 'input[value="Google Search"]')
self.add_tour_step(
"Or press [ENTER] after typing.", '[title="Search"]', theme="dark")
self.play_tour()
```

Expand Down
14 changes: 4 additions & 10 deletions examples/tour_examples/bootstrap_google_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@ def test_google_tour(self):
"Click to begin the Google Tour!", title="SeleniumBase Tours")
self.add_tour_step(
"Type in your search query here.", 'input[title="Search"]')
self.add_tour_step(
"Then click here to search!", 'input[value="Google Search"]',
alignment="bottom")
self.add_tour_step(
"Or click here to see the top result.",
'''[value="I'm Feeling Lucky"]''',
alignment="bottom")
self.add_tour_step("Here's an example Google search:")
self.add_tour_step('Then click "Google Search" or press [ENTER].')
self.play_tour()

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

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

self.create_bootstrap_tour() # OR self.create_tour(theme="bootstrap")
self.create_bootstrap_tour()
self.add_tour_step("Welcome to Google Maps!")
self.add_tour_step(
"Type in a location here.", "#searchboxinput", title="Search Box")
Expand Down
23 changes: 12 additions & 11 deletions examples/tour_examples/google_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ def test_google_tour(self):
"Click to begin the Google Tour!", title="SeleniumBase Tours")
self.add_tour_step(
"Type in your search query here.", 'input[title="Search"]')
self.play_tour()

self.highlight_update_text('input[title="Search"]', "Google")
self.wait_for_element('[role="listbox"]') # Wait for autocomplete

self.create_tour(theme="light")
self.add_tour_step(
"Then click here to search!", 'input[value="Google Search"]',
alignment="bottom", theme="arrows")
"Then click here to search.", 'input[value="Google Search"]')
self.add_tour_step(
"Or click here to see the top result.",
'''[value="I'm Feeling Lucky"]''',
alignment="bottom", theme="arrows")
self.add_tour_step("Here's an example Google search:", theme="arrows")
self.play_tour(interval=0) # If interval is 0, tour is fully manual
"Or press [ENTER] after typing.", '[title="Search"]', theme="dark")
self.play_tour()

self.highlight_update_text('input[title="Search"]', "GitHub")
self.highlight_click('input[value="Google Search"]')
self.highlight_update_text('input[title="Search"]', "GitHub\n")

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

self.open("https://www.google.com/maps/@42.3598616,-71.0912631,15z")
Expand Down Expand Up @@ -61,5 +62,5 @@ def test_google_tour(self):
alignment="left")
self.add_tour_step(
"Thanks for trying out SeleniumBase Tours!",
title="End of Guided Tour", theme="arrows")
title="End of Guided Tour", theme="light")
self.play_tour() # If interval isn't set, tour is fully manual
19 changes: 7 additions & 12 deletions seleniumbase/console_scripts/sb_mkdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,26 +217,20 @@ def main():
data.append("")
data.append(" def test_google_dot_com(self):")
data.append(" self.open('https://google.com')")
data.append(" try:")
data.append(" # Remove the Privacy Checkup box if present.")
data.append(" self.assert_text('Privacy Checkup', "
"HomePage.dialog_box, timeout=3)")
data.append(" self.click('link=NO, THANKS')")
data.append(" except Exception:")
data.append(" # Google may have removed it. Continue test.")
data.append(" pass")
data.append(
" self.update_text(HomePage.search_box, 'github')")
data.append(" self.assert_element(HomePage.list_box)")
data.append(" self.assert_element(HomePage.search_button)")
data.append(
" self.assert_element(HomePage.feeling_lucky_button)")
data.append(
" self.update_text(HomePage.search_box, 'github\\n')")
data.append(" self.click(HomePage.search_button)")
data.append(
" self.assert_text('github.com', "
"ResultsPage.search_results)")
data.append(" self.click_link_text('Images')")
data.append(" source = self.get_page_source()")
data.append(
" self.assert_element("
"'img[alt=\"Image result for github\"]')")
" self.assertTrue('Image result for github' in source)")
data.append("")
file_path = "%s/%s" % (dir_name_3, "google_test.py")
file = codecs.open(file_path, "w+", "utf-8")
Expand All @@ -247,6 +241,7 @@ def main():
data.append("class HomePage(object):")
data.append(" dialog_box = '[role=\"dialog\"] div'")
data.append(" search_box = 'input[title=\"Search\"]'")
data.append(" list_box = '[role=\"listbox\"]'")
data.append(" search_button = 'input[value=\"Google Search\"]'")
data.append(
" feeling_lucky_button = "
Expand Down
16 changes: 10 additions & 6 deletions seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,8 @@ def create_tour(self, name=None, theme=None):
name - If creating multiple tours, use this to select the
tour you wish to add steps to.
theme - Sets the default theme for the tour.
Choose from "arrows", "dark", "default", "square", and
"square-dark". ("arrows" is used if None is selected.)
Choose from "light"/"arrows", "dark", "default", "square",
and "square-dark". ("arrows" is used if None is selected.)
"""
if not name:
name = "default"
Expand All @@ -947,6 +947,8 @@ def create_tour(self, name=None, theme=None):
shepherd_theme = "shepherd-theme-default"
elif theme == "dark":
shepherd_theme = "shepherd-theme-dark"
elif theme == "light":
shepherd_theme = "shepherd-theme-arrows"
elif theme == "arrows":
shepherd_theme = "shepherd-theme-arrows"
elif theme == "square":
Expand Down Expand Up @@ -995,8 +997,8 @@ def add_tour_step(self, message, selector=None, name=None,
tour you wish to add steps to.
title - Additional header text that appears above the message.
theme - (NON-Bootstrap Tours ONLY) The styling of the tour step.
Choose from "arrows", "dark", "default", "square", and
"square-dark". ("arrows" is used if None is selected.)
Choose from "light"/"arrows", "dark", "default", "square",
and "square-dark". ("arrows" is used if None is selected.)
alignment - Choose from "top", "bottom", "left", and "right".
("top" is the default alignment).
duration - (Bootstrap Tours ONLY) The amount of time, in seconds,
Expand Down Expand Up @@ -1047,15 +1049,17 @@ def __add_shepherd_tour_step(self, message, selector=None, name=None,
tour you wish to add steps to.
title - Additional header text that appears above the message.
theme - (NON-Bootstrap Tours ONLY) The styling of the tour step.
Choose from "arrows", "dark", "default", "square", and
"square-dark". ("arrows" is used if None is selected.)
Choose from "light"/"arrows", "dark", "default", "square",
and "square-dark". ("arrows" is used if None is selected.)
alignment - Choose from "top", "bottom", "left", and "right".
("top" is the default alignment).
"""
if theme == "default":
shepherd_theme = "shepherd-theme-default"
elif theme == "dark":
shepherd_theme = "shepherd-theme-dark"
elif theme == "light":
shepherd_theme = "shepherd-theme-arrows"
elif theme == "arrows":
shepherd_theme = "shepherd-theme-arrows"
elif theme == "square":
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.15.8',
version='1.15.9',
description='All-In-One Test Automation Framework',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down