Skip to content

Commit 45a00cf

Browse files
authored
Merge pull request #166 from seleniumbase/add-tour-feature
Add tour feature
2 parents c01d68a + 7570a61 commit 45a00cf

File tree

8 files changed

+744
-240
lines changed

8 files changed

+744
-240
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ script:
2727
- "pytest examples/my_first_test.py --browser=chrome -s --headless --with-db_reporting"
2828
- "nosetests examples/boilerplates/boilerplate_test.py --browser=chrome --headless"
2929
- "pytest examples/my_first_test.py --browser=firefox -s --headless --with-db_reporting"
30-
- "pytest examples/github_test.py --browser=firefox -s --headless --with-db_reporting --demo_mode --demo_sleep=0.2"
30+
- "pytest examples/my_first_test.py --browser=chrome -s --headless --with-db_reporting --demo_mode --demo_sleep=0.2"
3131
- "sudo mysql --password=test -e 'select test_address,browser,state,start_time,runtime from test_db.test_run_data'"
3232
after_script:
3333
- "sudo mysql -e 'DROP DATABASE test_db;'"

examples/my_first_test.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ def test_basic(self):
7676
# title = element.get_attribute("title")
7777
# ]
7878
#
79-
# For backwards-compatibilty, some methods have multiple names.
79+
# For backwards-compatibilty, some SeleniumBase methods that do the
80+
# same thing have multiple names, kept on from previous versions.
8081
# Ex: wait_for_element_visible() is the same as find_element().
8182
# Both search for and return the element, and raise an exception if
8283
# the element does not appear on the page within the timeout limit.
84+
# And assert_element() also does this (minus returning the element).
85+
#
8386
# (See seleniumbase/fixtures/base_case.py for the full method list.)

examples/tour_examples/ReadMe.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
```

examples/tour_examples/google_tour.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
self.create_tour(theme="dark")
10+
self.add_tour_step("Click to begin the Google Tour!",
11+
title="SeleniumBase Guided Tours")
12+
self.add_tour_step("Type in your search query here.",
13+
'input[title="Search"]')
14+
self.add_tour_step("Then click here to search!",
15+
'input[value="Google Search"]',
16+
alignment="bottom", theme="arrows")
17+
self.add_tour_step("Or click here to see the top result.",
18+
'''[value="I'm Feeling Lucky"]''',
19+
alignment="bottom", theme="arrows")
20+
self.add_tour_step("Here's an example Google search...",
21+
theme="arrows")
22+
self.play_tour()
23+
24+
self.highlight_update_text('input[title="Search"]', "GitHub")
25+
self.highlight_click('input[value="Google Search"]')
26+
self.create_tour(theme="dark")
27+
self.add_tour_step("Voila! Search results appear here!")
28+
self.add_tour_step("Let's take another tour...",
29+
title="Ready for more?", theme="square")
30+
self.play_tour()
31+
32+
self.open("https://www.google.com/maps/@42.3598616,-71.0912631,15z")
33+
self.wait_for_element('input#searchboxinput')
34+
self.create_tour(theme="dark")
35+
self.add_tour_step("Welcome to Google Maps!")
36+
self.add_tour_step("Type in a location here.",
37+
"#searchboxinput", title="Search Box")
38+
self.add_tour_step("Then click here to show it on the map.",
39+
"#searchbox-searchbutton", alignment="bottom")
40+
self.add_tour_step("Or click here to get driving directions.",
41+
"#searchbox-directions",
42+
alignment="bottom", theme="square-dark")
43+
self.add_tour_step("Use this button to switch to Satellite view.",
44+
"div.widget-minimap", alignment="right")
45+
self.add_tour_step("Click here to zoom in.",
46+
"#widget-zoom-in", alignment="left")
47+
self.add_tour_step("Or click here to zoom out.",
48+
"#widget-zoom-out",
49+
alignment="left", theme="default")
50+
self.add_tour_step("Use the Menu button to see more options.",
51+
".searchbox-hamburger-container", alignment="right")
52+
self.add_tour_step("Or click here to see more Google apps.",
53+
'[title="Google apps"]', alignment="left")
54+
self.add_tour_step("Thanks for trying out SeleniumBase tours!",
55+
title="End of Guided Tour", theme="square")
56+
self.play_tour()

help_docs/method_summary.md

+13
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,21 @@ self.set_window_size(width, height)
8383

8484
self.maximize_window()
8585

86+
self.add_css_link(css_link)
87+
88+
self.add_js_link(js_link)
89+
90+
self.add_css_style(css_style)
91+
8692
self.activate_jquery()
8793

94+
self.create_tour(name=None, theme=None)
95+
96+
self.add_tour_step(message, selector=None, name=None,
97+
title=None, theme=None, alignment=None)
98+
99+
self.play_tour(name=None)
100+
88101
self.activate_messenger()
89102

90103
self.post_message(message, style="info", duration=None)

seleniumbase/core/browser_launcher.py

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def _create_firefox_profile(downloads_path, proxy_string):
5555
profile.set_preference("network.proxy.ssl_port", int(proxy_port))
5656
profile.set_preference(
5757
"security.mixed_content.block_active_content", False)
58+
profile.set_preference("security.csp.enable", False)
5859
profile.set_preference(
5960
"browser.download.manager.showAlertOnComplete", False)
6061
profile.set_preference("browser.download.panel.shown", False)

0 commit comments

Comments
 (0)