A comprehensive automation testing framework that uses Firecrawl to crawl web applications and automatically generates Robot Framework test cases for UI elements. Designed specifically for VPN-protected applications like MDR Nexus with authentication management.
This framework automatically:
- Crawls web applications using Firecrawl API with VPN and authentication support
- Detects interactive elements (buttons, forms, links) with hover testing
- Generates Robot Framework test cases (
.robot
files) automatically - Creates Python keywords for reusable test components
- Manages locators in centralized
locators.py
files - Executes comprehensive test suites with detailed reporting
π Project Structure
βββ src/ # Core application modules
β βββ session/ # Session & authentication management
β β βββ session_manager.py # Browser session handling
β β βββ auth_detector.py # Authentication detection
β β βββ cookie_manager.py # Session persistence
β β βββ session_validator.py # Session health monitoring
β βββ firecrawl/ # Firecrawl API integration
β β βββ api_client.py # Core API client
β β βββ authenticated_crawler.py # VPN-aware crawler
β β βββ config.py # Configuration management
β β βββ exceptions.py # Custom error handling
β βββ element_analyzer/ # Element detection & classification
β βββ test_generator/ # Test case generation
β βββ locator_manager/ # Locator management
β βββ test_executor/ # Test execution & monitoring
βββ tests/ # Generated test files
β βββ generated/ # Auto-generated .robot files
β βββ keywords/ # Python-based keywords (.py)
β βββ resources/ # Test resources & locators
βββ config/ # Configuration files
βββ docs/ # Documentation & flowcharts
βββ reports/ # Test execution reports
βββ logs/ # Application logs
βββ sessions/ # Session data storage
# Install dependencies
pip install -r requirements.txt
# Install the framework
pip install -e .
export FIRECRAWL_API_KEY="your_firecrawl_api_key_here"
export MDR_USERNAME="your_mdr_username"
export MDR_PASSWORD="your_mdr_password"
target_application:
base_url: "https://mdr.nexus.armorlabs.co/"
requires_vpn: true
vpn_check_url: "https://mdr.nexus.armorlabs.co/health"
authentication:
enabled: true
method: "form_based"
form_auth:
login_url: "https://mdr.nexus.armorlabs.co/login"
username_field: "#username"
password_field: "#password"
submit_button: "button[type='submit']"
firecrawl:
api_key: "${FIRECRAWL_API_KEY}"
base_url: "https://api.firecrawl.dev"
timeout: 60
max_concurrent_requests: 5
from src.session import SessionManager
from src.firecrawl import AuthenticatedCrawler
# Initialize with configuration
config = load_config('config/app_config.yaml')
with SessionManager(config) as session_manager:
with AuthenticatedCrawler(config, session_manager) as crawler:
# Crawl protected application
result = crawler.crawl_authenticated_page(
"https://mdr.nexus.armorlabs.co/dashboard"
)
print(f"Crawl successful: {result['success']}")
urls = [
"https://mdr.nexus.armorlabs.co/dashboard",
"https://mdr.nexus.armorlabs.co/reports",
"https://mdr.nexus.armorlabs.co/settings"
]
results = crawler.crawl_authenticated_urls(urls)
print(f"Crawled {len(results)} URLs successfully")
For VPN-protected applications, ensure:
- VPN Connection: Connect to your VPN before running
- VPN Check URL: Set
vpn_check_url
in configuration - Network Settings: Configure SSL verification and proxy settings
target_application:
requires_vpn: true
vpn_check_url: "https://mdr.nexus.armorlabs.co/health"
network:
verify_ssl: true
vpn_networks:
- "10.0.0.0/8"
- "172.16.0.0/12"
- "192.168.0.0/16"
Configure authentication for protected applications:
authentication:
enabled: true
method: "form_based"
session_persistence: true
max_session_duration: 3600
form_auth:
login_url: "https://your-app.com/login"
username_field: "#username"
password_field: "#password"
submit_button: "input[type='submit']"
indicators:
success_selectors:
- ".dashboard"
- ".user-profile"
failure_selectors:
- ".error-message"
- ".alert-danger"
Configure Firecrawl API settings:
firecrawl:
api_key: "${FIRECRAWL_API_KEY}"
base_url: "https://api.firecrawl.dev"
timeout: 60
max_retries: 3
rate_limit_per_minute: 100
max_concurrent_requests: 5
crawl_options:
include_html: true
include_raw_html: true
include_metadata: true
include_links: true
wait_for: 2000
screenshot: false
mobile: false
The framework generates several types of files:
*** Settings ***
Documentation Auto-generated login functionality tests
Library SeleniumLibrary
Resource ../resources/common_keywords.robot
Variables ../resources/locators.py
*** Test Cases ***
Verify Login Button Functionality
[Documentation] Test login button click behavior
[Tags] login button automated firecrawl
Click Element With Validation ${LOGIN_BUTTON}
Wait For Page Load
Verify Login Form Visible
from robot.api.deco import keyword
from selenium import webdriver
@keyword("Click Element With Validation")
def click_element_with_validation(locator):
"""Custom keyword for clicking with validation"""
# Scroll element into view
# Verify element is clickable
# Click with error handling
pass
@keyword("Verify Authentication State")
def verify_authentication_state():
"""Verify user is properly authenticated"""
pass
# Auto-generated locators for MDR Nexus Application
# Generated on: 2024-01-15 10:30:00
# Login Page Elements
LOGIN_BUTTON = "//button[@type='submit' and contains(text(), 'Login')]"
USERNAME_FIELD = "//input[@id='username']"
PASSWORD_FIELD = "//input[@type='password']"
# Dashboard Elements
DASHBOARD_MENU = "//nav[@class='dashboard-menu']"
USER_PROFILE = "//div[@class='user-profile']"
LOGOUT_BUTTON = "//a[contains(text(), 'Logout')]"
# Reports Section
REPORTS_TABLE = "//table[@id='reports-table']"
EXPORT_BUTTON = "//button[contains(text(), 'Export')]"
The framework follows this automated workflow:
graph TD
A[Initialize Session] --> B[Verify VPN Connection]
B --> C[Perform Authentication]
C --> D[Crawl Pages with Firecrawl]
D --> E[Analyze Elements with Hover Testing]
E --> F[Generate XPath Locators]
F --> G[Create Robot Framework Tests]
G --> H[Generate Python Keywords]
H --> I[Execute Test Suite]
I --> J[Generate Reports]
- Session Initialization: Start browser session with VPN verification
- Authentication: Detect and handle login forms automatically
- Page Crawling: Use Firecrawl API to extract page structure and content
- Element Analysis: Identify interactive elements with hover testing
- Test Generation: Create Robot Framework test cases for each element
- Keyword Creation: Generate reusable Python keywords
- Locator Management: Centralize all element selectors
- Test Execution: Run generated test suite with reporting
# Run all generated tests
robot tests/generated/
# Run specific test suite
robot tests/generated/login_tests.robot
# Run with specific tags
robot --include automated tests/generated/
# Generate detailed reports
robot --outputdir reports tests/generated/
# Get crawling statistics
crawler_stats = crawler.get_session_stats()
print(f"URLs crawled: {crawler_stats['urls_crawled']}")
print(f"Success rate: {crawler_stats['success_rate']}%")
# Get API client statistics
api_stats = crawler.firecrawl_client.get_stats()
print(f"Requests made: {api_stats['requests_made']}")
print(f"Rate limited: {api_stats['rate_limited_count']} times")
Error: VPN connectivity verification failed
Solution:
- Ensure VPN is connected and active
- Verify VPN check URL is accessible
- Check network configuration settings
Error: Authentication failed with provided credentials
Solution:
- Verify credentials in environment variables
- Check authentication configuration selectors
- Ensure login form is properly detected
Error: Rate limit exceeded
Solution:
- Check API key validity
- Reduce
max_concurrent_requests
in config - Increase
rate_limit_per_minute
if you have higher limits
Error: No interactive elements found
Solution:
- Ensure page is fully loaded before analysis
- Check
wait_for
setting in crawl options - Verify JavaScript is enabled
Enable debug logging for troubleshooting:
import logging
logging.basicConfig(level=logging.DEBUG)
# Enable detailed Firecrawl logging
from src.firecrawl import setup_logging
setup_logging('DEBUG')
Store sensitive data in environment variables:
# Required
export FIRECRAWL_API_KEY="fc_your_api_key_here"
export MDR_USERNAME="your_username"
export MDR_PASSWORD="your_secure_password"
# Optional
export VPN_USERNAME="vpn_user"
export VPN_PASSWORD="vpn_pass"
- Never commit credentials to version control
- Use
.env
files for local development (git-ignored) - Use secure credential storage in production
- Rotate API keys regularly
- Sessions are encrypted using Fernet encryption
- Session files have restrictive permissions (600)
- Automatic session timeout and cleanup
- VPN verification before each operation
firecrawl:
rate_limit_per_minute: 100 # Adjust based on your plan
max_concurrent_requests: 5 # Balance speed vs. stability
timeout: 60 # Adjust for slow pages
# Adjust concurrency for your system
crawler.crawl_authenticated_urls(
urls,
max_workers=3 # Lower for VPN/auth scenarios
)
authentication:
session_persistence: true
max_session_duration: 3600 # 1 hour cache
- Follow Existing Patterns: Use comprehensive documentation and error handling
- Add Tests: Include unit tests for new functionality
- Update Documentation: Keep README and docstrings current
- Security First: Never commit credentials or sensitive data
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Check the troubleshooting section above
- Review configuration examples in
/config/
- Check logs in
/logs/
directory - Ensure all prerequisites are met (VPN, authentication, API key)
π Happy Testing with Firecrawl Automation Framework!