Skip to content

vinayadasepalli/selenium_git

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

# 🧪 Selenium Automation Framework (Python + Pytest + HTML Report)

This project is a simple Selenium automation framework that:
- ✅ Launches Google Search page
- 🔍 Verifies that the search field is visible
- 🧾 Generates an HTML report after test execution
- 🌿 Uses Git for version control
- 🐧 Runs on Linux (tested on Ubuntu)

---

## 📌 Project Structure

selenium_project/

│── tests/

│ └── test_google.py # Selenium test file

│── reports/ # HTML reports will be stored here

│── requirements.txt # Python dependencies

│── README.md # Project documentation

│── .gitignore # Ignored files for Git

└── venv/ # (Optional) Virtual environment


---

## 🛠️ Tech Stack

| Tool / Tech             | Purpose                                              |
|--------------------------|-----------------------------------------------------|
| Python 3.x               | Programming language                                |
| Selenium                 | Browser automation                                 |
| Pytest                   | Test runner framework                              |
| Pytest-HTML              | Test reporting                                     |
| Chrome + ChromeDriver    | Browser & driver for test execution                 |
| Git & GitHub             | Version control and code collaboration              |

---

## ⚙️ 1. Environment Setup (Linux)

### Update and install Python:
```bash
sudo apt update && sudo apt upgrade -y
sudo apt install python3 python3-pip -y

Install Google Chrome:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb

Check Chrome version:

google-chrome --version

Install ChromeDriver (matching Chrome version):

wget https://chromedriver.storage.googleapis.com/<YOUR_VERSION>/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/local/bin/
chmod +x /usr/local/bin/chromedriver

👉 OR use webdriver-manager (auto downloads driver).


🐍 2. Python Setup

Create a virtual environment (optional but recommended):

python3 -m venv venv
source venv/bin/activate

Install dependencies:

pip install -r requirements.txt

If you don’t have a requirements.txt yet, you can install manually:

pip install selenium pytest pytest-html webdriver-manager

Then generate requirements.txt:

pip freeze > requirements.txt

🧪 3. Running Tests

Run all tests:

pytest

Run with HTML report:

pytest --html=reports/test_report.html --self-contained-html

Open report:

xdg-open reports/test_report.html

🧭 4. Git Setup

Initialize Git:

git init

Add and commit files:

git add .
git commit -m "Initial Selenium setup"

Add remote repository (SSH or HTTPS):

git remote add origin git@github.com:<your-username>/<repo-name>.git

Push code:

git branch -M main
git push -u origin main

🧰 5. Example Test: test_google.py

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

def test_google_search_field_visible():
    service = Service(ChromeDriverManager().install())
    driver = webdriver.Chrome(service=service)
    driver.get("https://www.google.com")

    # Verify page loaded
    assert "Google" in driver.title

    # Verify search box is visible
    search_box = driver.find_element(By.NAME, "q")
    assert search_box.is_displayed()

    driver.quit()

🚀 6. Optional Improvements

  • ✅ Implement Page Object Model (POM) for better structure.
  • 🧭 Integrate with GitHub Actions / Jenkins for CI/CD.
  • 📝 Add logging and screenshots for failures.
  • 🌐 Run tests in headless mode to save resources.

🧹 7. .gitignore Example

venv/
__pycache__/
reports/
*.pyc
chromedriver

🏁 Final Result

  • ✔️ Simple and maintainable Selenium project
  • 📊 Detailed HTML test report generated after execution
  • 💻 Compatible with Linux
  • 🔐 Code tracked with Git & pushed to GitHub

📚 References


👨‍💻 Author: Vinaya Dasepalli. 📧 Contributions and improvements are welcome!


---

✅ **Tip:**  
Once you save this `README.md`, you can preview it directly on GitHub after pushing your code.  
This gives your repo a **professional and structured look**.  

Would you like me to also generate a `requirements.txt` file content for you to include in the repo? (so others can set it up easily) 📦✨

About

Testing_selenium_project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published