Skip to content

PiotrNowek/SwagLabGUITesting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwagLabs Test Crusaders - Mastering Web UI Testing with Selenium

About the Project

Welcome to the ultimate challenge in the world of web UI testing! My mission: to explore and test the SwagLabs e-commerce galaxy using the powerful Selenium framework. Join me on this journey where we leave no bug unchallenged and ensure the SwagLabs experience is flawless!

Goal

When the precision of Selenium meets the vast expanse of SwagLabs, I ensure every click, every product, and every transaction is tested to perfection. My goal is to create robust tests that make the SwagLabs interface run smoother than a droid in peak condition!

Features

  • Selenium WebDriver: My hyperdrive for navigating through the SwagLabs website, ensuring I interact with every element as intended.
  • Pytest: The lightsaber of my testing arsenal, making sure my tests are sharp, efficient, and ready to slice through any bugs.

How to Run

  1. Clone the Repository: Download the code and prepare your test environment.
  2. Install Dependencies: Make sure your test environment is powered up with all the necessary libraries.
  3. Launch Selenium Tests: Engage the engines and watch as our tests cruise through SwagLabs, validating every interaction!

Test Structure

My tests are meticulously organized to ensure clarity, maintainability, and ease of use. Here's the breakdown:

  • tests/: The battleground where my Web UI test cases are executed. May your tests be as accurate as a sharpshooter's aim!

  • drivers/: The hangar where I keep my browser drivers, such as geckodriver for Firefox. These drivers are essential for steering the Selenium WebDriver through the SwagLabs interface.

  • reports/: The archive where I store detailed test reports. Here, you can find logs, screenshots, and summaries of each test run, helping us track the performance and outcomes of my test suite.

  • tests/config/: The command center where I store all the necessary configurations, including browser drivers and URLs. This is the hub that guides my tests through the SwagLabs interface with precision.

  • tests/conftest.py: The strategic base where shared fixtures and configurations reside, ensuring my tests are streamlined and efficient.

Example Tests

"""Test of completing the checkout and order process successfully after login to system with valid data"""
from selenium import webdriver
from selenium.webdriver.common.by import By

from conftest import setup
from pages.login_page import LoginPage
from pages.inventory_page import InventoryPage


def test_checkout(setup):
    try:
        driver = setup

        """Login to system with valid data"""
        login_page = LoginPage(driver)
        login_page.login("standard_user", "secret_sauce")

        """Verification that login was successful"""
        inventory_page = InventoryPage(driver)
        assert "inventory.html" in driver.current_url, "Login failed or incorrect page loaded"
        assert inventory_page.get_header_title() == "Products", "Login successful but incorrect page title"

        """Add the first product to the cart"""
        product_name1 = "Sauce Labs Backpack"
        driver.find_element(By.ID, "add-to-cart-sauce-labs-backpack").click()

        """Add the second product to the cart"""