Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: Checkout code
Expand All @@ -30,11 +30,13 @@ jobs:

- name: Run tests
run: |
pytest --html=reports/report.html --self-contained-html -v
python -m pytest --html=reports/report.html --self-contained-html -v
continue-on-error: true
env:
PYTHONPATH: ${{ github.workspace }}

- name: Upload test results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
Expand Down
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"""
import pytest
from playwright.sync_api import Page, expect
from utils.config import STANDARD_USER, STANDARD_PASSWORD
from utils.config import BASE_URL, STANDARD_USER, STANDARD_PASSWORD
from pages.login_page import LoginPage
from pages.inventory_page import InventoryPage

BASE_URL_NO_SLASH = BASE_URL.rstrip("/")


@pytest.fixture(scope="session")
def browser_context_args(browser_context_args):
Expand Down Expand Up @@ -35,7 +37,7 @@ def logged_in_page(login_page: LoginPage) -> Page:
"""
login_page.login(STANDARD_USER, STANDARD_PASSWORD)
# Wait for navigation to inventory page
expect(login_page.page).to_have_url("https://www.saucedemo.com/inventory.html")
expect(login_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/inventory.html")
# Wait for inventory page to be fully loaded
inventory_page = InventoryPage(login_page.page)
inventory_page.is_loaded()
Expand Down
5 changes: 4 additions & 1 deletion tests/test_cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
from playwright.sync_api import expect
from pages.inventory_page import InventoryPage
from pages.cart_page import CartPage
from utils.config import BASE_URL
from utils.helpers import load_test_data

BASE_URL_NO_SLASH = BASE_URL.rstrip("/")


@pytest.mark.cart
class TestCart:
Expand Down Expand Up @@ -164,4 +167,4 @@ def test_proceed_to_checkout_from_cart(self, inventory_page: InventoryPage):
cart_page.proceed_to_checkout()

# Verify navigation to checkout page
expect(inventory_page.page).to_have_url("https://www.saucedemo.com/checkout-step-one.html")
expect(inventory_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/checkout-step-one.html")
13 changes: 8 additions & 5 deletions tests/test_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
from pages.inventory_page import InventoryPage
from pages.cart_page import CartPage
from pages.checkout_page import CheckoutPage
from utils.config import BASE_URL
from utils.helpers import load_test_data

BASE_URL_NO_SLASH = BASE_URL.rstrip("/")


@pytest.mark.checkout
class TestCheckout:
Expand Down Expand Up @@ -40,13 +43,13 @@ def test_complete_checkout_flow(self, inventory_page: InventoryPage):
checkout_page.continue_to_overview()

# Verify overview page
expect(inventory_page.page).to_have_url("https://www.saucedemo.com/checkout-step-two.html")
expect(inventory_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/checkout-step-two.html")

# Complete order
checkout_page.finish_order()

# Verify order completion
expect(inventory_page.page).to_have_url("https://www.saucedemo.com/checkout-complete.html")
expect(inventory_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/checkout-complete.html")
assert checkout_page.is_checkout_complete(), "Checkout should be complete"

confirmation_message = checkout_page.get_confirmation_message()
Expand Down Expand Up @@ -85,7 +88,7 @@ def test_checkout_missing_first_name(self, inventory_page: InventoryPage):
f"Expected error for missing first name. Got: {error_message}"

# Verify still on checkout page
expect(inventory_page.page).to_have_url("https://www.saucedemo.com/checkout-step-one.html")
expect(inventory_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/checkout-step-one.html")

def test_checkout_missing_last_name(self, inventory_page: InventoryPage):
"""Test checkout form validation - missing last name."""
Expand Down Expand Up @@ -154,7 +157,7 @@ def test_cancel_checkout(self, inventory_page: InventoryPage):
checkout_page.cancel_checkout()

# Verify return to cart
expect(inventory_page.page).to_have_url("https://www.saucedemo.com/cart.html")
expect(inventory_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/cart.html")
cart_page = CartPage(inventory_page.page)
assert cart_page.is_loaded(), "Should be back on cart page"

Expand Down Expand Up @@ -184,7 +187,7 @@ def test_logout_from_inventory_after_checkout(self, inventory_page: InventoryPag
inventory_page.logout()

# Verify redirect to login page
expect(inventory_page.page).to_have_url("https://www.saucedemo.com/")
expect(inventory_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/")

def test_checkout_with_multiple_items(self, inventory_page: InventoryPage):
"""Test checkout process with multiple items in cart."""
Expand Down
6 changes: 4 additions & 2 deletions tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
from playwright.sync_api import Page, expect
from pages.login_page import LoginPage
from pages.inventory_page import InventoryPage
from utils.config import STANDARD_USER, STANDARD_PASSWORD, LOCKED_OUT_USER
from utils.config import BASE_URL, STANDARD_USER, STANDARD_PASSWORD, LOCKED_OUT_USER
from utils.helpers import get_user_credentials

BASE_URL_NO_SLASH = BASE_URL.rstrip("/")


@pytest.mark.login
class TestLogin:
Expand All @@ -21,7 +23,7 @@ def test_valid_login(self, login_page: LoginPage):

# Verify redirect to inventory page
inventory_page = InventoryPage(login_page.page)
expect(login_page.page).to_have_url("https://www.saucedemo.com/inventory.html")
expect(login_page.page).to_have_url(f"{BASE_URL_NO_SLASH}/inventory.html")
assert inventory_page.is_loaded(), "Inventory page should be loaded after successful login"

def test_invalid_username(self, login_page: LoginPage):
Expand Down