The final project consists of two parts - API tests for https://swapi.dev and UI tests for https://demo.nopcommerce.com/.
This repository contains API tests for the Star Wars universe API. The tests aim to validate the functionality and responses of various API endpoints.
Before running the tests, make sure you have the following prerequisites:
- Python 3.x installed on your system
pippackage manager installed
To install the necessary dependencies, follow these steps:
-
Clone the repository:
git clone https://github.com/chipolina/Otus_final.git
-
Navigate to the project directory:
cd Otus_final -
Create a virtual environment (optional but recommended):
python3 -m venv venv
-
Activate the virtual environment:
-
For Windows:
venv\Scripts\activate.bat
-
For Unix or Linux:
source venv/bin/activate
-
-
Install the required dependencies:
pip install -r requirements.txt
To run the API tests, use the following command:
pytest -m apiThis command will execute all the tests defined in the test_api.py file and display the test results in the console.
You can also run test in several threeds using flag -n {number of threeds or auto}
pytest -m api -n 4To generate allure report use
allure serveReport will be available on address 127.0.0.1:port. You can see full address in your terminal
This repository contains UI tests for Nopcommerce using Selenium with Python. The tests aim to validate the functionality and behavior of several pages in the Nopcommerce e-commerce platform.
Before running the tests, make sure you have the following prerequisites:
- Chrome WebDriver or Firefox WebDriver installed, depending on your preferred browser and installed in folder Otus_final/drivers
To run the API tests, use the following command:
pytest -m uiThis command will execute all the tests defined in the test_ui.py file and display the test results in the console.
You can also run test in several threeds using flag -n {number of threeds or auto}
pytest -m ui -n 4To run the tests with the pytest_addoption function options, you can follow these instructions:
-
Run the tests using the
pytestcommand and specify the options:pytest --browser chrome --drivers_folder /path/to/chromedriver -m ui
Replace the following options with your desired values:
--browser: Specify the browser to run the tests (e.g.,chrome,firefox).--drivers_folder: Specify the path to the WebDriver executable.--stage: Local or remote run (Selenoid).--remote_url: Specify the Selenoid endpoint URL. By default, 127.0.0.1:4444
All option you can see in conftest.py
Note: Make sure to provide the correct paths and URLs for your setup.
-
The tests will be executed using the specified options, and the results will be displayed in the console.
You can also add additional flags or options as needed for your testing environment.
To run test in Jenkins you need to set up jenkins server and start it using official documentation
-
Access the Jenkins Server:
- Open your web browser and go to the Jenkins server URL: http://127.0.0.1:8080/.
-
Create Pipeline:
- Click on "New Item" to create a new Jenkins Pipeline.
- Choose "GitHub project" and enter the project URL as https://github.com/chipolina/Otus_final.git.
- Configure project parameters: Create 'browser' and 'network' parameters with default values 'chrome' and 'host'.
-
Pipeline Configuration:
- In the Pipeline configuration, select "Pipeline script from SCM".
- Set the Repository URL to https://github.com/chipolina/Otus_final.git.
- Specify the Branch as */main.
- Set the Script Path to 'Jenkinsfile'.
-
Save Changes:
- Click "Save" to save your Pipeline configuration changes.
-
Build Job:
- Build the Jenkins job by clicking on "Build with Parameters". Choose the desired values for 'browser' and 'network' parameters 'chrome' and 'host'
-
Report:
- After the build is done you can open attached allure report.