Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kmd-vignesh/autovd-python-selenium
AutoVD framework for Python with Selenium
https://github.com/kmd-vignesh/autovd-python-selenium
automation pytest python selenium webautomation
Last synced: 28 days ago
JSON representation
AutoVD framework for Python with Selenium
- Host: GitHub
- URL: https://github.com/kmd-vignesh/autovd-python-selenium
- Owner: KMD-Vignesh
- License: mit
- Created: 2024-07-26T16:56:16.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-31T17:12:19.000Z (7 months ago)
- Last Synced: 2024-11-17T08:38:19.648Z (3 months ago)
- Topics: automation, pytest, python, selenium, webautomation
- Language: Python
- Homepage:
- Size: 768 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AutoVD-Python-Selenium
AutoVD-Python-Selenium is a Python-based automation framework designed for web and API testing. It leverages Selenium WebDriver for browser automation and provides a structured approach to creating page objects and test cases.
## Author
```yaml
Name : Vignesh D
Location : Chennai, India
```[![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/vigneshdhakshnamoorthy/)
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Creating a Page Class](#creating-a-page-class)
- [Writing a Test Case](#writing-a-test-case)
- [Configuration](#configuration)
- [Running Tests](#running-tests)
- [VD Report](#vd-report)
- [License](#license)## Installation
To use AutoVD-Python-Selenium, clone the repository and install the required dependencies:
```bash
git clone https://github.com/KMD-Vignesh/AutoVD-Python-Selenium.git
cd AutoVD-Python-Selenium
pip install -r requirements.txt
```## Usage
### Creating a Page Class
To create a page class, define a class that inherits from `PageVD` and initialize it with a `SeleniumVD` instance. Use the `Locator` class to define locators for web elements.
```python
from dataclasses import dataclass
from typing import Selffrom library.helper.vd_selenium import SeleniumVD
from library.interface.vd_page import PageVD
from library.model.vd_class import Locator@dataclass
class LoginPage(PageVD):
def __init__(self, selenium: SeleniumVD) -> None:
super().__init__(selenium=selenium)username_input: Locator = Locator.ID(id="user-name")
password_input: Locator = Locator.ID(id="password")
login_button: Locator = Locator.ID(id="login-button")def login_to_app(self, username: str, password: str) -> Self:
self.selenium.type(locator=self.username_input, type_value=username)
self.selenium.type(locator=self.password_input, type_value=password)
self.selenium.click(locator=self.login_button)
self.selenium.log(message="Action : Logged into Application")
return self
```### Writing a Test Case
To write a test case, use the `pytest` framework and import your page classes. Initialize the page class with a `SeleniumVD` instance and define your test logic.
```python
import pytest
from pages.sauce_lab.main_page import MainPagefrom library.helper.vd_selenium import SeleniumVD
from library.model.vd_config import ConfigVD@pytest.mark.vignesh
@pytest.mark.add_cart
def test_add_cart_badge_validation(selenium: SeleniumVD) -> None:
main_page = MainPage(selenium=selenium)
main_page.open_app(url=ConfigVD.URL.get(key="SauceLab")).login_to_app(
username=ConfigVD.Credentials.get(key="UserName"),
password=ConfigVD.Credentials.get(key="Password"),
).assert_true(condition=main_page.is_main_page_loaded()).add_cart_product(
product_name="Sauce Labs Bike Light"
).assert_true(condition=main_page.get_product_count_badge() == 1).add_cart_product(
product_name="Sauce Labs Backpack"
).assert_true(condition=main_page.get_product_count_badge() == 2).add_cart_product(
product_name="Sauce Labs Onesie"
).assert_true(condition=main_page.get_product_count_badge() == 3)
```## Configuration
Configurations such as URLs and credentials are managed through the `vd_config.yml`(setting/config/vd_config.yml). Ensure you have a configuration file
```yaml
Project:
ProjectName : SauceLabPytest:
IsDryRun : false
IsFailureRerun : false
ParallelCount : 5
IsParallelGroupFile : false
DeleteConftest : true
Tag : add_cartBrowser:
IsHeadless : false
DefaultBrowser : Chrome
IsMultiBrowser : false
DeleteDownloads : true
MultiBrowserList :
- Chrome
- Firefox
- Edge
- SafariAllure:
Generate : true
AutoOpenServer : falseURL:
SauceLab : https://saucedemo.com
SelDev : https://www.selenium.dev/downloads/Credentials:
UserName : standard_user
Password : secret_sauce```
## Running Tests
To run your tests, use the `pytest` command:
```bash
python runner.py
```## VD Report
The framework generates two types of reports:
1. **Current Execution Report**: A detailed report of the most recent test execution.
2. **Trend Report**: A report showing trends over time, allowing you to filter results by date and time for detailed analysis.![VD Trends](vd_trends.gif)
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.