Skip to main content

Selenium With TestCafe


Run TestCafe tests on the TestMu AI cloud grid. This guide covers setup, running a sample test, configuring capabilities, and testing locally hosted pages.

npm package

Visit the TestMu AI npm package for TestCafe for full details.

Prerequisites


Complete these steps before integrating TestCafe with TestMu AI.

  1. Create a TestMu AI account and get your username and access key from the dashboard.
  2. Add the dependency "testcafe": "<testcafe_version>" in your package.json file.

Step 1: Clone the Sample Project


Install the TestMu AI npm plugin for TestCafe.

npm install testcafe-browser-provider-lambdatest

Step 2: Set Your Credentials


Set your TestMu AI username and access key as environment variables.

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

Step 3: Configure Your Test Capabilities


Configure your tests using environment variables for resolution, build name, and other settings.

VARIABLEDESCRIPTION
LT_TEST_NAMESpecify a name for your test on TestMu AI Selenium Grid.
LT_BUILDSpecify a name for your build on TestMu AI Selenium Grid.
LT_CAPABILITY_PATHSpecify the path of a JSON file that declares additional Desired Capabilities.
"[email protected]:Windows 8.1" : {
"network" : true,
"visual" : true,
"timezone" : "UTC+11:00"
}
Here, [email protected]:Windows 8.1 represents browser alias.
LT_RESOLUTIONPerform cross browser testing on a specific screen resolution in the ${width}x${height} format.
LT_LOGFILEView detailed logs of your automation script execution. Provide a specific path to this file. If you don't provide a path, the logs save in your present working directory by the filename: tunnel.log.
LT_VERBOSESet flag for verbose to either true or false.
LT_PROXY_HOSTA required variable if you perform cross browser testing through proxy. Declare the hostname/IP of proxy.
LT_PROXY_PORTPort of the proxy. Default value for proxy port is 3128.
LT_PROXY_USERUsername for connecting to proxy. Required for using 'proxypass'.
LT_PROXY_PASSPassword for the USERNAME option.
LT_TUNNEL_NAMEHuman readable tunnel identifier (Name of the tunnel).
LT_DIRPath of the local folder you want to test.
LT_SELENIUM_VERSIONBrowser specific capability.
LT_CONSOLESet flag as true or false.
LT_NETWORKSet flag as true or false.
LT_VIDEOSet flag as true or false.
LT_SCREENSHOTSet flag as true or false.
LT_TIMEZONEConfigure tests to run on a custom time zone.
LT_TUNNEL_NUMBERNumber of tunnels to spawn at a time.
LOAD_BALANCED_MODELoad Balanced Mode in TestCafe.
tip

Generate capabilities for your test requirements with the Capabilities Generator.

Step 4: Run the Test


Execute the test using the following command.

Single test:

$ testcafe "lambdatest:[email protected]:Windows 8" 'path/to/test/file.js'

Parallel tests:

$ testcafe "lambdatest:[email protected]:Windows 8","lambdatest:[email protected]:Windows 10" "path/to/test/file.js"

Using the API:

testCafe
.createRunner()
.src('path/to/test/file.js')
.browsers('lambdatest:[email protected]:Windows 8')
.run();

To list all available browser aliases:

testcafe -b lambdatest

Step 5: View Your Results


After running the test, view your results on the TestMu AI Automation Dashboard.

The dashboard provides:

  • Video recordings of each test session
  • Screenshots captured at each step
  • Console logs from the browser
  • Network logs for debugging
  • Detailed command logs

Run TestCafe Tests Using Agent Skills


Use AI coding assistants to generate and run TestCafe tests with the TestMu AI Agent Skill.

The testcafe-skill is part of TestMu AI Agent Skills - structured packages that teach AI coding assistants how to write production-grade test automation.

Install the skill:

git clone https://github.com/LambdaTest/agent-skills.git
cp -r agent-skills/testcafe-skill .claude/skills/

# For Cursor / Copilot
cp -r agent-skills/testcafe-skill .cursor/skills/
tip

Install all available framework skills at once by cloning the repository directly into your tool's skills directory (e.g., .claude/skills/, .cursor/skills/).

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

Book Demo

Help and Support

Related Articles