Skip to content

Commit 2c080f8

Browse files
committed
Update example tests
1 parent 3813649 commit 2c080f8

10 files changed

+36
-6
lines changed

examples/basic_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ def test_basics(self):
1717
self.assert_text_not_visible("Backpack", "div.cart_item")
1818
self.js_click("a#logout_sidebar_link")
1919
self.assert_element("div#login_button_container")
20+
21+
22+
if __name__ == "__main__": # Use "python" to call "pytest"
23+
from pytest import main
24+
main([__file__])

examples/my_first_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_swag_labs(self):
2828
self.assert_element("div#login_button_container")
2929

3030

31-
if __name__ == "__main__":
31+
if __name__ == "__main__": # Use "python" to call "pytest"
3232
from pytest import main
3333
main([__file__])
3434

examples/raw_file_call.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Works by using pytest.main([__file__])."""
44
from seleniumbase import BaseCase
55

6-
if __name__ == "__main__":
6+
if __name__ == "__main__": # Use "python" to call "pytest"
77
from pytest import main
88
main([__file__])
99

@@ -19,4 +19,5 @@ def test_tinymce(self):
1919
with self.frame_switch("iframe"):
2020
self.add_text("#tinymce", "SeleniumBase!")
2121
self.highlight("#tinymce")
22-
self.post_message("SeleniumBase is cool!")
22+
self.post_message("SeleniumBase is fast!")
23+
self.post_message("And SeleniumBase is fun!")

examples/test_calculator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ def test_6_times_7_plus_12_equals_54(self):
1313
self.click('button[id="2"]')
1414
self.click("button#equal")
1515
self.assert_exact_text("54", "input#output")
16+
17+
18+
if __name__ == "__main__": # Use "python" to call "pytest"
19+
from pytest import main
20+
main([__file__])

examples/test_coffee_cart.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ def test_coffee_cart(self):
1515
self.type("input#email", "[email protected]")
1616
self.click("button#submit-payment")
1717
self.assert_text("Thanks for your purchase.", "div#app div")
18+
19+
20+
if __name__ == "__main__": # Use "python" to call "pytest"
21+
from pytest import main
22+
main([__file__])

examples/test_mfa_login.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ def test_mfa_login(self):
1414
self.click_link("Sign out") # Link must be "a" tag. Not "button".
1515
self.assert_element('a:contains("Sign in")')
1616
self.assert_exact_text("You have been signed out!", "#top_message")
17+
18+
19+
if __name__ == "__main__": # Use "python" to call "pytest"
20+
from pytest import main
21+
main([__file__])

examples/test_swag_labs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,8 @@ def tearDown(self):
7878
except Exception:
7979
pass
8080
super(SwagLabsTests, self).tearDown()
81+
82+
83+
if __name__ == "__main__": # Use "python" to call "pytest"
84+
from pytest import main
85+
main([__file__])

examples/verify_undetected.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
from seleniumbase import BaseCase
77

8-
if __name__ == "__main__":
8+
if __name__ == "__main__": # Use "python" to call "pytest"
99
from pytest import main
1010
main([__file__, "--uc"])
1111

examples/wordle_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
class WordleTests(BaseCase):
9-
109
word_list = []
1110

1211
def initialize_word_list(self):
@@ -95,3 +94,8 @@ def test_wordle(self):
9594
print('Final guess: "%s" (Not the correct word!)' % word.upper())
9695
self.fail("Unable to solve for the correct word in 6 attempts!")
9796
self.sleep(3)
97+
98+
99+
if __name__ == "__main__": # Use "python" to call "pytest"
100+
from pytest import main
101+
main([__file__])

help_docs/syntax_formats.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class MyTestClass(BaseCase):
6262
self.assert_exact_text("Demo Page", "h1")
6363
self.assert_no_js_errors()
6464

65-
if __name__ == "__main__": # To run with "python" instead of "pytest".
65+
if __name__ == "__main__": # Use "python" to call "pytest"
6666
from pytest import main
6767
main([__file__])
6868
```

0 commit comments

Comments
 (0)