This project automates interactions with Amazon's website using Selenium and pytest.
amazon/
: Contains application code.tests/
: Contains test code.requirements.txt
: Project dependencies.README.md
: Project documentation.
Great! Setting up an automation framework using Selenium and Pytest in PyCharm is a structured and efficient way to start. Here's a step-by-step guide to get you going:
- Python: Ensure Python is installed on system. You can download it from python.org.
- PyCharm: Download and install PyCharm from jetbrains.com.
- Open PyCharm and create a new project.
- In the project settings, create a new virtual environment.
- Go to
File
->Settings
->Project: <your_project>
->Python Interpreter
. - Click on the gear icon and select
Add...
. - Choose
New environment
and selectVirtualenv
.
- Go to
Open the terminal in PyCharm and install Selenium and Pytest using pip:
pip install selenium pytest
- Download the appropriate WebDriver for your browser.
- Place the WebDriver in a directory that's included in system's PATH, or provide the path to the WebDriver in your code.
-
Java and Allure CLI Installation:
- Java: Allure requires Java to run, so install Java on local system. This is a one-time installation.
- Allure CLI: The Allure Command-Line Interface (CLI) is also a standalone tool that needs to be install on local system. This allows you to generate and serve Allure reports.
-
Allure-Pytest Plugin:
- Within Your
venv
: The Allure-Pytest plugin is installed within Python virtual environment (venv
). This plugin enables pytest to generate the necessary files (results) that the Allure CLI will use to create reports.
- Within Your
Ensure Java is installed:
java -version
If not installed, download and install it from here.
Follow the steps to install Allure CLI:
-
Download Allure:
- Download from Allure releases.
-
Extract Allure:
- Extract to
C:\allure
.
- Extract to
-
Add to PATH:
- Add
C:\allure\bin
to your system PATH.
- Add
Activate virtual environment and install the Allure-Pytest plugin:
source path/to/venv/bin/activate # or .\venv\Scripts\activate on Windows
pip install allure-pytest
Create or update the pytest.ini
file in project root:
[pytest]
addopts = --alluredir=allure-results
-
Run Your Tests:
pytest
This will generate Allure results in the
allure-results
directory. -
Serve the Allure Report:
allure serve allure-results
- Java and Allure CLI: Install on your local system, not within the
venv
. - Allure-Pytest Plugin: Install within your
venv
. - Configuration and Annotations: Set up pytest to use Allure and annotate your tests.
- Generate and Serve Reports: Use pytest to run tests and the Allure CLI to generate and view reports.