This project provides a robust simulation of IRCTC ticket booking automation using Selenium and Python. It leverages locally hosted mock HTML pages to replicate the IRCTC website, enabling safe and controlled testing of automation scripts without interacting with the live platform.
The IRCTC Ticket Booking Automation project is designed to demonstrate and test the automation of ticket booking processes in a simulated environment. By using mock HTML pages and a modular framework, it ensures scalability, maintainability, and safe experimentation.
- Selenium Automation: Automates user interactions for login, train search, ticket booking, and payment workflows using the Page Object Model.
- Mock HTML Pages: Simulates IRCTC website pages locally (
mock_site/
) for safe, repeatable testing. - Cross-Browser Support: Easily run tests on Chrome, Firefox, or Edge using the
--browser
option. - PyTest Integration: Comprehensive test suites with detailed HTML reports for validation.
- Sanity & E2E Tests: Includes both quick sanity scripts and full end-to-end automation flows.
- Logging: Centralized logging of automation and test runs in the
logs/
directory. - Reporting Capabilities: Generates and distributes test reports via email and Telegram.
- Extensible Framework: Modular structure for adding new features, test cases, or workflows.
- Configuration Management: Centralized test data and configuration in the
configurations/
directory.
mock_site/
: Local HTML files simulating IRCTC website pages (login.html
,search.html
,booking.html
,payment.html
).pages/
: Selenium POM classes for interacting with simulated web pages.tests/
: PyTest scripts for validating automation workflows.configurations/
: Test data and configuration scripts.sanity/
: Scripts for quick sanity checks of critical functionalities.report/
: Tools for generating and sending test reports via email and Telegram.logs/
: Log files for automation and sanity test runs.main.py
: Orchestrates the end-to-end ticket booking automation process.requirements.txt
: Lists Python dependencies required for the project.utilities/
: Utility scripts and helpers.
Python 3.8 or higher
Google Chrome browser
ChromeDriver compatible with the installed Chrome version
Mozilla Firefox browser
GeckoDriver compatible with the installed Firefox version
Microsoft Edge browser
EdgeDriver compatible with the installed Edge version
Git (for cloning the repository)
-
Clone the Repository:
git clone https://github.com/mohanmulakalapalli/IRCTC-Ticket-Booking-Bot-Automation.git cd IRCTC-Ticket-Booking-Bot-Automation
-
Install Dependencies:
pip install -r requirements.txt
-
Launch the Mock Website:
- Open the HTML files in
mock_site/
(login.html
,search.html
,booking.html
,payment.html
) using a local server or directly in Google Chrome. - Example: Use Python's HTTP server:
Access at http://localhost:8000/mock_site/login.html.
python -m http.server 8000
- Open the HTML files in
-
Execute the Main Script: To execute the complete ticket booking flow, run the
main.py
script:python3 main.py
This framework supports Chrome, Firefox, and Edge browsers.
To run tests on a specific browser, use the --browser
option:
# For Chrome (default)
pytest tests/
# For Firefox
pytest tests/ --browser=firefox
# For Edge
pytest tests/ --browser=edge
Make sure the corresponding driver (ChromeDriver, GeckoDriver, or EdgeDriver) is installed and available at the specified path in tests/conftest.py
.
Run test suites using PyTest with HTML reporting:
pytest tests/ --html=report/all_tests.html
Individual test cases:
pytest tests/test_login.py --html=report/test_report_login.html
pytest tests/test_search.py --html=report/test_report_search.html
pytest tests/test_booking.py --html=report/test_report_booking.html
pytest tests/test_L_S_B_P.py --html=report/test_report_L_S_B_P.html
pytest tests/test_e2e.py --html=report/test_report_e2e.html
Execute sanity tests for rapid validation:
python3 sanity_report_email.py
-
Email Reports:
- Configure email settings in
sanity_report_email.py
. - Run:
python sanity_report_email.py
- Configure email settings in
-
Telegram Reports:
- Set up your Telegram bot token in
telegram_bot_report.py
. - Run:
python telegram_bot_report.py
- Set up your Telegram bot token in
-
HTML Reports (Interactive):
- PyTest generates interactive HTML reports for each test suite.
- These reports allow you to:
- Filter results by status (Passed, Failed, Skipped, etc.)
- Expand/collapse test details and logs
- View attached screenshots or media for failed steps
- Sort tests by result, name, or duration
- Example command:
pytest tests/ --html=report/all_tests.html
- Example reports:
This project is licensed under the MIT License.
For questions, feedback, or support, please reach out:
- Author: Mulakalapalli Mohana Krishna
- Email: [email protected]
- GitHub: mohanmulakalapalli
This project is for educational and testing purposes only. It does not interact with the live IRCTC website and should not be used for actual ticket booking.