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 11"""Classic Page Object Model with the "sb" fixture."""
2+ from seleniumbase import BaseCase
3+ BaseCase .main (__name__ , __file__ )
24
35
46class 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
1214class 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")' )
Original file line number Diff line number Diff line change 44
55
66class 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" )
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change 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
1519class 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" )
Original file line number Diff line number Diff line change 11"""Overriding the "sb" fixture to override the driver."""
22import 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
7981class 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" )
Original file line number Diff line number Diff line change 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)
26def 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)
1317class 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" )
Original file line number Diff line number Diff line change 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
1014class 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")' )
Original file line number Diff line number Diff line change 11import 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" )
You can’t perform that action at this time.
0 commit comments