Skip to content

Commit 5c1ac1f

Browse files
committed
Update examples
1 parent d2bb997 commit 5c1ac1f

13 files changed

+17
-35
lines changed

examples/boilerplates/ReadMe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<h2><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="24" /> Example Boilerplates:</h2>
44

5-
* Boilerplates are located in the [SeleniumBase => examples/boilerplates/](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/boilerplates) folder.
6-
* Boilerplates can help you structure tests using common design patterns such as the Page Object Model.
5+
* Boilerplate files are located in the [SeleniumBase => examples/boilerplates/](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/boilerplates) folder.
6+
* Boilerplates can help you structure tests using common design patterns such as the Page Object Model. For all 20 SeleniumBase design patterns, see: [Syntax Formats](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md)
77

88
<h2><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="24" /> Boilerplate Files:</h2>
99

examples/boilerplates/base_test_case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def setUp(self):
1515
# <<< Run custom setUp() code for tests AFTER the super().setUp() >>>
1616

1717
def tearDown(self):
18-
self.save_teardown_screenshot()
18+
self.save_teardown_screenshot() # If test fails, or if "--screenshot"
1919
if self.has_exception():
2020
# <<< Run custom code if the test failed. >>>
2121
pass

examples/edge_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_edge(self):
1313
print(' (Run this test using "--edge" or "--browser=edge")')
1414
self.skip('Use "--edge" or "--browser=edge"')
1515
if self.headless:
16-
self.open("data:,")
16+
self.open_if_not_url("about:blank")
1717
print("\n This test is NOT designed for Headless Mode!")
1818
self.skip('Do NOT use "--headless" with this test!')
1919
self.open("edge://settings/help")

examples/github_test.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,10 @@
33

44
class GitHubTests(BaseCase):
55
def test_github(self):
6-
# Selenium can trigger GitHub's anti-automation system:
7-
# "You have triggered an abuse detection mechanism."
8-
# "Please wait a few minutes before you try again."
9-
# To avoid this automation blocker, two steps are being taken:
10-
# 1. self.slow_click() is being used to slow down Selenium actions.
11-
# 2. The browser's User Agent is modified to avoid Selenium-detection
12-
# when running in headless mode.
136
if self.headless:
14-
self.get_new_driver(
15-
agent="""Mozilla/5.0 """
16-
"""AppleWebKit/537.36 (KHTML, like Gecko) """
17-
"""Chrome/Version 100.0.4896.88 Safari/537.36"""
18-
)
7+
self.open_if_not_url("about:blank")
8+
print("\n This test is NOT designed for Headless Mode!")
9+
self.skip('Do NOT use "--headless" with this test!')
1910
self.open("https://github.com/search?q=SeleniumBase")
2011
self.slow_click('a[href="/seleniumbase/SeleniumBase"]')
2112
self.click_if_visible('[data-action="click:signup-prompt#dismiss"]')

examples/my_first_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,8 @@ def test_swag_labs(self):
135135
#
136136
# 7. self.js_click(SELECTOR) can be used to click on hidden elements.
137137
#
138-
# 8. If a URL starts with "://", then "https://" is automatically used.
139-
# Example: [self.open("://URL")] becomes [self.open("https://URL")]
140-
# This helps by reducing the line length by 5 characters.
138+
# 8. self.open(URL) will automatically complete URLs missing a prefix.
139+
# Example: google.com will become https://google.com before opened.
141140
#
142141
# 9. For the full method list, see one of the following:
143142
# * SeleniumBase/seleniumbase/fixtures/base_case.py

examples/raw_parameter_script.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
if pure_python:
3232
sb = MyTestClass("test_swag_labs")
3333
sb.browser = "chrome"
34+
sb.is_behave = False
3435
sb.headless = False
3536
sb.headed = False
3637
sb.xvfb = False
@@ -43,6 +44,7 @@
4344
sb.var1 = None
4445
sb.var2 = None
4546
sb.var3 = None
47+
sb.variables = {}
4648
sb.account = None
4749
sb.environment = "test"
4850
sb.user_agent = None
@@ -98,7 +100,6 @@
98100
sb.swiftshader = False
99101
sb.ad_block_on = False
100102
sb.highlights = None
101-
sb.check_js = False
102103
sb.interval = None
103104
sb.cap_file = None
104105
sb.cap_string = None

0 commit comments

Comments
 (0)