5
5
6
6
class SwagLabsTests (BaseCase ):
7
7
8
- def login (self , user = "standard_user" ):
8
+ def login (self , username = "standard_user" ):
9
9
""" Login to Swag Labs and verify that login was successful. """
10
10
self .open ("https://www.saucedemo.com/" )
11
- if user not in self .get_text ("#login_credentials" ):
12
- self .fail ("Invalid user for login: %s" % user )
13
- self .update_text ("#user-name" , user )
11
+ if username not in self .get_text ("#login_credentials" ):
12
+ self .fail ("Invalid user for login: %s" % username )
13
+ self .update_text ("#user-name" , username )
14
14
self .update_text ("#password" , "secret_sauce" )
15
15
self .click ('input[type="submit"]' )
16
16
self .assert_element ("#inventory_container" )
@@ -21,10 +21,10 @@ def login(self, user="standard_user"):
21
21
["problem_user" ],
22
22
])
23
23
@pytest .mark .run (order = 1 )
24
- def test_swag_labs_basic_functional_flow (self , user ):
24
+ def test_swag_labs_basic_functional_flow (self , username ):
25
25
""" This test checks functional flow of the Swag Labs store.
26
26
This test is parameterized, and receives the user for login. """
27
- self .login (user = user )
27
+ self .login (username = username )
28
28
29
29
# Verify that the "Test.allTheThings() T-Shirt" appears on the page
30
30
item_name = "Test.allTheThings() T-Shirt"
@@ -48,7 +48,11 @@ def test_swag_labs_basic_functional_flow(self, user):
48
48
self .assert_text (item_name , "div.inventory_item_name" )
49
49
self .assert_exact_text ("1" , "div.cart_quantity" )
50
50
self .assert_exact_text ("REMOVE" , "button.cart_button" )
51
- self .assert_element ("link=CONTINUE SHOPPING" )
51
+ continue_shopping_button = "link=CONTINUE SHOPPING"
52
+ if self .browser == "safari" :
53
+ # Safari sees this element differently
54
+ continue_shopping_button = "link=Continue Shopping"
55
+ self .assert_element (continue_shopping_button )
52
56
53
57
# Checkout - Add info
54
58
self .click ("link=CHECKOUT" )
@@ -72,16 +76,16 @@ def test_swag_labs_basic_functional_flow(self, user):
72
76
self .assert_element ("div.pony_express" )
73
77
self .click ("#shopping_cart_container path" )
74
78
self .assert_element_absent ("div.inventory_item_name" )
75
- self .click ("link=CONTINUE SHOPPING" )
79
+ self .click (continue_shopping_button )
76
80
self .assert_element_absent ("span.shopping_cart_badge" )
77
81
78
82
@parameterized .expand ([
79
83
["standard_user" ],
80
84
["problem_user" ],
81
85
])
82
86
@pytest .mark .run (order = 2 )
83
- def test_swag_labs_products_page_resource_verification (self , user ):
87
+ def test_swag_labs_products_page_resource_verification (self , username ):
84
88
""" This test checks for 404 errors on the Swag Labs products page.
85
89
This test is parameterized, and receives the user for login. """
86
- self .login (user = user )
90
+ self .login (username = username )
87
91
self .assert_no_404_errors ()
0 commit comments