Pular para o conteúdo

LambdaTest Cheat Sheet

Overview

LambdaTest is a cloud-based testing infrastructure platform that allows developers and QA teams to perform manual and automated cross-browser testing across 3000+ browser-OS combinations. It provides a scalable Selenium Grid, Cypress testing cloud, Playwright integration, and real device testing for both web and mobile applications.

LambdaTest offers features including parallel test execution, geolocation testing, network simulation, visual regression testing with Smart UI, and integrations with CI/CD tools, project management platforms, and communication tools. It supports Selenium, Cypress, Playwright, Puppeteer, Appium, and Espresso test frameworks.

Installation

# LambdaTest Tunnel (local testing)
# Linux
wget https://downloads.lambdatest.com/tunnel/v3/linux/64bit/LT_Linux.zip
unzip LT_Linux.zip

# macOS
brew install lambdatest/tap/lambdatest-tunnel

# Selenium WebDriver (Node.js)
npm install selenium-webdriver

# Cypress integration
npm install -D lambdatest-cypress-cli

# Playwright
npm install -D @playwright/test

LambdaTest Tunnel

# Start tunnel
./LT --user YOUR_USERNAME --key YOUR_ACCESS_KEY

# Named tunnel
./LT --user YOUR_USERNAME --key YOUR_ACCESS_KEY \
  --tunnelName my-tunnel

# With proxy
./LT --user YOUR_USERNAME --key YOUR_ACCESS_KEY \
  --proxy-host proxy.example.com \
  --proxy-port 8080

# Shared tunnel for team
./LT --user YOUR_USERNAME --key YOUR_ACCESS_KEY \
  --shared-tunnel

Selenium Automation

const { Builder } = require("selenium-webdriver");

const capabilities = {
  browserName: "Chrome",
  browserVersion: "latest",
  "LT:Options": {
    platform: "Windows 11",
    build: "Build 1.0",
    name: "Homepage Test",
    project: "My Project",
    resolution: "1920x1080",
    network: true,
    console: true,
    video: true,
    visual: true,
    username: process.env.LT_USERNAME,
    accessKey: process.env.LT_ACCESS_KEY,
  },
};

async function runTest() {
  const driver = new Builder()
    .usingServer(
      `https://${process.env.LT_USERNAME}:${process.env.LT_ACCESS_KEY}@hub.lambdatest.com/wd/hub`
    )
    .withCapabilities(capabilities)
    .build();

  try {
    await driver.get("https://example.com");
    const title = await driver.getTitle();

    // Mark test status
    await driver.executeScript(
      `lambda-status=${title ? "passed" : "failed"}`
    );
  } finally {
    await driver.quit();
  }
}

Python

from selenium import webdriver

lt_options = {
    "platform": "Windows 11",
    "build": "Build 1.0",
    "name": "Python Test",
    "video": True,
    "network": True,
    "console": True,
    "w3c": True,
}

options = webdriver.ChromeOptions()
options.browser_version = "latest"
options.set_capability("LT:Options", lt_options)

driver = webdriver.Remote(
    command_executor=f"https://{username}:{access_key}@hub.lambdatest.com/wd/hub",
    options=options,
)

driver.get("https://example.com")
driver.execute_script("lambda-status=passed")
driver.quit()

Cypress Integration

# Initialize LambdaTest config
npx lambdatest-cypress init

# Run Cypress tests on LambdaTest
npx lambdatest-cypress run
{
  "lambdatest_auth": {
    "username": "YOUR_USERNAME",
    "access_key": "YOUR_ACCESS_KEY"
  },
  "browsers": [
    {
      "browser": "Chrome",
      "platform": "Windows 11",
      "versions": ["latest"]
    },
    {
      "browser": "Firefox",
      "platform": "macOS Sonoma",
      "versions": ["latest"]
    }
  ],
  "run_settings": {
    "cypress_config_file": "cypress.config.js",
    "build_name": "Cypress Build",
    "parallels": 5,
    "specs": "cypress/e2e/**/*.cy.js"
  }
}

Playwright Integration

// playwright.config.js
const { defineConfig } = require("@playwright/test");

module.exports = defineConfig({
  use: {
    connectOptions: {
      wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(
        JSON.stringify({
          browserName: "Chrome",
          browserVersion: "latest",
          "LT:Options": {
            platform: "Windows 11",
            build: "Playwright Build",
            name: "PW Test",
            username: process.env.LT_USERNAME,
            accessKey: process.env.LT_ACCESS_KEY,
          },
        })
      )}`,
    },
  },
});

Capabilities Reference

CapabilityDescription
platformOS (Windows 11, macOS Sonoma, etc.)
browserNameChrome, Firefox, Safari, Edge, etc.
browserVersionVersion number or “latest”
resolutionScreen resolution (1920x1080, etc.)
videoRecord video (true/false)
visualCapture screenshots (true/false)
networkCapture network logs (true/false)
consoleCapture console logs (true/false)
tunnelUse LambdaTest tunnel (true/false)
tunnelNameNamed tunnel identifier
geoLocationCountry code for geolocation testing
timezoneTimezone for testing
idleTimeoutSession idle timeout in seconds
selenium_versionSelenium version to use

Advanced Usage

Geolocation Testing

const capabilities = {
  "LT:Options": {
    geoLocation: "US",
    timezone: "US/Eastern",
    // ...
  },
};

Network Throttling

const capabilities = {
  "LT:Options": {
    networkThrottling: "Regular 4G",
    // Options: Regular 2G, Good 2G, Regular 3G, Good 3G,
    //          Regular 4G, DSL, WiFi, Custom
  },
};

Parallel Testing

# Run parallel Selenium tests
# Configure parallelism in your test runner
# LambdaTest handles concurrent sessions

# Check concurrency limits
curl -u "USERNAME:ACCESS_KEY" \
  https://api.lambdatest.com/automation/api/v1/platforms

API Reference

# List builds
curl -u "USERNAME:ACCESS_KEY" \
  https://api.lambdatest.com/automation/api/v1/builds

# Get session details
curl -u "USERNAME:ACCESS_KEY" \
  https://api.lambdatest.com/automation/api/v1/sessions/SESSION_ID

# Delete session
curl -X DELETE -u "USERNAME:ACCESS_KEY" \
  https://api.lambdatest.com/automation/api/v1/sessions/SESSION_ID

# Stop session
curl -X PUT -u "USERNAME:ACCESS_KEY" \
  https://api.lambdatest.com/automation/api/v1/sessions/SESSION_ID/stop

Configuration

# Environment variables
export LT_USERNAME="your_username"
export LT_ACCESS_KEY="your_access_key"
export LT_BUILD_NAME="CI Build #${BUILD_NUMBER}"

# GitHub Actions integration
# .github/workflows/lambdatest.yml
# name: LambdaTest
# on: [push]
# jobs:
#   test:
#     runs-on: ubuntu-latest
#     steps:
#       - uses: actions/checkout@v4
#       - uses: LambdaTest/LambdaTest-tunnel-action@v2
#         with:
#           user: ${{ secrets.LT_USERNAME }}
#           accessKey: ${{ secrets.LT_ACCESS_KEY }}
#           tunnelName: "github-tunnel"
#       - run: npm test

Troubleshooting

IssueSolution
Tunnel connection failedCheck credentials; verify port 443 is open
Session timeoutIncrease idleTimeout capability; default is 90s
Tests queuedCheck plan concurrency limits; reduce parallel count
Video not availableEnsure video: true in capabilities
Geolocation not workingVerify country code is valid; some locations are limited
Selenium version mismatchSpecify selenium_version in LT:Options
Local site not loadingStart tunnel before running tests; use tunnel: true capability
Flaky testsEnable network and console logging for debugging