|
| 1 | +## Using SeleniumBase Tours |
| 2 | + |
| 3 | +SeleniumBase Tours utilize the [HubSpot Shepherd Library](http://github.hubspot.com/shepherd/docs/welcome/) for creating and running tours on any website. |
| 4 | + |
| 5 | +To utilize tours, there are three methods that you need to know at the basic level: |
| 6 | + |
| 7 | +``self.create_tour(theme)`` |
| 8 | +``self.add_tour_step(message, css_selector, title, alignment, theme)`` |
| 9 | +``self.play_tour()`` |
| 10 | + |
| 11 | +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``. |
| 12 | + |
| 13 | +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). |
| 14 | + |
| 15 | +Finally, you can play a tour you created by calling the ``self.play_tour()`` method. |
| 16 | + |
| 17 | +### Here's an example of using SeleniumBase Tours: |
| 18 | + |
| 19 | +```python |
| 20 | +from seleniumbase import BaseCase |
| 21 | + |
| 22 | +class MyTourClass(BaseCase): |
| 23 | + |
| 24 | + def test_google_tour(self): |
| 25 | + self.open('https://google.com') |
| 26 | + self.wait_for_element('input[title="Search"]') |
| 27 | + self.create_tour(theme="dark") |
| 28 | + self.add_tour_step("Click to begin the Google Tour!", |
| 29 | + title="SeleniumBase Guided Tours") |
| 30 | + self.add_tour_step("Type in your search query here.", |
| 31 | + 'input[title="Search"]') |
| 32 | + self.add_tour_step("Then click here to search!", |
| 33 | + 'input[value="Google Search"]', |
| 34 | + alignment="bottom", theme="arrows") |
| 35 | + self.add_tour_step("Or click here to see the top result.", |
| 36 | + '''[value="I'm Feeling Lucky"]''', |
| 37 | + alignment="bottom", theme="arrows") |
| 38 | + self.play_tour() |
| 39 | +``` |
| 40 | + |
| 41 | +### 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: |
| 42 | + |
| 43 | +```bash |
| 44 | +pytest google_tour.py |
| 45 | +``` |
0 commit comments