How lambdatest/java-testng-selenium works
Project Type and Purpose
• This is not a full-stack application but an open-source Java TestNG + Selenium automation suite that demonstrates running UI tests against the LambdaTest cloud grid.
• Its primary purpose is to show users how to configure, execute, and report Selenium WebDriver tests on LambdaTest across single or parallel browsers, with optional local-tunnel support.
Key Components from File Structure and README
• src/test/java/com/lambdatest/*.java
→ Test scripts (TestNG test classes) that use Selenium WebDriver.
• single.xml, parallel.xml, mobile.xml
→ TestNG suite definitions for single, parallel, and mobile test configurations.
• pom.xml
→ Maven build and dependency management (TestNG, Selenium, remote-WebDriver client).
• cloudbuild.yaml
→ CI/CD pipeline definition (e.g., Google Cloud Build).
• .gitpod.yml
→ Development workspace automation (Gitpod).
• README.md
→ Documentation on setting credentials, capabilities, and TLS tunnel for local testing.
Main Architectural Components
a. Developer / CI Environment
• Developer Workstation (IDE + Maven)
• CI/CD Pipeline (cloudbuild.yaml)
• Gitpod Workspace (.gitpod.yml)
b. Test Runner
• Maven → TestNG plugin
• TestNG Suite Loader (reads single.xml, parallel.xml, mobile.xml)
c. Test Scripts
• Java Test Classes (TestNGTodo1, 2, 3, TestNGTodoMobile)
d. Selenium WebDriver Client
• DesiredCapabilities configuration (browser, version, platform, tunnel flag)
e. Remote WebDriver Endpoint
• LambdaTest Selenium Grid Hub (https://hub.lambdatest.com/wd/hub)
f. LambdaTest Cloud Infrastructure
• Browser Nodes (Chrome, Firefox, Safari, Mobile)
• LambdaTest Tunnel Service (for local/private URLs)
• Test Result Dashboard (videos, logs, reports)
Relationships and Data Flow
1. Developer pushes code → CI/CD pipeline
→ Installs JDK, Maven → Executes mvn test -D suite=<xml>
2. Maven loads TestNG plugin → parses suite XML → invokes TestNG runner
3. TestNG runner instantiates each test class → builds DesiredCapabilities
4. WebDriver code opens RemoteWebDriver with LT hub URL + credentials
5. LT Grid allocates a browser node → executes WebDriver commands
6. Browser node runs tests, sends DOM events back to WebDriver
7. Test results, logs, screenshots, video are streamed to LambdaTest Dashboard
8. If “tunnel=true” capability is set, WebDriver traffic is proxied through a local SSH tunnel binary to access private URLs.
Architectural Patterns & Design Principles
• Test-oriented layering:
Test Runner → Test Scripts → WebDriver Client → Remote Grid
• Parallel execution courtesy of TestNG’s parallel="tests" attribute in XML.
• Decoupling of configuration (suite XML, environment variables for credentials) from code.
• CI/CD integration via a cloudbuild.yaml to ensure repeatability and traceability.