LayoutTitle

Hoverable Dropdown

Sunday, September 28, 2025

Python Test Automation Engineer: Complete Setup Guide

 

1. Install Python

🔹 Steps:

  1. Download Python (latest stable, e.g., 3.12.x)
    👉 https://www.python.org/downloads/

  2. During installation:

    • ✅ Check “Add Python to PATH”

    • ✅ Install pip (package manager)

  3. Verify installation:

    python --version pip --version

2. Set Up Environment

🔹 Virtual Environment

Always isolate projects using venv or pipenv.

# Create virtual environment python -m venv venv # Activate (Windows) venv\Scripts\activate # Activate (Linux/Mac) source venv/bin/activate

You should see (venv) in your terminal.

🔹 Install Core Packages

pip install pytest selenium requests pytest-html

Optional (for advanced use):

pip install allure-pytest pytest-xdist

3. Start with a Small Example

🔹 Web Automation Example (Selenium + pytest)

  1. Install browser driver (e.g., ChromeDriver).

  2. Create test_google.py:

from selenium import webdriver from selenium.webdriver.common.by import By def test_google_search(): driver = webdriver.Chrome() driver.get("https://www.google.com") search_box = driver.find_element(By.NAME, "q") search_box.send_keys("Python Test Automation") search_box.submit() assert "Python" in driver.title driver.quit()
  1. Run test:

pytest -v --html=report.html

👉 Generates report.html with results.


4. API Automation Example (pytest + requests)

Create test_api.py:

import requests def test_github_api(): response = requests.get("https://api.github.com") assert response.status_code == 200 assert "current_user_url" in response.json()

Run:

pytest -v

5. Build a Mini Automation Framework (Skeleton)

Project Structure:

automation/ │── tests/ │ ├── test_ui.py │ ├── test_api.py │── pages/ │ ├── base_page.py │ ├── login_page.py │── utils/ │ ├── config.py │ ├── logger.py │── conftest.py │── requirements.txt │── pytest.ini
  • tests/ → UI + API test cases

  • pages/ → Page Object Model for UI

  • utils/ → Config, helpers

  • conftest.py → pytest fixtures

  • pytest.ini → markers, test configs

✅ This is a reusable base for real projects.


6. Integrate with CI/CD

🔹 Option A: Jenkins

  1. Install Jenkins (download)

  2. Install plugins:

    • Git Plugin

    • Pytest Plugin (or Allure)

  3. Create a Jenkins Job:

    • Pull code from GitHub

    • Add build step:

      pip install -r requirements.txt pytest -v --html=report.html
    • Archive report.html as test report.


🔹 Option B: GitHub Actions

  1. In your repo, create .github/workflows/python-tests.yml:

name: Python Test Automation on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install dependencies run: | pip install -r requirements.txt - name: Run Tests run: pytest -v --html=report.html
  1. Push code → GitHub Actions runs tests automatically.


7. Scaling Up

  • Add parallel execution: pytest -n 4 (with pytest-xdist)

  • Add cross-browser testing: BrowserStack/Sauce Labs integration

  • Add Allure Reports for rich reporting

  • Add Dockerfile to containerize the framework


Summary Roadmap

  1. Install Python + pip + venv

  2. Install pytest, selenium, requests

  3. Write UI & API tests

  4. Create framework structure

  5. Integrate with CI/CD (Jenkins/GitHub Actions)

  6. Scale with parallel execution, cloud, reporting