File tree Expand file tree Collapse file tree 8 files changed +31
-17
lines changed Expand file tree Collapse file tree 8 files changed +31
-17
lines changed Original file line number Diff line number Diff line change 1
1
"""Classic Page Object Model with the "sb" fixture."""
2
+ from seleniumbase import BaseCase
3
+ BaseCase .main (__name__ , __file__ )
2
4
3
5
4
6
class LoginPage :
5
- def login_to_swag_labs (self , sb , username ):
7
+ def login_to_swag_labs (self , sb : BaseCase , username ):
6
8
sb .open ("https://www.saucedemo.com" )
7
9
sb .type ("#user-name" , username )
8
10
sb .type ("#password" , "secret_sauce" )
9
11
sb .click ('input[type="submit"]' )
10
12
11
13
12
14
class MyTests :
13
- def test_swag_labs_login (self , sb ):
15
+ def test_swag_labs_login (self , sb : BaseCase ):
14
16
LoginPage ().login_to_swag_labs (sb , "standard_user" )
15
17
sb .assert_element ("div.inventory_list" )
16
18
sb .assert_element ('div:contains("Sauce Labs Backpack")' )
Original file line number Diff line number Diff line change 4
4
5
5
6
6
class LoginPage :
7
- def login_to_swag_labs (self , sb , username ):
7
+ def login_to_swag_labs (self , sb : BaseCase , username ):
8
8
sb .open ("https://www.saucedemo.com" )
9
9
sb .type ("#user-name" , username )
10
10
sb .type ("#password" , "secret_sauce" )
Original file line number Diff line number Diff line change @@ -301,11 +301,7 @@ def test_all_your_base_are_belong_to_us(self):
301
301
302
302
self .open ("https://git-scm.com/" )
303
303
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 )
309
305
310
306
self .open ("https://pragprog.com/" )
311
307
self .set_text_content ("header p" , aybabtu )
Original file line number Diff line number Diff line change
1
+ from seleniumbase import BaseCase
2
+ BaseCase .main (__name__ , __file__ )
3
+
4
+
1
5
# "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 ):
3
7
sb .open ("seleniumbase.io/simple/login" )
4
8
sb .type ("#username" , "demo_user" )
5
9
sb .type ("#password" , "secret_pass" )
@@ -13,7 +17,7 @@ def test_sb_fixture_with_no_class(sb):
13
17
14
18
# "sb" pytest fixture test in a method inside a class
15
19
class Test_SB_Fixture :
16
- def test_sb_fixture_inside_class (self , sb ):
20
+ def test_sb_fixture_inside_class (self , sb : BaseCase ):
17
21
sb .open ("seleniumbase.io/simple/login" )
18
22
sb .type ("#username" , "demo_user" )
19
23
sb .type ("#password" , "secret_pass" )
Original file line number Diff line number Diff line change 1
1
"""Overriding the "sb" fixture to override the driver."""
2
2
import pytest
3
+ from seleniumbase import BaseCase
4
+ BaseCase .main (__name__ , __file__ )
3
5
4
6
5
7
@pytest .fixture ()
@@ -66,7 +68,7 @@ def tearDown(self):
66
68
sb ._needs_tearDown = False
67
69
68
70
69
- def test_override_fixture_no_class (sb ):
71
+ def test_override_fixture_no_class (sb : BaseCase ):
70
72
sb .open ("https://seleniumbase.io/demo_page" )
71
73
sb .type ("#myTextInput" , "This is Automated" )
72
74
sb .set_value ("input#mySlider" , "100" )
@@ -77,7 +79,7 @@ def test_override_fixture_no_class(sb):
77
79
78
80
79
81
class TestOverride :
80
- def test_override_fixture_inside_class (self , sb ):
82
+ def test_override_fixture_inside_class (self , sb : BaseCase ):
81
83
sb .open ("https://seleniumbase.io/demo_page" )
82
84
sb .type ("#myTextInput" , "This is Automated" )
83
85
sb .set_value ("input#mySlider" , "100" )
Original file line number Diff line number Diff line change
1
+ from seleniumbase import BaseCase
2
+ BaseCase .main (__name__ , __file__ )
3
+
4
+
1
5
# Use the pytest "request" fixture to get the "sb" fixture (no class)
2
6
def test_request_sb_fixture (request ):
3
- sb = request .getfixturevalue ("sb" )
7
+ sb : BaseCase = request .getfixturevalue ("sb" )
4
8
sb .open ("https://seleniumbase.io/demo_page" )
5
9
sb .assert_text ("SeleniumBase" , "#myForm h2" )
6
10
sb .assert_element ("input#myTextInput" )
@@ -12,7 +16,7 @@ def test_request_sb_fixture(request):
12
16
# Use the pytest "request" fixture to get the "sb" fixture (in class)
13
17
class Test_Request_Fixture :
14
18
def test_request_sb_fixture_in_class (self , request ):
15
- sb = request .getfixturevalue ("sb" )
19
+ sb : BaseCase = request .getfixturevalue ("sb" )
16
20
sb .open ("https://seleniumbase.io/demo_page" )
17
21
sb .assert_element ("input#myTextInput" )
18
22
sb .type ("#myTextarea" , "Automated" )
Original file line number Diff line number Diff line change
1
+ from seleniumbase import BaseCase
2
+ BaseCase .main (__name__ , __file__ )
3
+
4
+
1
5
# "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 ):
3
7
sb .open ("seleniumbase.io/help_docs/install/" )
4
8
sb .type ('input[aria-label="Search"]' , "GUI Commander" )
5
9
sb .click ('mark:contains("Commander")' )
@@ -8,7 +12,7 @@ def test_sb_fixture_with_no_class(sb):
8
12
9
13
# "sb" pytest fixture test in a method inside a class
10
14
class Test_SB_Fixture :
11
- def test_sb_fixture_inside_class (self , sb ):
15
+ def test_sb_fixture_inside_class (self , sb : BaseCase ):
12
16
sb .open ("seleniumbase.io/help_docs/install/" )
13
17
sb .type ('input[aria-label="Search"]' , "GUI Commander" )
14
18
sb .click ('mark:contains("Commander")' )
Original file line number Diff line number Diff line change 1
1
import pytest
2
+ from seleniumbase import BaseCase
3
+ BaseCase .main (__name__ , __file__ )
2
4
3
5
4
6
@pytest .mark .usefixtures ("sb" )
@@ -7,7 +9,7 @@ def test_usefixtures_on_class(self):
7
9
if not hasattr (self , "sb" ):
8
10
print ("This test is for pytest only!" )
9
11
return
10
- sb = self .sb
12
+ sb : BaseCase = self .sb
11
13
sb .open ("https://seleniumbase.io/realworld/login" )
12
14
sb .type ("#username" , "demo_user" )
13
15
sb .type ("#password" , "secret_pass" )
You can’t perform that action at this time.
0 commit comments