Skip to content

Commit 0bc0cfc

Browse files
authored
Merge pull request #196 from seleniumbase/bootstrap-tour
Add the ability to create Bootstrap Tours
2 parents 4ea23a1 + e380721 commit 0bc0cfc

File tree

8 files changed

+329
-42
lines changed

8 files changed

+329
-42
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ cd tour_examples
6060
pytest google_tour.py
6161
```
6262

63-
![](https://cdn2.hubspot.net/hubfs/100006/images/google_tour.gif "SeleniumBase Tours")<br />
63+
<img src="https://cdn2.hubspot.net/hubfs/100006/images/google_tour.gif" title="SeleniumBase Tours" height="348"><br>
6464
(Above: Actual demo of [google_tour.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/google_tour.py) running on [google.com](https://google.com))
6565

6666
For more detailed steps on getting started, see the [**Detailed Instructions**](#seleniumbase_installation) section.

examples/tour_examples/ReadMe.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
11
## Creating SeleniumBase Tours
22

3-
![](https://cdn2.hubspot.net/hubfs/100006/images/google_tour.gif "SeleniumBase Tours")<br>
3+
SeleniumBase Tours utilize the **[Shepherd Javascript Library](https://cdnjs.com/libraries/shepherd/1.8.1)** and the **[Bootstrap Tour Library](https://cdnjs.com/libraries/bootstrap-tour)** for creating and running tours, demos, and walkthroughs on any website.
44

5-
SeleniumBase Tours utilize the [Shepherd Javascript Library](https://cdnjs.com/libraries/shepherd/1.8.1) for creating and running tours, demos, and walkthroughs on any website.
5+
Example tour utilizing the Shepherd Javascript Library:
66

7-
To utilize tours, there are three methods that you need to know at the basic level (which contain optional arguments):
7+
<img src="https://cdn2.hubspot.net/hubfs/100006/images/google_tour.gif" title="Shepherd Tour" height="348"><br>
88

9-
``self.create_tour(theme)``
9+
Example tour utilizing the Bootstrap Javascript Library:
10+
11+
<img src="https://cdn2.hubspot.net/hubfs/100006/images/google_tour_2b.gif" title="Bootstrap Tour" height="340"><br>
12+
13+
By default, the Shepherd Javascript Library is used when creating a tour with:
14+
15+
``self.create_tour()``
16+
17+
To create a tour utilizing the Bootstrap Javascript Library, you can use either of the following:
18+
19+
``self.create_bootstrap_tour()``
20+
21+
OR
22+
23+
``self.create_tour(theme="bootstrap")``
24+
25+
To add a tour step, use the following: (Only ``message`` is required. The other args are optional.)
1026

1127
``self.add_tour_step(message, css_selector, title, alignment, theme)``
1228

29+
Here's how you play a tour:
30+
1331
``self.play_tour(interval)``
1432

1533
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``.
@@ -18,6 +36,8 @@ With the ``self.add_tour_step()`` method, you must first pass a message to displ
1836

1937
Finally, you can play a tour you created by calling the ``self.play_tour()`` method. If you specify an interval, the tour will automatically walk through each step after that many seconds have passed.
2038

39+
All methods have the optional ``name`` argument, which is only needed if you're creating multiple tours at once. Then, when you're adding a step or playing a tour, SeleniumBase knows which tour you're referring too. You can avoid using the ``name`` arg for multiple tours if you play a tour before creating a new one.
40+
2141
### Here's an example of using SeleniumBase Tours:
2242

2343
```python
@@ -44,3 +64,9 @@ class MyTourClass(BaseCase):
4464
```bash
4565
pytest google_tour.py
4666
```
67+
68+
#### There's also the Bootstrap Google Tour, which you can play with the following command:
69+
70+
```bash
71+
pytest bootstrap_google_tour.py
72+
```
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
from seleniumbase import BaseCase
2+
3+
4+
class MyTourClass(BaseCase):
5+
6+
def test_google_tour(self):
7+
self.open('https://google.com')
8+
self.wait_for_element('input[title="Search"]')
9+
10+
self.create_bootstrap_tour() # OR self.create_tour(theme="bootstrap")
11+
self.add_tour_step(
12+
"Click to begin the Google Tour!", title="SeleniumBase Tours")
13+
self.add_tour_step(
14+
"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:")
23+
self.play_tour()
24+
25+
self.highlight_update_text('input[title="Search"]', "GitHub")
26+
self.highlight_click('input[value="Google Search"]')
27+
28+
self.create_bootstrap_tour() # OR self.create_tour(theme="bootstrap")
29+
self.add_tour_step(
30+
"Search results appear here!", title="(5-second autoplay on)")
31+
self.add_tour_step("Let's take another tour:")
32+
self.play_tour(interval=5) # tour automatically continues after 5 sec
33+
34+
self.open("https://www.google.com/maps/@42.3598616,-71.0912631,15z")
35+
self.wait_for_element('input#searchboxinput')
36+
37+
self.create_bootstrap_tour() # OR self.create_tour(theme="bootstrap")
38+
self.add_tour_step("Welcome to Google Maps!")
39+
self.add_tour_step(
40+
"Type in a location here.", "#searchboxinput", title="Search Box")
41+
self.add_tour_step(
42+
"Then click here to show it on the map.",
43+
"#searchbox-searchbutton", alignment="bottom")
44+
self.add_tour_step(
45+
"Or click here to get driving directions.",
46+
"#searchbox-directions", alignment="bottom")
47+
self.add_tour_step(
48+
"Use this button to switch to Satellite view.",
49+
"div.widget-minimap", alignment="right")
50+
self.add_tour_step(
51+
"Click here to zoom in.", "#widget-zoom-in", alignment="left")
52+
self.add_tour_step(
53+
"Or click here to zoom out.", "#widget-zoom-out", alignment="left")
54+
self.add_tour_step(
55+
"Use the Menu button to see more options.",
56+
".searchbox-hamburger-container", alignment="right")
57+
self.add_tour_step(
58+
"Or click here to see more Google apps.", '[title="Google apps"]',
59+
alignment="left")
60+
self.add_tour_step(
61+
"Thanks for trying out SeleniumBase Tours!",
62+
title="End of Guided Tour")
63+
self.play_tour()

examples/tour_examples/google_tour.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ def test_google_tour(self):
2828
self.create_tour(theme="dark")
2929
self.add_tour_step(
3030
"Search results appear here!", title="(5-second autoplay on)")
31-
self.add_tour_step(
32-
"Let's take another tour...",
33-
title="Ready for more?", theme="arrows")
34-
self.play_tour(interval=5) # tour automatically continues after 3s
31+
self.add_tour_step("Let's take another tour:", theme="arrows")
32+
self.play_tour(interval=5) # tour automatically continues after 5 sec
3533

3634
self.open("https://www.google.com/maps/@42.3598616,-71.0912631,15z")
3735
self.wait_for_element('input#searchboxinput')

help_docs/method_summary.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ self.add_css_style(css_style)
9191

9292
self.add_js_code_from_link(js_link)
9393

94-
self.add_meta_tag(http_equiv=None, content=None):
94+
self.add_meta_tag(http_equiv=None, content=None)
9595

9696
self.activate_jquery()
9797

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

100+
self.create_bootstrap_tour(name=None)
101+
100102
self.add_tour_step(message, selector=None, name=None,
101103
title=None, theme=None, alignment=None)
102104

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ setuptools
33
ipython==5.6.0
44
selenium==3.14.0
55
nose==1.3.7
6-
pytest==3.7.2
6+
pytest==3.7.3
77
pytest-html==1.19.0
8-
pytest-xdist==1.22.5
8+
pytest-xdist==1.23.0
99
six==1.11.0
1010
flake8==3.5.0
1111
requests==2.19.1

0 commit comments

Comments
 (0)