|
7 | 7 | from pages.inventory_page import InventoryPage |
8 | 8 | from pages.cart_page import CartPage |
9 | 9 | from pages.checkout_page import CheckoutPage |
| 10 | +from utils.config import BASE_URL |
10 | 11 | from utils.helpers import load_test_data |
11 | 12 |
|
| 13 | +BASE_URL_NO_SLASH = BASE_URL.rstrip("/") |
| 14 | + |
12 | 15 |
|
13 | 16 | @pytest.mark.checkout |
14 | 17 | class TestCheckout: |
@@ -40,13 +43,13 @@ def test_complete_checkout_flow(self, inventory_page: InventoryPage): |
40 | 43 | checkout_page.continue_to_overview() |
41 | 44 |
|
42 | 45 | # Verify overview page |
43 | | - expect(inventory_page.page).to_have_url("https://www.saucedemo.com/checkout-step-two.html") |
| 46 | + expect(inventory_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/checkout-step-two.html") |
44 | 47 |
|
45 | 48 | # Complete order |
46 | 49 | checkout_page.finish_order() |
47 | 50 |
|
48 | 51 | # Verify order completion |
49 | | - expect(inventory_page.page).to_have_url("https://www.saucedemo.com/checkout-complete.html") |
| 52 | + expect(inventory_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/checkout-complete.html") |
50 | 53 | assert checkout_page.is_checkout_complete(), "Checkout should be complete" |
51 | 54 |
|
52 | 55 | confirmation_message = checkout_page.get_confirmation_message() |
@@ -85,7 +88,7 @@ def test_checkout_missing_first_name(self, inventory_page: InventoryPage): |
85 | 88 | f"Expected error for missing first name. Got: {error_message}" |
86 | 89 |
|
87 | 90 | # Verify still on checkout page |
88 | | - expect(inventory_page.page).to_have_url("https://www.saucedemo.com/checkout-step-one.html") |
| 91 | + expect(inventory_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/checkout-step-one.html") |
89 | 92 |
|
90 | 93 | def test_checkout_missing_last_name(self, inventory_page: InventoryPage): |
91 | 94 | """Test checkout form validation - missing last name.""" |
@@ -154,7 +157,7 @@ def test_cancel_checkout(self, inventory_page: InventoryPage): |
154 | 157 | checkout_page.cancel_checkout() |
155 | 158 |
|
156 | 159 | # Verify return to cart |
157 | | - expect(inventory_page.page).to_have_url("https://www.saucedemo.com/cart.html") |
| 160 | + expect(inventory_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/cart.html") |
158 | 161 | cart_page = CartPage(inventory_page.page) |
159 | 162 | assert cart_page.is_loaded(), "Should be back on cart page" |
160 | 163 |
|
@@ -184,7 +187,7 @@ def test_logout_from_inventory_after_checkout(self, inventory_page: InventoryPag |
184 | 187 | inventory_page.logout() |
185 | 188 |
|
186 | 189 | # Verify redirect to login page |
187 | | - expect(inventory_page.page).to_have_url("https://www.saucedemo.com/") |
| 190 | + expect(inventory_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/") |
188 | 191 |
|
189 | 192 | def test_checkout_with_multiple_items(self, inventory_page: InventoryPage): |
190 | 193 | """Test checkout process with multiple items in cart.""" |
|
0 commit comments