For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content

How to Run Your First Puppeteer Test on TestMu AI


If you automate Chrome with Puppeteer over the DevTools Protocol, you can run that same End-to-End (E2E) testing against real browsers and operating systems by connecting to TestMu AI. This gives your Puppeteer scripts access to a browser farm of real browser and OS combinations instead of a single local machine. You point Puppeteer's connect call at the TestMu AI CDP WebSocket endpoint, pass your capabilities, then view every run in the Automation Dashboard.

Prerequisites​


Before you run a test, set up the sample project and your credentials.

Sample repo
  1. Clone the TestMu AI Puppeteer repository on your system.

  2. Install the npm dependencies.

Verified
npm install
  1. Add browserWSEndpoint (the browser endpoint URL) in your test script.
Verified
`wss://cdp.lambdatest.com/puppeteer?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
  1. Set your TestMu AI username and access key in the environment variables. Click the Access Key button at the top-right of the Automation Dashboard to access it.

Windows

Verified
set LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
set LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"

macOS/Linux

Verified
export LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
export LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"

Run Your First Puppeteer Test​


With the project cloned and your credentials set, follow these steps to run a Puppeteer test on the TestMu AI platform.

  1. Clone the TestMu AI Puppeteer sample repository and switch to the cloned directory.
Verified
git clone https://github.com/LambdaTest/puppeteer-sample.git
cd puppeteer-sample
  1. Ensure you have npm dependencies installed.

  2. Configure your TestMu AI authentication credentials.

Once these steps are complete, you can run your first Puppeteer test on TestMu AI.

Test Scenario: The below test script runs on the Chrome browser on Windows 10. It visits the TestMu AI platform, opens the Pricing page, then navigates to the Automation Testing page.

Verified
'use strict';
const { strict } = require('once');
const puppeteer = require('puppeteer');
const expect = require('chai').expect;

(async () => {
const capabilities = {
'browserName': 'Chrome',
'browserVersion': 'latest',
'LT:Options': {
'platform': 'Windows 10',
'build': 'puppeteer-build-1',
'name': 'My first Puppeteer test',
'resolution':'1366x768',
'user': process.env.LT_USERNAME || "Your Username",
'accessKey': process.env.LT_ACCESS_KEY || "Your Access Key",
'network': true
}
};

try {
const browser = await puppeteer.connect({
browserWSEndpoint:
`wss://cdp.lambdatest.com/puppeteer?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`,
});

const page = await browser.newPage();
await page.setViewport({
width: 1024,
height: 768,
deviceScaleFactor: 1,
});
console.log("Navigating to LambdaTest");
await page.goto('https://www.lambdatest.com/');
console.log("Navigating to Pricing");
await page.goto('https://www.lambdatest.com/pricing');
console.log("Navigating to Automation");
await page.goto('https://www.lambdatest.com/automation-testing');
console.log("Closing browser");
await browser.close();

} catch (e) {
console.log("Error - ", e);
}
})();
  1. Run the test with the command below.
Verified
node navigation.js

View Your Puppeteer Test Results​


After a run finishes, the TestMu AI Automation Dashboard is where you see the results of your Puppeteer tests. Click the session name of a test to view the details of the Puppeteer session you just executed. The session view shows Test Name, Test ID, selected configurations, test logs, basic info, input config, and the test session video.

Puppeteer session details showing test name, configurations, logs, and session video

Continue with these related guides to configure and extend your Puppeteer runs on TestMu AI.

Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

×
Schedule Your Personal Demo
Kane CLI terminal

Help and Support

Related Articles