Skip to content

Commit 529dbfc

Browse files
authored
Merge pull request #213 from seleniumbase/tours-overhaul
Add ability to create SeleniumBase website tours using IntroJS
2 parents ff9e518 + 3ee4b6a commit 529dbfc

File tree

15 files changed

+560
-103
lines changed

15 files changed

+560
-103
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ install:
1919
- "python setup.py develop"
2020
- "sudo rm -f /etc/boto.cfg"
2121
before_script:
22-
- "flake8 seleniumbase/*.py && flake8 seleniumbase/*/*.py && flake8 seleniumbase/*/*/*.py && flake8 seleniumbase/*/*/*/*.py"
22+
- "flake8 --ignore FutureWarning seleniumbase/*.py && flake8 --ignore FutureWarning seleniumbase/*/*.py && flake8 --ignore FutureWarning seleniumbase/*/*/*.py && flake8 --ignore FutureWarning seleniumbase/*/*/*/*.py"
2323
# - "wget https://chromedriver.storage.googleapis.com/2.40/chromedriver_linux64.zip && unzip chromedriver_linux64.zip && sudo cp chromedriver /usr/local/bin/ && sudo chmod +x /usr/local/bin/chromedriver"
2424
# - "wget https://github.com/mozilla/geckodriver/releases/download/v0.21.0/geckodriver-v0.21.0-linux64.tar.gz -O /tmp/geckodriver.tar.gz && tar -C /opt -xzf /tmp/geckodriver.tar.gz && sudo chmod 755 /opt/geckodriver && sudo ln -fs /opt/geckodriver /usr/bin/geckodriver && sudo ln -fs /opt/geckodriver /usr/local/bin/geckodriver"
2525
# - "wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 && tar -xvf ./phantomjs-2.1.1-linux-x86_64.tar.bz2 && export PATH=$PWD/phantomjs-2.1.1-linux-x86_64/bin:$PATH"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Try out Demo Mode to see what what's being tested in real time! (Chrome is the d
4848
pytest my_first_test.py --demo_mode
4949
```
5050

51-
![](https://cdn2.hubspot.net/hubfs/100006/images/sb_demo.gif "SeleniumBase")<br />
51+
<img src="https://cdn2.hubspot.net/hubfs/100006/sb_demo_mode.gif" title="SeleniumBase" height="270"><br>
5252
(Above: Actual demo of [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) running on [xkcd.com](http://xkcd.com/353/))
5353

5454
There are many more examples to try out from the [SeleniumBase/examples](https://github.com/seleniumbase/SeleniumBase/blob/master/examples) directory, which you can run easily if you clone SeleniumBase.
@@ -60,7 +60,7 @@ cd tour_examples
6060
pytest google_tour.py
6161
```
6262

63-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/google_tour.gif" title="SeleniumBase Tours" height="348"><br>
63+
<img src="https://cdn2.hubspot.net/hubfs/100006/google_tour_3.gif" title="SeleniumBase Tour of Google" height="260"><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: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,58 @@
1-
## Creating SeleniumBase Tours
1+
## SeleniumBase Website Tours
22

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.
3+
SeleniumBase Tours utilize the following three Javascript libraries for creating and running tours, demos, and walkthroughs on any website: **[Shepherd JS](https://cdnjs.com/libraries/shepherd/1.8.1)**, **[Bootstrap Tour JS](https://cdnjs.com/libraries/bootstrap-tour)**, and **[Intro JS](https://cdnjs.com/libraries/intro.js)**.
44

5-
Example tour utilizing the Shepherd Javascript Library:
5+
Example tour:
66

7-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/google_tour.gif" title="Shepherd Tour" height="348"><br>
7+
<img src="https://cdn2.hubspot.net/hubfs/100006/google_tour_3.gif" title="SeleniumBase Tour of Google" height="260"><br>
88

9-
Example tour utilizing the Bootstrap Javascript Library:
109

11-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/google_tour_2b.gif" title="Bootstrap Tour" height="340"><br>
10+
### Creating a new tour:
1211

13-
By default, the Shepherd Javascript Library is used when creating a tour with:
12+
By default, Shepherd JS is used when creating a tour with:
1413

1514
``self.create_tour()``
1615

17-
To create a tour utilizing the Bootstrap Javascript Library, you can use either of the following:
16+
You can also do:
17+
18+
``self.create_shepherd_tour()``
19+
20+
With the ``create_tour()`` and ``create_shepherd_tour()`` methods, 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``.
21+
22+
To create a tour utilizing the Bootstrap Tour Library, you can use either of the following:
1823

1924
``self.create_bootstrap_tour()``
2025

2126
OR
2227

2328
``self.create_tour(theme="bootstrap")``
2429

30+
To create a tour utilizing the Intro JS Library, you can use either of the following:
31+
32+
``self.create_introjs_tour()``
33+
34+
OR
35+
36+
``self.create_tour(theme="introjs")``
37+
38+
39+
### Adding a step to a tour:
40+
2541
To add a tour step, use the following: (Only ``message`` is required. The other args are optional.)
2642

2743
``self.add_tour_step(message, css_selector, title, alignment, theme)``
2844

29-
Here's how you play a tour:
45+
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 (Shepherd tours only), and even specify the alignment (which is the side of the element that you want the tour message to tether to).
3046

31-
``self.play_tour(interval)``
3247

33-
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``.
48+
### Playing a tour:
49+
50+
You can play a tour by calling:
51+
52+
``self.play_tour(interval)``
3453

35-
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).
54+
If you specify an interval (optional), the tour will automatically walk through each step after that many seconds have passed.
3655

37-
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.
3856

3957
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.
4058

@@ -63,7 +81,7 @@ class MyTourClass(BaseCase):
6381
self.add_tour_step(
6482
"Then click here to search.", 'input[value="Google Search"]')
6583
self.add_tour_step(
66-
"Or press [ENTER] after typing.", '[title="Search"]', theme="dark")
84+
"Or press [ENTER] after typing a query here.", '[title="Search"]')
6785
self.play_tour()
6886
```
6987

@@ -72,9 +90,3 @@ class MyTourClass(BaseCase):
7290
```bash
7391
pytest google_tour.py
7492
```
75-
76-
#### There's also the Bootstrap Google Tour, which you can play with the following command:
77-
78-
```bash
79-
pytest bootstrap_google_tour.py
80-
```

examples/tour_examples/bootstrap_google_tour.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,26 @@ def test_google_tour(self):
1212
"Click to begin the Google Tour!", title="SeleniumBase Tours")
1313
self.add_tour_step(
1414
"Type in your search query here.", 'input[title="Search"]')
15-
self.add_tour_step('Then click "Google Search" or press [ENTER].')
1615
self.play_tour()
1716

18-
self.highlight_update_text('input[title="Search"]', "GitHub")
17+
self.highlight_update_text('input[title="Search"]', "Google")
1918
self.wait_for_element('[role="listbox"]') # Wait for autocomplete
20-
self.highlight_click('input[value="Google Search"]')
19+
20+
self.create_bootstrap_tour()
21+
self.add_tour_step(
22+
"Then click here to search.", 'input[value="Google Search"]')
23+
self.add_tour_step(
24+
"Or press [ENTER] after typing a query here.", '[title="Search"]')
25+
self.play_tour()
26+
27+
self.highlight_update_text('input[title="Search"]', "GitHub\n")
28+
self.wait_for_element("#search")
2129

2230
self.create_bootstrap_tour()
2331
self.add_tour_step(
2432
"Search results appear here!", title="(5-second autoplay on)")
2533
self.add_tour_step("Let's take another tour:")
26-
self.play_tour(interval=5) # tour automatically continues after 5 sec
34+
self.play_tour(interval=5) # Tour automatically continues after 5 sec
2735

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

examples/tour_examples/google_tour.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ def test_google_tour(self):
77
self.open('https://google.com')
88
self.wait_for_element('input[title="Search"]')
99

10+
# Create a website tour using the ShepherdJS library with "dark" theme
11+
# Same as: self.create_shepherd_tour(theme="dark")
1012
self.create_tour(theme="dark")
1113
self.add_tour_step(
1214
"Click to begin the Google Tour!", title="SeleniumBase Tours")
@@ -17,25 +19,32 @@ def test_google_tour(self):
1719
self.highlight_update_text('input[title="Search"]', "Google")
1820
self.wait_for_element('[role="listbox"]') # Wait for autocomplete
1921

22+
# Create a website tour using the ShepherdJS library with "light" theme
23+
# Same as: self.create_shepherd_tour(theme="light")
2024
self.create_tour(theme="light")
2125
self.add_tour_step(
2226
"Then click here to search.", 'input[value="Google Search"]')
2327
self.add_tour_step(
24-
"Or press [ENTER] after typing.", '[title="Search"]', theme="dark")
28+
"Or press [ENTER] after typing a query here.", '[title="Search"]')
2529
self.play_tour()
2630

2731
self.highlight_update_text('input[title="Search"]', "GitHub\n")
32+
self.wait_for_element("#search")
2833

29-
self.create_tour(theme="dark")
34+
# Create a website tour using the Bootstrap Tour JS library
35+
# Same as: self.create_bootstrap_tour()
36+
self.create_tour(theme="bootstrap")
3037
self.add_tour_step(
3138
"Search results appear here!", title="(5-second autoplay on)")
3239
self.add_tour_step("Let's take another tour:", theme="light")
33-
self.play_tour(interval=5) # tour automatically continues after 5 sec
40+
self.play_tour(interval=5) # Tour automatically continues after 5 sec
3441

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

38-
self.create_tour(theme="dark")
45+
# Create a website tour using the IntroJS library
46+
# Same as: self.create_introjs_tour()
47+
self.create_tour(theme="introjs")
3948
self.add_tour_step(
4049
"Welcome to Google Maps!")
4150
self.add_tour_step(
@@ -45,15 +54,14 @@ def test_google_tour(self):
4554
"#searchbox-searchbutton", alignment="bottom")
4655
self.add_tour_step(
4756
"Or click here to get driving directions.",
48-
"#searchbox-directions", alignment="bottom", theme="square-dark")
57+
"#searchbox-directions", alignment="bottom")
4958
self.add_tour_step(
5059
"Use this button to switch to Satellite view.",
5160
"div.widget-minimap", alignment="right")
5261
self.add_tour_step(
5362
"Click here to zoom in.", "#widget-zoom-in", alignment="left")
5463
self.add_tour_step(
55-
"Or click here to zoom out.", "#widget-zoom-out",
56-
alignment="left", theme="default")
64+
"Or click here to zoom out.", "#widget-zoom-out", alignment="left")
5765
self.add_tour_step(
5866
"Use the Menu button to see more options.",
5967
".searchbox-hamburger-container", alignment="right")
@@ -62,5 +70,5 @@ def test_google_tour(self):
6270
alignment="left")
6371
self.add_tour_step(
6472
"Thanks for trying out SeleniumBase Tours!",
65-
title="End of Guided Tour", theme="light")
66-
self.play_tour() # If interval isn't set, tour is fully manual
73+
title="End of Guided Tour")
74+
self.play_tour()
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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_introjs_tour() # OR self.create_tour(theme="introjs")
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.play_tour()
16+
17+
self.highlight_update_text('input[title="Search"]', "Google")
18+
self.wait_for_element('[role="listbox"]') # Wait for autocomplete
19+
20+
self.create_introjs_tour()
21+
self.add_tour_step(
22+
"Then click here to search.", 'input[value="Google Search"]')
23+
self.add_tour_step(
24+
"Or press [ENTER] after typing a query here.", '[title="Search"]')
25+
self.play_tour()
26+
27+
self.highlight_update_text('input[title="Search"]', "GitHub\n")
28+
self.wait_for_element("#search")
29+
30+
self.create_introjs_tour()
31+
self.add_tour_step(
32+
"Search results appear here!", title="(5-second autoplay on)")
33+
self.add_tour_step("Let's take another tour:")
34+
self.play_tour(interval=5) # Tour automatically continues after 5 sec
35+
36+
self.open("https://www.google.com/maps/@42.3598616,-71.0912631,15z")
37+
self.wait_for_element('input#searchboxinput')
38+
39+
self.create_introjs_tour()
40+
self.add_tour_step("Welcome to Google Maps!")
41+
self.add_tour_step(
42+
"Type in a location here.", "#searchboxinput", title="Search Box")
43+
self.add_tour_step(
44+
"Then click here to show it on the map.",
45+
"#searchbox-searchbutton", alignment="bottom")
46+
self.add_tour_step(
47+
"Or click here to get driving directions.",
48+
"#searchbox-directions", alignment="bottom")
49+
self.add_tour_step(
50+
"Use this button to switch to Satellite view.",
51+
"div.widget-minimap", alignment="right")
52+
self.add_tour_step(
53+
"Click here to zoom in.", "#widget-zoom-in", alignment="left")
54+
self.add_tour_step(
55+
"Or click here to zoom out.", "#widget-zoom-out", alignment="left")
56+
self.add_tour_step(
57+
"Use the Menu button to see more options.",
58+
".searchbox-hamburger-container", alignment="right")
59+
self.add_tour_step(
60+
"Or click here to see more Google apps.", '[title="Google apps"]',
61+
alignment="left")
62+
self.add_tour_step(
63+
"Thanks for trying out SeleniumBase Tours!",
64+
title="End of Guided Tour")
65+
self.play_tour()
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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_shepherd_tour(theme="dark")
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.play_tour()
16+
17+
self.highlight_update_text('input[title="Search"]', "Google")
18+
self.wait_for_element('[role="listbox"]') # Wait for autocomplete
19+
20+
self.create_shepherd_tour(theme="light")
21+
self.add_tour_step(
22+
"Then click here to search.", 'input[value="Google Search"]')
23+
self.add_tour_step(
24+
"Or press [ENTER] after typing a query here.", '[title="Search"]')
25+
self.play_tour()
26+
27+
self.highlight_update_text('input[title="Search"]', "GitHub\n")
28+
self.wait_for_element("#search")
29+
30+
self.create_shepherd_tour(theme="dark")
31+
self.add_tour_step(
32+
"Search results appear here!", title="(5-second autoplay on)")
33+
self.add_tour_step("Let's take another tour:", theme="light")
34+
self.play_tour(interval=5) # Tour automatically continues after 5 sec
35+
36+
self.open("https://www.google.com/maps/@42.3598616,-71.0912631,15z")
37+
self.wait_for_element('input#searchboxinput')
38+
39+
self.create_shepherd_tour(theme="dark")
40+
self.add_tour_step(
41+
"Welcome to Google Maps!")
42+
self.add_tour_step(
43+
"Type in a location here.", "#searchboxinput", title="Search Box")
44+
self.add_tour_step(
45+
"Then click here to show it on the map.",
46+
"#searchbox-searchbutton", alignment="bottom")
47+
self.add_tour_step(
48+
"Or click here to get driving directions.",
49+
"#searchbox-directions", alignment="bottom", theme="dark")
50+
self.add_tour_step(
51+
"Use this button to switch to Satellite view.",
52+
"div.widget-minimap", alignment="right")
53+
self.add_tour_step(
54+
"Click here to zoom in.", "#widget-zoom-in", alignment="left")
55+
self.add_tour_step(
56+
"Or click here to zoom out.", "#widget-zoom-out",
57+
alignment="left", theme="light")
58+
self.add_tour_step(
59+
"Use the Menu button to see more options.",
60+
".searchbox-hamburger-container", alignment="right")
61+
self.add_tour_step(
62+
"Or click here to see more Google apps.", '[title="Google apps"]',
63+
alignment="left")
64+
self.add_tour_step(
65+
"Thanks for trying out SeleniumBase Tours!",
66+
title="End of Guided Tour", theme="light")
67+
self.play_tour()

requirements.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ pip
22
ipython
33
setuptools
44
selenium==3.14.1
5-
pytest>=3.8.1
5+
pytest>=3.8.2
66
pytest-cov>=2.6.0
77
pytest-html>=1.19.0
88
pytest-rerunfailures>=4.1
9-
pytest-xdist>=1.23.0
9+
pytest-xdist>=1.23.2
1010
parameterized==0.6.1
1111
six>=1.11.0
1212
pyotp>=2.2.6
1313
requests>=2.19.1
14-
beautifulsoup4==4.6.3
15-
unittest2==1.1.0
14+
beautifulsoup4>=4.6.3
15+
unittest2>=1.1.0
1616
chardet>=3.0.4
17-
urllib3==1.23
18-
boto==2.48.0
17+
urllib3>=1.23
18+
boto>=2.49.0
1919
nose==1.3.7
2020
ipdb==0.11
2121
flake8==3.5.0

0 commit comments

Comments
 (0)