Skip to content

E2E, API and Visual Tests with Robot Framework, SeleniumLib, RequestsLib, EyesLib and FakerLib

Notifications You must be signed in to change notification settings

Samska/gen-ai-robot-test

Repository files navigation

Robot Framework Tests Badge ServeRest

GenerativeAI Robot Framework Tests

This is a Robot Framework project for automated testing using GenerativeAI, that is, part or all of this project's content was made based on AI suggestions, I took the liberty of changing some parts. This project uses the following folder structure:

gen-ai-robot-test/                     
 ├── .github/                               
 │    ├── workflows/                        
 │        ├── robot.yml                     # Configuration for the tests on CI
 ├── config/                               
 │    ├── requirements.txt                  # Required dependencies for the tests
 │    ├── settings.robot                    # Libraries used in the tests
 ├── docs/                                  # Any documentation related to the project
 │    ├── chatgpt-interactions/             # Interactions with ChatGPT           
 │        ├── files.png                     # Format in which interactions were saved
 ├── resources/                             # Resources used in the project like keywords and variables
 │    ├── e2e/                              # Test type folder
 │        ├── keywords/                     # Keywords for that test type
 │          ├── test_keywords_common.robot  # Keywords that can be reused in more than one e2e test
 │          ├── test_keywords_signup.robot  # Keywords from a specific page
 │        ├── variables/                    # Variables for that test type
 │          ├── test_variables_common.robot # Variables that can be reused in more than one e2e test
 ├── results/                               # Test results generated by the Robot
 │    ├── log.html
 │    ├── output.xml    
 │    ├── report.html
 ├── support/                               # Any additional files needed for the project
 │    ├── webdriver/  
 │        ├── chromedriver.exe              # Webdriver file that I used in the project
 ├── tests/                                 # Project tests separated by test type folder                                        
 │     ├── e2e/                             # Test type folder
 |        ├── test_ui_signup.robot          # Test script                                          
 │     ├── visual/                          # Test type folder
 |        ├── applitools.yaml               # Configuration for Applitools tests
 |        ├── test_visual_check.robot       # Test script                                                                                       
 ├── .gitignore                             # Untracked folder and files
 ├── README.md                              # README with project overview and instructions

I also have structured this project following the principles of the Page Object Model. This means that for each page of the web application, or for each API endpoint, I have a corresponding class. This class contains the elements of the page or the details of the endpoint, as well as methods for interacting with these elements or endpoints.

The focus is that by following this pattern, we have code reusability, facilitated maintenance, separation of responsibilities, and better readability.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Python 3
  • Pip
  • ChromeDriver

Installing

  1. Clone the repository
  2. Install the dependencies:
pip install -r requirements.txt

Running the Tests

To run the tests, use the following command:

robot --outputdir results tests

This will run all the tests in the tests/ directory and save the report in the results/.

Test Results

The test results will be generated in the results directory. Open the report.html file to view the HTML report.

You can also consult the test results on this page as it is published with each new pipeline run.

Test Configuration

The test configuration can be found in the config directory. The settings.robot file contains the default configuration, which can be overridden using environment variables or command line arguments.