How to Migrate Your Selenium Suite to TestMu AI
Already have Selenium End-to-End (E2E) testing running locally? You can run it on the TestMu AI cloud grid with three changes: swap the driver URL, add your credentials, and set the 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.
- Migrate from BrowserStack to TestMu AI - hub URL, capability mapping, and feature equivalents
- Migrate from Sauce Labs to TestMu AI - hub URL, capability mapping, and feature equivalents
Prerequisites
Make sure you have the following set up before you start.
- Create a TestMu AI account if you don't have one.
- Get your Username and Access Key from the TestMu AI Dashboard.
- 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.
- macOS / Linux
- Windows
export LT_USERNAME="undefined"
export LT_ACCESS_KEY="undefined"
$env:LT_USERNAME="undefined"
$env: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. The values you pass in LT:Options come from the full list of Selenium automation capabilities, so you can tune build name, platform, and logging to match your suite.
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:
- Java
- JavaScript
- Python
- C#
- PHP
- Ruby
Before (local):
VerifiedWebDriver driver = new ChromeDriver();
After (cloud):
VerifiedString 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);
Before (local):
Verifiedconst driver = new Builder().forBrowser('chrome').build();
After (cloud):
Verifiedconst username = process.env.LT_USERNAME;
const accessKey = process.env.LT_ACCESS_KEY;
const hubURL = `https://${username}:${accessKey}@hub.lambdatest.com/wd/hub`;
const capabilities = {
browserName: 'Chrome',
browserVersion: 'latest',
'LT:Options': {
platformName: 'Windows 10',
build: 'My First Cloud Build',
name: 'Sample Test',
w3c: true,
}
};
const driver = new Builder()
.usingServer(hubURL)
.withCapabilities(capabilities)
.build();
Before (local):
Verifieddriver = webdriver.Chrome()
After (cloud):
Verifiedimport os
from selenium import webdriver
username = os.getenv("LT_USERNAME")
access_key = os.getenv("LT_ACCESS_KEY")
hub_url = f"https://{username}:{access_key}@hub.lambdatest.com/wd/hub"
options = webdriver.ChromeOptions()
options.platform_name = "Windows 10"
options.browser_version = "latest"
lt_options = {
"build": "My First Cloud Build",
"name": "Sample Test",
"w3c": True,
}
options.set_capability("LT:Options", lt_options)
driver = webdriver.Remote(command_executor=hub_url, options=options)
Before (local):
VerifiedIWebDriver driver = new ChromeDriver();
After (cloud):
Verifiedstring username = Environment.GetEnvironmentVariable("LT_USERNAME");
string accessKey = Environment.GetEnvironmentVariable("LT_ACCESS_KEY");
string hubURL = $"https://{username}:{accessKey}@hub.lambdatest.com/wd/hub";
var options = new ChromeOptions();
options.PlatformName = "Windows 10";
options.BrowserVersion = "latest";
var ltOptions = new Dictionary<string, object>
{
{ "build", "My First Cloud Build" },
{ "name", "Sample Test" },
{ "w3c", true }
};
options.AddAdditionalOption("LT:Options", ltOptions);
IWebDriver driver = new RemoteWebDriver(new Uri(hubURL), options);
Before (local):
Verified$driver = ChromeDriver::start();
After (cloud):
Verified$username = getenv("LT_USERNAME");
$accessKey = getenv("LT_ACCESS_KEY");
$hubURL = "https://{$username}:{$accessKey}@hub.lambdatest.com/wd/hub";
$capabilities = [
"browserName" => "Chrome",
"browserVersion" => "latest",
"LT:Options" => [
"platformName" => "Windows 10",
"build" => "My First Cloud Build",
"name" => "Sample Test",
"w3c" => true,
]
];
$driver = RemoteWebDriver::create($hubURL, $capabilities);
Before (local):
Verifieddriver = Selenium::WebDriver.for :chrome
After (cloud):
Verifiedusername = ENV["LT_USERNAME"]
access_key = ENV["LT_ACCESS_KEY"]
hub_url = "https://#{username}:#{access_key}@hub.lambdatest.com/wd/hub"
options = Selenium::WebDriver::Options.chrome(
platform_name: "Windows 10",
browser_version: "latest",
"LT:Options": {
build: "My First Cloud Build",
name: "Sample Test",
w3c: true,
}
)
driver = Selenium::WebDriver.for :remote, url: hub_url, capabilities: options
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. If you are new to the grid, first walk through how to run your first Selenium test to confirm your setup before migrating a full suite.
Verified# 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. If a migrated test fails, use these artifacts to debug your Selenium tests and find the cause.
What Stays the Same
Everything except the driver setup. Here is what does not change when you move to the cloud.
| What | Changes? |
|---|---|
| Test logic (assertions, flows, waits) | No |
| Page Object Models | No |
| Test framework config (TestNG XML, pytest.ini, etc.) | No |
| CI/CD pipeline commands | No |
| Driver setup (URL + capabilities) | Yes |
| Local browser install requirement | Removed |
Next Steps
Continue with these related guides:
