Skip to content

Commit 50484a0

Browse files
committed
Update examples
1 parent 1e7355f commit 50484a0

File tree

8 files changed

+31
-17
lines changed

8 files changed

+31
-17
lines changed

examples/boilerplates/samples/sb_swag_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
"""Classic Page Object Model with the "sb" fixture."""
2+
from seleniumbase import BaseCase
3+
BaseCase.main(__name__, __file__)
24

35

46
class LoginPage:
5-
def login_to_swag_labs(self, sb, username):
7+
def login_to_swag_labs(self, sb: BaseCase, username):
68
sb.open("https://www.saucedemo.com")
79
sb.type("#user-name", username)
810
sb.type("#password", "secret_sauce")
911
sb.click('input[type="submit"]')
1012

1113

1214
class MyTests:
13-
def test_swag_labs_login(self, sb):
15+
def test_swag_labs_login(self, sb: BaseCase):
1416
LoginPage().login_to_swag_labs(sb, "standard_user")
1517
sb.assert_element("div.inventory_list")
1618
sb.assert_element('div:contains("Sauce Labs Backpack")')

examples/boilerplates/samples/swag_labs_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class LoginPage:
7-
def login_to_swag_labs(self, sb, username):
7+
def login_to_swag_labs(self, sb: BaseCase, username):
88
sb.open("https://www.saucedemo.com")
99
sb.type("#user-name", username)
1010
sb.type("#password", "secret_sauce")

examples/hack_the_planet.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,7 @@ def test_all_your_base_are_belong_to_us(self):
301301

302302
self.open("https://git-scm.com/")
303303
self.set_text_content("span#tagline", aybabtu)
304-
self.set_text_content("#nav-about h3", ayb)
305-
self.set_text_content("#nav-documentation h3", abtu)
306-
self.highlight("span#tagline", loops=8, scroll=False)
307-
self.highlight("#nav-about h3", loops=5, scroll=False)
308-
self.highlight("#nav-documentation h3", loops=6, scroll=False)
304+
self.highlight("span#tagline", loops=10, scroll=False)
309305

310306
self.open("https://pragprog.com/")
311307
self.set_text_content("header p", aybabtu)

examples/sb_fixture_tests.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
from seleniumbase import BaseCase
2+
BaseCase.main(__name__, __file__)
3+
4+
15
# "sb" pytest fixture test in a method with no class
2-
def test_sb_fixture_with_no_class(sb):
6+
def test_sb_fixture_with_no_class(sb: BaseCase):
37
sb.open("seleniumbase.io/simple/login")
48
sb.type("#username", "demo_user")
59
sb.type("#password", "secret_pass")
@@ -13,7 +17,7 @@ def test_sb_fixture_with_no_class(sb):
1317

1418
# "sb" pytest fixture test in a method inside a class
1519
class Test_SB_Fixture:
16-
def test_sb_fixture_inside_class(self, sb):
20+
def test_sb_fixture_inside_class(self, sb: BaseCase):
1721
sb.open("seleniumbase.io/simple/login")
1822
sb.type("#username", "demo_user")
1923
sb.type("#password", "secret_pass")

examples/test_override_sb_fixture.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Overriding the "sb" fixture to override the driver."""
22
import pytest
3+
from seleniumbase import BaseCase
4+
BaseCase.main(__name__, __file__)
35

46

57
@pytest.fixture()
@@ -66,7 +68,7 @@ def tearDown(self):
6668
sb._needs_tearDown = False
6769

6870

69-
def test_override_fixture_no_class(sb):
71+
def test_override_fixture_no_class(sb: BaseCase):
7072
sb.open("https://seleniumbase.io/demo_page")
7173
sb.type("#myTextInput", "This is Automated")
7274
sb.set_value("input#mySlider", "100")
@@ -77,7 +79,7 @@ def test_override_fixture_no_class(sb):
7779

7880

7981
class TestOverride:
80-
def test_override_fixture_inside_class(self, sb):
82+
def test_override_fixture_inside_class(self, sb: BaseCase):
8183
sb.open("https://seleniumbase.io/demo_page")
8284
sb.type("#myTextInput", "This is Automated")
8385
sb.set_value("input#mySlider", "100")

examples/test_request_sb_fixture.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
from seleniumbase import BaseCase
2+
BaseCase.main(__name__, __file__)
3+
4+
15
# Use the pytest "request" fixture to get the "sb" fixture (no class)
26
def test_request_sb_fixture(request):
3-
sb = request.getfixturevalue("sb")
7+
sb: BaseCase = request.getfixturevalue("sb")
48
sb.open("https://seleniumbase.io/demo_page")
59
sb.assert_text("SeleniumBase", "#myForm h2")
610
sb.assert_element("input#myTextInput")
@@ -12,7 +16,7 @@ def test_request_sb_fixture(request):
1216
# Use the pytest "request" fixture to get the "sb" fixture (in class)
1317
class Test_Request_Fixture:
1418
def test_request_sb_fixture_in_class(self, request):
15-
sb = request.getfixturevalue("sb")
19+
sb: BaseCase = request.getfixturevalue("sb")
1620
sb.open("https://seleniumbase.io/demo_page")
1721
sb.assert_element("input#myTextInput")
1822
sb.type("#myTextarea", "Automated")

examples/test_sb_fixture.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
from seleniumbase import BaseCase
2+
BaseCase.main(__name__, __file__)
3+
4+
15
# "sb" pytest fixture test in a method with no class
2-
def test_sb_fixture_with_no_class(sb):
6+
def test_sb_fixture_with_no_class(sb: BaseCase):
37
sb.open("seleniumbase.io/help_docs/install/")
48
sb.type('input[aria-label="Search"]', "GUI Commander")
59
sb.click('mark:contains("Commander")')
@@ -8,7 +12,7 @@ def test_sb_fixture_with_no_class(sb):
812

913
# "sb" pytest fixture test in a method inside a class
1014
class Test_SB_Fixture:
11-
def test_sb_fixture_inside_class(self, sb):
15+
def test_sb_fixture_inside_class(self, sb: BaseCase):
1216
sb.open("seleniumbase.io/help_docs/install/")
1317
sb.type('input[aria-label="Search"]', "GUI Commander")
1418
sb.click('mark:contains("Commander")')

examples/test_usefixtures.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import pytest
2+
from seleniumbase import BaseCase
3+
BaseCase.main(__name__, __file__)
24

35

46
@pytest.mark.usefixtures("sb")
@@ -7,7 +9,7 @@ def test_usefixtures_on_class(self):
79
if not hasattr(self, "sb"):
810
print("This test is for pytest only!")
911
return
10-
sb = self.sb
12+
sb: BaseCase = self.sb
1113
sb.open("https://seleniumbase.io/realworld/login")
1214
sb.type("#username", "demo_user")
1315
sb.type("#password", "secret_pass")

0 commit comments

Comments
 (0)