https://github.com/hjsblogger/selenium-automation-python-tutorial
This repo contains implementation that uses Selenium and Pytest to get started with Front-End Automated Testing
https://github.com/hjsblogger/selenium-automation-python-tutorial
automation lambdatest makefile pytest pyunit selenium selenium-pytest selenium-python
Last synced: 30 days ago
JSON representation
This repo contains implementation that uses Selenium and Pytest to get started with Front-End Automated Testing
- Host: GitHub
- URL: https://github.com/hjsblogger/selenium-automation-python-tutorial
- Owner: hjsblogger
- Created: 2024-07-10T11:39:26.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-01-01T11:33:18.000Z (4 months ago)
- Last Synced: 2025-03-24T18:06:01.004Z (about 2 months ago)
- Topics: automation, lambdatest, makefile, pytest, pyunit, selenium, selenium-pytest, selenium-python
- Language: Python
- Homepage:
- Size: 60.5 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tutorial: Automated Testing using Selenium Python
In this 'Automated Testing using Selenium Python Tutorial' repo, we have covered the following usecases:
* Execution of simple Python tests
* Automating keyboard and mouse interactions
* Switching tabs & windows
* Handling drop-downs, radio-buttons, and alerts
* Automating Frame and iFrame interactions## Pre-requisites for test execution
**Step 1**
Create a virtual environment by triggering the *virtualenv venv* command on the terminal
```bash
virtualenv venv
```**Step 2**
Navigate the newly created virtual environment by triggering the *source venv/bin/activate* command on the terminal
```bash
source venv/bin/activate
```**Step 3**
Procure the LambdaTest User Name and Access Key by navigating to [LambdaTest Account Page](https://accounts.lambdatest.com/security). You might need to create an an account on LambdaTest since it is used for running tests on the cloud Grid.
**Step 4**
Add the LambdaTest User Name and Access Key in the *Makefile* that is located in the parent directory. Once done, save the Makefile.

## Dependency/Package Installation
Run the *make install* command on the terminal to install the desired packages (or dependencies) - Pytest, Selenium, etc.
```bash
make install
```
With this, all the dependencies and environment variables are set. Instead of PyUnit/*unittest*, the Pytest framework is used for test execution. The following websites are used for demonstration:
* [LambdaTest Selenium Playground](https://lambdatest.com/selenium-playground)
* [LambdaTest E-commerce Playground](https://ecommerce-playground.lambdatest.io/)Follow the below mentioned steps to run automated tests using Selenium Python:
**Step 1**
Set *EXEC_PLATFORM* environment variable to *cloud*. Trigger the command *export EXEC_PLATFORM=local* on the terminal.
**Step 2**
Trigger the command *make clean* to clean the remove _pycache_ folder(s) and .pyc files
**Step 3**
Trigger the respective *make* command on the terminal to run the test(s). For example, run the command *make mouse_interactions_test* for triggering mouse interaction tests.
As seen above, the test execution was successful and the status is "Completed". You can find the status of test execution in the [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build).
Simply type *make help* on the terminal to know the command for running the intended test(s).
## Have feedback or need assistance?
Feel free to fork the repo and contribute to make it better! Email to [himanshu[dot]sheth[at]gmail[dot]com](mailto:[email protected]) for any queries or ping me on the following social media sites:LinkedIn: [@hjsblogger](https://linkedin.com/in/hjsblogger)
Twitter: [@hjsblogger](https://www.twitter.com/hjsblogger)