diff --git a/examples/boilerplates/samples/google_objects.py b/examples/boilerplates/samples/google_objects.py index 067711e1236..acdc092a41e 100755 --- a/examples/boilerplates/samples/google_objects.py +++ b/examples/boilerplates/samples/google_objects.py @@ -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"]''' diff --git a/examples/boilerplates/samples/google_test.py b/examples/boilerplates/samples/google_test.py index f368a7236b4..232aa78bc63 100755 --- a/examples/boilerplates/samples/google_test.py +++ b/examples/boilerplates/samples/google_test.py @@ -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) diff --git a/examples/tour_examples/ReadMe.md b/examples/tour_examples/ReadMe.md index a4ae0429ce8..36152e0e29b 100755 --- a/examples/tour_examples/ReadMe.md +++ b/examples/tour_examples/ReadMe.md @@ -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). @@ -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() ``` diff --git a/examples/tour_examples/bootstrap_google_tour.py b/examples/tour_examples/bootstrap_google_tour.py index 9838883b130..ddfb92a26db 100755 --- a/examples/tour_examples/bootstrap_google_tour.py +++ b/examples/tour_examples/bootstrap_google_tour.py @@ -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:") @@ -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") diff --git a/examples/tour_examples/google_tour.py b/examples/tour_examples/google_tour.py index 84a7e3da2cd..6360de8b9f7 100755 --- a/examples/tour_examples/google_tour.py +++ b/examples/tour_examples/google_tour.py @@ -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") @@ -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 diff --git a/seleniumbase/console_scripts/sb_mkdir.py b/seleniumbase/console_scripts/sb_mkdir.py index 175e6868685..71f4cf65b5f 100755 --- a/seleniumbase/console_scripts/sb_mkdir.py +++ b/seleniumbase/console_scripts/sb_mkdir.py @@ -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") @@ -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 = " diff --git a/seleniumbase/fixtures/base_case.py b/seleniumbase/fixtures/base_case.py index 9518da3dfa2..57c1aa6b819 100755 --- a/seleniumbase/fixtures/base_case.py +++ b/seleniumbase/fixtures/base_case.py @@ -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" @@ -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": @@ -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, @@ -1047,8 +1049,8 @@ 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). """ @@ -1056,6 +1058,8 @@ def __add_shepherd_tour_step(self, message, selector=None, name=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": diff --git a/setup.py b/setup.py index d718c3d7b28..0f6ea4bdf13 100755 --- a/setup.py +++ b/setup.py @@ -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',