|
5 | 5 | from pages.inventory_page import InventoryPage |
6 | 6 | from pages.login_page import LoginPage |
7 | 7 | from pages.cart_page import CartPage |
| 8 | +from pages.checkout_page import CheckoutPage |
8 | 9 | from webdriver_manager.firefox import GeckoDriverManager |
9 | 10 | from config import config_for_login_page |
10 | 11 | from config.config_for_cart_page import PRODUCTS |
| 12 | +import time |
11 | 13 |
|
12 | 14 | @pytest.fixture(scope="function") |
13 | 15 | def cart_page_with_items(request): |
@@ -65,3 +67,20 @@ def test_start_checkout(cart_page_with_items): |
65 | 67 | assert "checkout-step-one.html" in cart_page_with_items.driver.current_url |
66 | 68 | print(f"Current URL after checkout: {cart_page_with_items.driver.current_url}") |
67 | 69 |
|
| 70 | +@pytest.mark.parametrize("first_name, last_name, postal_code", [("Juanito", "Alimana", "1969"), ("Procura", "Peralta", "1997")]) |
| 71 | + |
| 72 | +def test_full_e2e_checkout(cart_page_with_items, first_name, last_name, postal_code): |
| 73 | + cart_page_with_items.start_checkout() |
| 74 | + print(f"URL after start: {cart_page_with_items.driver.current_url}") |
| 75 | + time.sleep(2) |
| 76 | + assert "checkout-step-one.html" in cart_page_with_items.driver.current_url |
| 77 | + time.sleep(1) # Extra buffer for DOM |
| 78 | + checkout = CheckoutPage(cart_page_with_items.driver) |
| 79 | + checkout.fill_info(first_name, last_name, postal_code) |
| 80 | + assert checkout.continue_to_overview() == True |
| 81 | + assert "checkout-step-two.html" in checkout.driver.current_url |
| 82 | + assert checkout.complete_checkout() == True |
| 83 | + assert "checkout-complete.html" in checkout.driver.current_url |
| 84 | + assert "Thank you for your order!" in checkout.driver.page_source |
| 85 | + print(f"E2E complete with user {first_name} {last_name}, final URL: {checkout.driver.current_url}") |
| 86 | + |
0 commit comments