Skip to content
Merged
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ script:
- "pytest examples/my_first_test.py --browser=chrome -s --headless --with-db_reporting"
- "nosetests examples/boilerplates/boilerplate_test.py --browser=chrome --headless"
- "pytest examples/my_first_test.py --browser=firefox -s --headless --with-db_reporting"
- "pytest examples/github_test.py --browser=firefox -s --headless --with-db_reporting --demo_mode --demo_sleep=0.2"
- "pytest examples/my_first_test.py --browser=chrome -s --headless --with-db_reporting --demo_mode --demo_sleep=0.2"
- "sudo mysql --password=test -e 'select test_address,browser,state,start_time,runtime from test_db.test_run_data'"
after_script:
- "sudo mysql -e 'DROP DATABASE test_db;'"
Expand Down
5 changes: 4 additions & 1 deletion examples/my_first_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ def test_basic(self):
# title = element.get_attribute("title")
# ]
#
# For backwards-compatibilty, some methods have multiple names.
# For backwards-compatibilty, some SeleniumBase methods that do the
# same thing have multiple names, kept on from previous versions.
# Ex: wait_for_element_visible() is the same as find_element().
# Both search for and return the element, and raise an exception if
# the element does not appear on the page within the timeout limit.
# And assert_element() also does this (minus returning the element).
#
# (See seleniumbase/fixtures/base_case.py for the full method list.)
45 changes: 45 additions & 0 deletions examples/tour_examples/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## Using SeleniumBase Tours

SeleniumBase Tours utilize the [HubSpot Shepherd Library](http://github.hubspot.com/shepherd/docs/welcome/) for creating and running tours on any website.

To utilize tours, there are three methods that you need to know at the basic level:

``self.create_tour(theme)``
``self.add_tour_step(message, css_selector, title, alignment, theme)``
``self.play_tour()``

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 ``self.add_tour_step()`` method, at minimum you must pass a message to display. Then you can specify a web element to attach to (by CSS selector). If no element is specified, the tour step will tether to the top of the screen by default. You can add an optional title above the message to display with the tour step. You can also change the theme for that step, as well as specifiy the alignment (which is the side of the element that the tour message will tether to).

Finally, you can play a tour you created by calling the ``self.play_tour()`` method.

### Here's an example of using SeleniumBase Tours:

```python
from seleniumbase import BaseCase

class MyTourClass(BaseCase):

def test_google_tour(self):
self.open('https://google.com')
self.wait_for_element('input[title="Search"]')
self.create_tour(theme="dark")
self.add_tour_step("Click to begin the Google Tour!",
title="SeleniumBase Guided 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.play_tour()
```

### This example was taken from [google_tour.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/google_tour.py), which you can run with:

```bash
pytest google_tour.py
```
56 changes: 56 additions & 0 deletions examples/tour_examples/google_tour.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from seleniumbase import BaseCase


class MyTourClass(BaseCase):

def test_google_tour(self):
self.open('https://google.com')
self.wait_for_element('input[title="Search"]')
self.create_tour(theme="dark")
self.add_tour_step("Click to begin the Google Tour!",
title="SeleniumBase Guided 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("Here's an example Google search...",
theme="arrows")
self.play_tour()

self.highlight_update_text('input[title="Search"]', "GitHub")
self.highlight_click('input[value="Google Search"]')
self.create_tour(theme="dark")
self.add_tour_step("Voila! Search results appear here!")
self.add_tour_step("Let's take another tour...",
title="Ready for more?", theme="square")
self.play_tour()

self.open("https://www.google.com/maps/@42.3598616,-71.0912631,15z")
self.wait_for_element('input#searchboxinput')
self.create_tour(theme="dark")
self.add_tour_step("Welcome to Google Maps!")
self.add_tour_step("Type in a location here.",
"#searchboxinput", title="Search Box")
self.add_tour_step("Then click here to show it on the map.",
"#searchbox-searchbutton", alignment="bottom")
self.add_tour_step("Or click here to get driving directions.",
"#searchbox-directions",
alignment="bottom", theme="square-dark")
self.add_tour_step("Use this button to switch to Satellite view.",
"div.widget-minimap", alignment="right")
self.add_tour_step("Click here to zoom in.",
"#widget-zoom-in", alignment="left")
self.add_tour_step("Or click here to zoom out.",
"#widget-zoom-out",
alignment="left", theme="default")
self.add_tour_step("Use the Menu button to see more options.",
".searchbox-hamburger-container", alignment="right")
self.add_tour_step("Or click here to see more Google apps.",
'[title="Google apps"]', alignment="left")
self.add_tour_step("Thanks for trying out SeleniumBase tours!",
title="End of Guided Tour", theme="square")
self.play_tour()
13 changes: 13 additions & 0 deletions help_docs/method_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,21 @@ self.set_window_size(width, height)

self.maximize_window()

self.add_css_link(css_link)

self.add_js_link(js_link)

self.add_css_style(css_style)

self.activate_jquery()

self.create_tour(name=None, theme=None)

self.add_tour_step(message, selector=None, name=None,
title=None, theme=None, alignment=None)

self.play_tour(name=None)

self.activate_messenger()

self.post_message(message, style="info", duration=None)
Expand Down
1 change: 1 addition & 0 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def _create_firefox_profile(downloads_path, proxy_string):
profile.set_preference("network.proxy.ssl_port", int(proxy_port))
profile.set_preference(
"security.mixed_content.block_active_content", False)
profile.set_preference("security.csp.enable", False)
profile.set_preference(
"browser.download.manager.showAlertOnComplete", False)
profile.set_preference("browser.download.panel.shown", False)
Expand Down
Loading