diff --git a/README.md b/README.md index 1bc44fe..3747195 100644 --- a/README.md +++ b/README.md @@ -1,303 +1,114 @@ -# Run Selenium Tests With JUnit On LambdaTest - -![image](https://user-images.githubusercontent.com/70570645/171432631-dcc31b10-6590-4877-98c0-4ac702fbd441.png) +# Run JUnit Tests with Selenium on TestMu AI (Formerly LambdaTest)

- Blog -   ⋅   - Docs -   ⋅   - Learning Hub -   ⋅   - Newsletter -   ⋅   - Certifications -   ⋅   - YouTube + Made by TestMu AI + JUnit version + Community

-  -  -  - -*Learn how to use JUnit framework to configure and run your Java automation testing scripts on the LambdaTest platform* - -[](https://accounts.lambdatest.com/register?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) - -## Table Of Contents +## Getting Started -* [Pre-requisites](#pre-requisites) -* [Run Your First Test](#run-your-first-test) -* [Parallel Testing With JUnit](#run-parallel-tests-using-junit) -* [Local Testing With JUnit](#testing-locally-hosted-or-privately-hosted-projects) +[TestMu AI](https://www.testmuai.com/) (Formerly LambdaTest) is the world's first full-stack AI Agentic Quality Engineering platform that empowers teams to test intelligently, smarter, and ship faster. Built for scale, it offers a full-stack testing cloud with 10K+ real devices and 3,000+ browsers. With AI-native test management, MCP servers, and agent-based automation, TestMu AI supports Selenium, Appium, Playwright, and all major frameworks. -## Pre-requisites +With TestMu AI (Formerly LambdaTest), you can run Java JUnit tests with Selenium. This sample shows how to configure JUnit + Selenium to run on the TestMu AI cloud. -Before you can start performing Java automation testing with Selenium, you would need to: +- [Sign up on TestMu AI](https://www.testmuai.com/register/) (Formerly LambdaTest). +- Follow the [TestMu AI Documentation](https://www.testmuai.com/support/docs/) for the full setup walkthrough. -- Install the latest **Java development environment** i.e. **JDK 1.6** or higher. We recommend using the latest version. +### Prerequisites -- Download the latest **Selenium Client** and its **WebDriver bindings** from the [official website](https://www.selenium.dev/downloads/). Latest versions of Selenium Client and WebDriver are ideal for running your automation script on LambdaTest Selenium cloud grid. +- Java JDK 1.6 or higher (latest recommended) +- Maven: install from [maven.apache.org](https://maven.apache.org/) or via Homebrew on macOS/Linux +- A [TestMu AI](https://www.testmuai.com/) account with your username and access key -- Install **Maven** which supports **JUnit** framework out of the box. **Maven** can be downloaded and installed following the steps from [the official website](https://maven.apache.org/). Maven can also be installed easily on **Linux/MacOS** using [Homebrew](https://brew.sh/) package manager. +### Setup -- You would have to add the following maven dependency to your `pom.xml` file if working on your local project. - ```xml - - junit - junit - 4.12 - test - - ``` - -### Cloning Repo And Installing Dependencies - -**Step 1:** Clone the LambdaTest’s JUnit-Selenium-Sample repository and navigate to the code directory as shown below: +Clone and install dependencies: ```bash -git clone https://github.com/LambdaTest/junit-selenium-sample -cd junit-selenium-sample -``` - -You may also want to run the command below to check for outdated dependencies. - -```bash -mvn versions:display-dependency-updates -``` - -### Setting Up Your Authentication - -Make sure you have your LambdaTest credentials with you to run test automation scripts. You can get these credentials from the [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) or by your [LambdaTest Profile](https://accounts.lambdatest.com/login?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample). - -**Step 2:** Set LambdaTest **Username** and **Access Key** in environment variables. - -* For **Linux/macOS**: - - ```bash - export LT_USERNAME="YOUR_USERNAME" - export LT_ACCESS_KEY="YOUR ACCESS KEY" - ``` - * For **Windows**: - ```bash - set LT_USERNAME="YOUR_USERNAME" - set LT_ACCESS_KEY="YOUR ACCESS KEY" - ``` - -## Run Your First Test - ->**Test Scenario**: Checkout sample [JUnitTodo.java](https://github.com/LambdaTest/junit-selenium-sample/blob/master/src/test/java/com/lambdatest/JUnitTodo.java) file. This JUnit Selenium script tests a sample to-do list app by marking couple items as done, adding a new item to the list and finally displaying the count of pending items as output. - -### Configuring your Test Capabilities - -**Step 3:** In the test script, you need to update your test capabilities. In this code, we are passing browser, browser version, and operating system information, along with LambdaTest Selenium grid capabilities via capabilities object. The capabilities object in the above code are defined as: - -```java -ChromeOptions browserOptions = new ChromeOptions(); - browserOptions.setCapability("platformName", "Windows 10"); - browserOptions.setCapability("browserVersion", "latest"); - - Map ltOptions = new HashMap<>(); - ltOptions.put("build", "JUnitSampleTestApp"); - ltOptions.put("name", "JUnitSampleTest"); - ltOptions.put("selenium_version", "4.0.0"); - ltOptions.put("project", ""); //Enter Project name here - ltOptions.put("smartUI.project", ""); //Enter smartUI Project name here - ltOptions.put("w3c", true); - ltOptions.put("plugin", "junit-junit"); - ltOptions.put("visual", true); // To enable step by step screenshot - ltOptions.put("network", true); // To enable network logs - ltOptions.put("video", true); // To enable video recording - ltOptions.put("console", true); // To capture console logs - browserOptions.setCapability("LT:Options", ltOptions); +git clone https://github.com/LambdaTest/junit-selenium-sample && cd junit-selenium-sample +mvn compile ``` -You can generate capabilities for your test requirements with the help of our inbuilt [Desired Capability Generator](https://www.lambdatest.com/capabilities-generator/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample). - -### Executing the Test +Set your credentials as environment variables. -**Step 4:** The tests can be executed in the terminal using the following command. +**macOS / Linux:** ```bash -mvn test -P single +export LT_USERNAME="YOUR_USERNAME" +export LT_ACCESS_KEY="YOUR_ACCESS_KEY" +export LT_TUNNEL="YOUR_TUNNEL_NAME" ``` -Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on [LambdaTest automation dashboard](https://automation.lambdatest.com/build). - -## Run Parallel Tests Using JUnit - -Check out the [Parallelized.java](https://github.com/LambdaTest/junit-selenium-sample/blob/master/src/test/java/com/lambdatest/Parallelized.java) class we have used for running our Parallel Tests using JUnit. - - -Check out the [JUnitConcurrentTodo.java](https://github.com/LambdaTest/junit-selenium-sample/blob/master/src/test/java/com/lambdatest/JUnitConcurrentTodo.java) file for executing parallel test using JUnit automation framework. - -### Executing Parallel Tests Using JUnit - -To run parallel tests using **JUnit**, we would have to execute the below command in the terminal: +**Windows:** ```bash -mvn test -P parallel +set LT_USERNAME="YOUR_USERNAME" +set LT_ACCESS_KEY="YOUR_ACCESS_KEY" +set LT_TUNNEL="YOUR_TUNNEL_NAME" ``` -## Testing Locally Hosted Or Privately Hosted Projects - -You can test your locally hosted or privately hosted projects with LambdaTest Selenium grid using LambdaTest Tunnel. All you would have to do is set up an SSH tunnel using tunnel and pass toggle `tunnel = True` via desired capabilities. LambdaTest Tunnel establishes a secure SSH protocol based tunnel that allows you in testing your locally hosted or privately hosted pages, even before they are live. - -Refer our [LambdaTest Tunnel documentation](https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) for more information. - -Here’s how you can establish LambdaTest Tunnel. - -Download the binary file of: -* [LambdaTest Tunnel for Windows](https://downloads.lambdatest.com/tunnel/v3/windows/64bit/LT_Windows.zip) -* [LambdaTest Tunnel for macOS](https://downloads.lambdatest.com/tunnel/v3/mac/64bit/LT_Mac.zip) -* [LambdaTest Tunnel for Linux](https://downloads.lambdatest.com/tunnel/v3/linux/64bit/LT_Linux.zip) - -Open command prompt and navigate to the binary folder. +### Run tests -Run the following command: - -```bash -LT -user {user’s login email} -key {user’s access key} ``` -So if your user name is lambdatest@example.com and key is 123456, the command would be: - -```bash -LT -user lambdatest@example.com -key 123456 +mvn test ``` -Once you are able to connect **LambdaTest Tunnel** successfully, you would just have to pass on tunnel capabilities in the code shown below : -**Tunnel Capability** +View results on your TestMu AI dashboard. -```java -ChromeOptions browserOptions = new ChromeOptions(); - browserOptions.setCapability("platformName", "Windows 10"); - browserOptions.setCapability("browserVersion", "latest"); +### Local testing with TestMu AI Tunnel - Map ltOptions = new HashMap<>(); - ltOptions.put("tunnel", true); -``` +To test locally hosted apps, set up the TestMu AI tunnel. OS-specific guides: -### Run your First SmartUI PDF Local Test -1. Clone the Java-Selenium-Sample repository. -``` -git clone https://github.com/LambdaTest/java-selenium-sample.git -``` -2. Next get into Java-Selenium-Sample folder, and import Lamabdatest SmartUI Credentials. You can get these from lambdatest automation dashboard. -

- For Linux/macOS:: - -``` -export LT_USERNAME="YOUR_USERNAME" -export LT_ACCESS_KEY="YOUR ACCESS KEY" -export PROJECT_TOKEN="YOUR PROJECT TOKEN" -``` -

- For Windows: +- [Local Testing on Windows](https://www.testmuai.com/support/docs/local-testing-for-windows/) +- [Local Testing on macOS](https://www.testmuai.com/support/docs/local-testing-for-macos/) +- [Local Testing on Linux](https://www.testmuai.com/support/docs/local-testing-for-linux/) -``` -set LT_USERNAME="YOUR_USERNAME" -set LT_ACCESS_KEY="YOUR ACCESS KEY" -set PROJECT_TOKEN="YOUR PROJECT TOKEN" -``` -Step 3. Run SmartUI PDF Local test. -``` -mvn test -P smartuiPdfLocal -``` - -### Run your First SmartUI PDF Cloud Test -1. Clone the Java-Selenium-Sample repository. -``` -git clone https://github.com/LambdaTest/java-selenium-sample.git -``` -2. Next get into Java-Selenium-Sample folder, and import Lamabdatest SmartUI Credentials. You can get these from lambdatest automation dashboard. -

- For Linux/macOS:: - -``` -export LT_USERNAME="YOUR_USERNAME" -export LT_ACCESS_KEY="YOUR ACCESS KEY" -export PROJECT_TOKEN="YOUR PROJECT TOKEN" -``` -

- For Windows: +Add the following to your capabilities: -``` -set LT_USERNAME="YOUR_USERNAME" -set LT_ACCESS_KEY="YOUR ACCESS KEY" -set PROJECT_TOKEN="YOUR PROJECT TOKEN" -``` -Step 3. Run SmartUI PDF Local test. -``` -mvn test -P smartuiPdfCloud +```js +tunnel: true, ``` -## Tutorials 📙 +## Contributions -Check out our latest tutorials on JUnit automation testing 👇 +Contributions are welcome. Open an issue to discuss your idea before submitting a pull request. When reporting bugs, include your Java version, OS, and Maven version. -* [JUnit 5 vs TestNG: Choosing the Right Frameworks for Selenium Automation Testing](https://www.lambdatest.com/blog/junit-5-vs-testng/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [TestNG vs JUnit: Which Testing Framework Should You Choose?](https://www.lambdatest.com/blog/testng-vs-junit-which-testing-framework-should-you-choose/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [JUnit With Selenium](https://www.lambdatest.com/blog/automated-testing-with-junit-and-selenium-for-browser-compatibility/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [JUnit Environment Setup](https://www.lambdatest.com/blog/setup-junit-environment/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [How to Run JUnit Selenium Tests Using TestNG?](https://www.lambdatest.com/blog/test-example-junit-and-testng-in-selenium/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [[Complete JUnit 5 Mockito Tutorial for Unit Testing]](https://www.lambdatest.com/blog/junit5-mockito-tutorial/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [Parallel Testing with JUnit 5 and Selenium [Tutorial]](https://www.lambdatest.com/blog/parallel-testing-with-junit5-and-selenium/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [How to Execute JUnit 4 Tests with JUnit 5 [Tutorial]](https://www.lambdatest.com/blog/execute-junit4-tests-with-junit5/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [How to Run JUnit Tests from the Command Line?](https://www.lambdatest.com/blog/run-junit-from-command-line/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [How to Minimize Browsers in Selenium WebDriver Using JUnit?](https://www.lambdatest.com/blog/minimize-browsers-in-selenium-webdriver/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [How to use @RepeatedTest Annotations in JUnit 5?](https://www.lambdatest.com/blog/repeatedtest-annotation-in-junit-5/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [A Comprehensive Guide on JUnit 5 Extensions](https://www.lambdatest.com/blog/junit5-extensions/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [How to Run JUnit Selenium Tests Using TestNG?](https://www.lambdatest.com/blog/test-example-junit-and-testng-in-selenium/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [JUnit Parameterized Test for Selenium Automation with Examples](https://www.lambdatest.com/blog/junit-parameterized-test-selenium/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [JUnit Asserts with Examples](https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [Tutorial on JUnit Annotations with Examples](https://www.lambdatest.com/blog/tutorial-on-junit-annotations-in-selenium-with-examples/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [Automated Testing with JUnit and Selenium for Browser Compatibility](https://www.lambdatest.com/blog/automated-testing-with-junit-and-selenium-for-browser-compatibility/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) +## TestMu AI (Formerly LambdaTest) Community -For video tutorials on Selenium JUnit, please refer to our [JUnit Tutorial Playlist](https://www.youtube.com/playlist?list=PLZMWkkQEwOPn68qzCGJl07ZbnI7Ix5zKU). ▶️ +Connect with testers and developers in the [TestMu AI Community](https://community.testmuai.com/). Ask questions, share what you are building, and discuss best practices in test automation and DevOps. + +## TestMu AI (Formerly LambdaTest) Certifications -Subscribe To Our [LambdaTest YouTube Channel 🔔](https://www.youtube.com/c/LambdaTest) and keep up-to-date on the latest video tutorial around software testing world. +Earn free [TestMu AI Certifications](https://www.testmuai.com/certifications/) for testers, developers, and QA engineers. Validate your skills in Selenium, Cypress, Playwright, Appium, Espresso and more. Industry-recognized, shareable on LinkedIn, and built by practitioners, not marketers. -## Documentation & Resources :books: +## Learning Resources by TestMu AI (Formerly LambdaTest) - -Visit the following links to learn more about LambdaTest's features, setup and tutorials around test automation, mobile app testing, responsive testing, and manual testing. +Learn modern testing through tutorials, guides, videos, and weekly updates: -* [LambdaTest Documentation](https://www.lambdatest.com/support/docs/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [LambdaTest Blog](https://www.lambdatest.com/blog/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) -* [LambdaTest Learning Hub](https://www.lambdatest.com/learning-hub/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) +* [TestMu AI Blog](https://www.testmuai.com/blog/) +* [TestMu AI Learning Hub](https://www.testmuai.com/learning-hub/) +* [TestMu AI on YouTube](https://www.youtube.com/@TestMuAI) +* [TestMu AI Newsletter](https://www.testmuai.com/newsletter/) + +## LambdaTest is Now TestMu AI -## LambdaTest Community :busts_in_silhouette: +On **January 12, 2026**, [LambdaTest evolved to TestMu AI](https://www.testmuai.com/lambdatest-is-now-testmuai/), the world's first fully autonomous **Agentic AI Quality Engineering Platform**. -The [LambdaTest Community](https://community.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) allows people to interact with tech enthusiasts. Connect, ask questions, and learn from tech-savvy people. Discuss best practises in web development, testing, and DevOps with professionals from across the globe 🌎 +Same team. Same infrastructure. Same customer accounts. All existing LambdaTest logins, scripts, capabilities, and integrations continue to work without change. -## What's New At LambdaTest ❓ +Find the new home for [LambdaTest](https://www.testmuai.com). -To stay updated with the latest features and product add-ons, visit [Changelog](https://changelog.lambdatest.com) - -## About LambdaTest +### How LambdaTest Evolved into TestMu AI -[LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) is a leading test execution and orchestration platform that is fast, reliable, scalable, and secure. It allows users to run both manual and automated testing of web and mobile apps across 3000+ different browsers, operating systems, and real device combinations. Using LambdaTest, businesses can ensure quicker developer feedback and hence achieve faster go to market. Over 500 enterprises and 1 Million + users across 130+ countries rely on LambdaTest for their testing needs. +In 2017, we launched LambdaTest with a simple mission: make testing fast, reliable, and accessible. As LambdaTest grew, we expanded into Test Intelligence, Visual Regression Testing, Accessibility Testing, API Testing, and Performance Testing, covering the full depth of the testing lifecycle. -### Features +As software development entered the AI era, testing had to evolve, too. We rebuilt the architecture to be AI-native from the ground up, with autonomous agents that **plan, author, execute, analyze, and optimize tests** while keeping humans in the loop. The platform integrates with your repos, CI, IDEs, and terminals, continuously learning from every code change and development signal. -* Run Selenium, Cypress, Puppeteer, Playwright, and Appium automation tests across 3000+ real desktop and mobile environments. -* Real-time cross browser testing on 3000+ environments. -* Test on Real device cloud -* Blazing fast test automation with HyperExecute -* Accelerate testing, shorten job times and get faster feedback on code changes with Test At Scale. -* Smart Visual Regression Testing on cloud -* 120+ third-party integrations with your favorite tool for CI/CD, Project Management, Codeless Automation, and more. -* Automated Screenshot testing across multiple browsers in a single click. -* Local testing of web and mobile apps. -* Online Accessibility Testing across 3000+ desktop and mobile browsers, browser versions, and operating systems. -* Geolocation testing of web and mobile apps across 53+ countries. -* LT Browser - for responsive testing across 50+ pre-installed mobile, tablets, desktop, and laptop viewports +That evolution earned a new name: **TestMu AI**, built for an AI-first future of quality engineering. TestMu is not a new name for us. It is the name of our annual community conference, which has brought together 100,000+ quality engineers to discuss how AI would reshape testing, long before that became an industry norm. - -[](https://accounts.lambdatest.com/register) +What started as a high-performance cloud testing platform has transformed into an AI-native, multi-agent system powering a connected, end-to-end quality layer. That evolution defined a new identity: LambdaTest evolved into TestMu AI, built for an AI-first future of quality engineering. - -## We are here to help you :headphones: +## Support -* Got a query? we are available 24x7 to help. [Contact Us](mailto:support@lambdatest.com) -* For more info, visit - [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=junit-selenium-sample) +Got a question? Email [support@testmuai.com](mailto:support@testmuai.com) or chat with us 24x7 from our chat portal.