Robot Framework β SauceDemo Test AutomationΒΆ
A web UI test automation suite for SauceDemo built with Robot Framework and Selenium Library. Tests run in headless Chrome and results are published automatically to GitHub Pages via GitHub Actions.
π FeaturesΒΆ
Core CapabilitiesΒΆ
- UI Testing: Selenium WebDriver through Robot Framework SeleniumLibrary
- Headless Execution: Chrome headless mode (
--headless=new) for CI/CD compatibility - Keyword-Driven: Modular, reusable keywords separated by responsibility
- Reporting: Built-in Robot Framework HTML report and log, auto-deployed to GitHub Pages
- CI/CD Ready: GitHub Actions integration with automated report deployment
Advanced FeaturesΒΆ
- Page Object Pattern: Locators decoupled from keywords into dedicated locator files
- Centralised Variables: All test data, URLs, and timeouts defined in one place
- Clean State Management: Automatic cart cleanup between tests via
Test Teardown - Noise-Free Logging:
Get Element Countand directIFcomparisons avoid false[ FAIL ]log entries - Screenshot on Failure: Automatic page screenshot captured before browser closes on failure
π Framework MetricsΒΆ
- Language: Robot Framework DSL
- Browser Automation: SeleniumLibrary + Selenium WebDriver
- Browser: Google Chrome (headless)
- Python: 3.12
- CI/CD: GitHub Actions
- Report Hosting: GitHub Pages
π Project StructureΒΆ
robot-framework/
βββ .github/
β βββ workflows/
β βββ robot-runner.yml # CI/CD: run tests + deploy report to GitHub Pages
βββ README.md # Project documentation
βββ requirements.txt # Python dependencies
βββ resources/
β βββ saucedemo/
β βββ keywords/ # Reusable business-logic keywords
β β βββ cart_keywords.robot
β β βββ checkout_keywords.robot
β β βββ common_keywords.robot
β β βββ login_keywords.robot
β β βββ product_keywords.robot
β βββ locators/ # Element selectors (CSS / ID), separated from logic
β β βββ cart_locators.robot
β β βββ checkout_locators.robot
β β βββ login_locators.robot
β β βββ product_locators.robot
β βββ variables/ # Centralised test data and configuration
β βββ common_variables.robot
βββ tests/
β βββ saucedemo/
β βββ cart_tests.robot
β βββ checkout_tests.robot
β βββ login_tests.robot
β βββ product_tests.robot
βββ results/ # Generated after a local run (git-ignored)
βββ log.html
βββ output.xml
βββ report.html
ποΈ Directory OverviewΒΆ
| Directory | Purpose |
|---|---|
.github/workflows/ |
GitHub Actions pipeline β runs tests on push/PR and deploys the HTML report to GitHub Pages |
resources/keywords/ |
Custom keywords that combine SeleniumLibrary calls into readable, business-level steps |
resources/locators/ |
CSS and ID selectors for every page element, kept separate from test logic for easy maintenance |
resources/variables/ |
Centralised test data: base URL, credentials, timeouts, product names, prices, and checkout data |
tests/ |
Test cases organised by feature module (login, product, cart, checkout) |
results/ |
Robot Framework output files generated after execution β excluded from version control |
π§ͺ Test CoverageΒΆ
| Module | Test IDs | Tags |
|---|---|---|
| Login | TC_LOGIN_001 β TC_LOGIN_002 | smoke, regression, negative |
| Products | TC_PRD_001 β TC_PRD_008 | smoke, regression |
| Cart | TC_CART_001 β TC_CART_002 | smoke, regression |
| Checkout | TC_CHK_001 β TC_CHK_006 | smoke, regression, negative, e2e |
π οΈ Technologies & DependenciesΒΆ
| Package | Purpose |
|---|---|
robotframework |
Core test framework and DSL runner |
robotframework-seleniumlibrary |
Selenium WebDriver bindings for Robot Framework |
webdriver-manager |
Automatic ChromeDriver version management |
robotframework-pabot |
Parallel test execution support (in development) |
π¦ Getting StartedΒΆ
PrerequisitesΒΆ
- Python 3.7 or higher
- Git
- Google Chrome (stable)
1. Clone the RepositoryΒΆ
2. Create and Activate a Virtual EnvironmentΒΆ
Windows (PowerShell):
Windows (Command Prompt):
macOS / Linux:
3. Install DependenciesΒΆ
4. Verify InstallationΒΆ
βΆοΈ Running TestsΒΆ
Run the Full SuiteΒΆ
This will execute all test files under tests/, save output to results/, and generate three files: log.html, report.html, and output.xml.
Run a Specific ModuleΒΆ
# Login tests
robot --outputdir results tests/saucedemo/login_tests.robot
# Product tests
robot --outputdir results tests/saucedemo/product_tests.robot
# Cart tests
robot --outputdir results tests/saucedemo/cart_tests.robot
# Checkout tests
robot --outputdir results tests/saucedemo/checkout_tests.robot
Run by TagΒΆ
# Smoke tests only
robot --include smoke --outputdir results tests/
# Full regression suite
robot --include regression --outputdir results tests/
# End-to-end tests only
robot --include e2e --outputdir results tests/
# Negative / validation tests only
robot --include negative --outputdir results tests/
# Exclude specific tests
robot --exclude skip --outputdir results tests/
View the Report LocallyΒΆ
start results/report.html # Windows
open results/report.html # macOS
xdg-open results/report.html # Linux
π Test ReportingΒΆ
Robot Framework Built-in ReportsΒΆ
Every test run generates three output files in the results/ directory:
report.htmlβ high-level summary showing pass/fail counts, elapsed time, and tag statisticslog.htmlβ step-by-step execution log with keyword calls, variable values, and screenshotsoutput.xmlβ machine-readable results for integration with external tools
GitHub Pages ReportΒΆ
The CI pipeline automatically deploys the latest report.html to GitHub Pages after every run β including failed runs, so results are always visible.
Access the live report at:
π§ Framework ComponentsΒΆ
Common Keywords (common_keywords.robot)ΒΆ
Core browser lifecycle and element interaction utilities shared across all test suites:
# Browser lifecycle
Open Browser To Login Page # Opens headless Chrome and navigates to login
Close Test Browser # Captures screenshot on failure, then closes browser
# Navigation
Wait Until Page Is Loaded # Polls document.readyState until complete
Navigate To URL ${url} # Go To + wait for page load
Verify Current URL Contains ${fragment}
# Element interactions
Wait And Click Element ${locator}
Wait And Input Text ${locator} ${text}
Wait And Get Text ${locator}
Wait And Select From List By Value ${locator} ${value}
Element Should Be Present ${locator}
Element Should Not Be Present ${locator}
Keyword ModulesΒΆ
| File | Responsibility |
|---|---|
login_keywords.robot |
Fill and submit the login form, assert success/failure messages, logout |
product_keywords.robot |
Cart badge tracking, add/remove items by locator, sort dropdown, product card assertions |
cart_keywords.robot |
Cart page assertions, proceed to checkout, clear all items between tests |
checkout_keywords.robot |
Multi-step checkout flow, field validation errors, order total math verification |
Variables (common_variables.robot)ΒΆ
All configuration values are centralised and referenced via Robot Framework variables:
# Browser & Timeouts
${BROWSER} chrome
${PAGE_LOAD_TIMEOUT} 30 seconds
${ELEMENT_TIMEOUT} 15 seconds
# Credentials
${STANDARD_USER} standard_user
${VALID_PASSWORD} secret_sauce
# URLs
${LOGIN_URL} ${BASE_URL}/
${PRODUCT_URL} ${BASE_URL}/inventory.html
# Product data
${PROD_NAME_BACKPACK} Sauce Labs Backpack
${PROD_PRICE_BACKPACK} $29.99
π Browser ConfigurationΒΆ
Tests run in headless Chrome with the following arguments configured in common_keywords.robot:
| Argument | Reason |
|---|---|
--no-sandbox |
Required inside Linux containers and CI runners |
--disable-dev-shm-usage |
Prevents shared memory crashes on Linux |
--incognito |
Ensures a clean, isolated session for every suite |
--headless=new |
Modern headless mode available from Chrome 112+ |
To run with a visible browser window locally, remove add_argument("--headless=new") from Open Browser To Login Page in resources/saucedemo/keywords/common_keywords.robot.
π CI/CD PipelineΒΆ
The workflow at .github/workflows/robot-runner.yml triggers automatically on every push or pull request to main / master, and can also be triggered manually via workflow_dispatch.
Push
β
βΌ
ββββββββββββββββββββββββββββββββββββββ
β Job 1: test β
β β’ Setup Python 3.12 β
β β’ pip install -r requirements.txt β
β β’ Install Chrome (stable) β
β β’ robot --outputdir results tests/β
β β’ Upload results/ as artifact β
ββββββββββββββββ¬ββββββββββββββββββββββ
β always (pass or fail)
βΌ
ββββββββββββββββββββββββββββββββββββββ
β Job 2: deploy-report β
β β’ Download artifact β
β β’ Create index.html redirect β
β β’ Deploy to GitHub Pages β
ββββββββββββββββββββββββββββββββββββββ
One-Time GitHub Repository SetupΒΆ
- Go to Settings β Pages β Source and select GitHub Actions.
- Go to Settings β Actions β General β Workflow permissions and enable Read and write permissions.
π TroubleshootingΒΆ
Virtual Environment Not ActivatingΒΆ
Ensure you are using the correct path for your OS. On Windows, you may need to allow script execution first:
Module Not Found ErrorΒΆ
Ensure the virtual environment is active and dependencies are installed:
Tests Failing LocallyΒΆ
- Open
results/log.htmlfor a detailed step-by-step breakdown - Verify credentials in
resources/saucedemo/variables/common_variables.robot - Confirm you have a stable internet connection (tests run against the live SauceDemo site)
- Try running without
--headless=newto observe the browser directly
Chrome / ChromeDriver Version MismatchΒΆ
webdriver-manager handles driver downloads automatically. If you encounter a version mismatch, upgrade it:
π€ ContributingΒΆ
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m 'Add your feature' - Push to the branch:
git push origin feature/your-feature - Open a Pull Request
Development GuidelinesΒΆ
- Add new keywords to the appropriate keyword file and keep locators in the matching locator file
- Tag all new test cases with at least one of:
smoke,regression,e2e, ornegative - Ensure the full suite passes locally before opening a PR
- Update this README if adding new modules or changing the project structure
π Quick LinksΒΆ
- Live Test Report: https://fahmi-wiradika.github.io/robot-framework/
- SauceDemo Site: https://www.saucedemo.com
- Robot Framework Docs: https://robotframework.org
- SeleniumLibrary Docs: https://robotframework.org/SeleniumLibrary/
π LicenseΒΆ
This project is licensed under the Apache 2.0 License.
Happy Testing! π