Skip to main content

Migrate Your Selenium Test Suite


Already have Selenium tests running locally? You can run them on the TestMu AI cloud grid with three changes: swap the driver URL, add your credentials, and set the desired capabilities. Your test logic stays the same.

If you are moving from BrowserStack or Sauce Labs, use these dedicated migration guides with capability mapping tables.

Prerequisites


Make sure you have the following set up before you start.

  1. Create a TestMu AI account if you don't have one.
  2. Get your Username and Access Key from the TestMu AI Dashboard.
  3. An existing Selenium test suite in any supported language (Java, JavaScript, Python, C#, PHP, or Ruby).

Step 1: Set Your Credentials


Add your TestMu AI credentials as environment variables so your tests can authenticate with the grid.

export LT_USERNAME="undefined"
export LT_ACCESS_KEY="undefined"

Step 2: Replace Your Local Driver With RemoteWebDriver


Point your tests to the TestMu AI hub instead of launching a local browser.

Find where your test creates the WebDriver instance and replace it with a RemoteWebDriver pointing to the TestMu AI hub URL:

https://{YOUR_USERNAME}:{YOUR_ACCESS_KEY}@hub.lambdatest.com/wd/hub

Here is what the change looks like in each language:

Before (local):

WebDriver driver = new ChromeDriver();

After (cloud):

String username = System.getenv("LT_USERNAME");
String accessKey = System.getenv("LT_ACCESS_KEY");
String hubURL = "https://" + username + ":" + accessKey + "@hub.lambdatest.com/wd/hub";

ChromeOptions browserOptions = new ChromeOptions();
browserOptions.setPlatformName("Windows 10");
browserOptions.setBrowserVersion("latest");

HashMap<String, Object> ltOptions = new HashMap<String, Object>();
ltOptions.put("build", "My First Cloud Build");
ltOptions.put("name", "Sample Test");
ltOptions.put("w3c", true);
browserOptions.setCapability("LT:Options", ltOptions);

WebDriver driver = new RemoteWebDriver(new URL(hubURL), browserOptions);
tip

Use the Capabilities Generator to auto-generate the capabilities code for any browser, version, and OS combination.

Step 3: Run Your Tests


Execute your tests the same way you normally would. The only difference is they now run on the cloud.

# Java (Maven)
mvn test

# JavaScript (npm)
npm test

# Python (pytest)
pytest

# C# (dotnet)
dotnet test

# PHP (PHPUnit)
vendor/bin/phpunit

# Ruby (RSpec)
bundle exec rspec

Step 4: View Your Results


Check the Automation Dashboard to see exactly what happened during your test.

Visit the TestMu AI Automation Dashboard to see your results. Each session captures video playback, screenshots, console logs, network logs, and Selenium command logs.

What Stays the Same


Everything except the driver setup. Here is what does not change when you move to the cloud.

WhatChanges?
Test logic (assertions, flows, waits)No
Page Object ModelsNo
Test framework config (TestNG XML, pytest.ini, etc.)No
CI/CD pipeline commandsNo
Driver setup (URL + capabilities)Yes
Local browser install requirementRemoved

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles