Skip to main content

Local Testing Using Puppeteer


LambdaTest tunnel feature lets you test private server URLs, locally hosted web apps, and websites on 3000+ real browsers and operating systems. On LambdaTest, you can test plain HTML, CSS, PHP, Python, and other similar web files saved locally. When connecting to corporate firewalls or proxy settings, no restrictions apply to the new LambdaTest tunnel binary. To establish a secure and unique tunnel connection between your system and LambdaTest cloud servers, the LambdaTest tunnel utilizes various protocols like Web Sockets, HTTPS, SSH(Secure Shell), etc.

Learn how to perform local testing using Puppeteer across 40+ real browsers and operating systems.

Puppeteer Testing Of Locally Hosted Websites


You can run Puppeteer testing of locally hosted websites and web apps via LambdaTest tunnel binary.

  1. Clone the LambdaTest-Puppeteer repository on your system.

  2. Install the npm dependencies.

npm install
  1. In order to run your Puppeteer tests, you will need to set your LambdaTest username and access key in the environment variables.

Windows

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

macOS/Linux

export LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
export LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"
  1. To establish a tunnel connection between your local device and LambdaTest, download the binary file based on your OS.
  1. Extract the downloaded binary file.

  2. Navigate to the directory or folder where you extracted the binary file in the Command Prompt.

  3. Run the below command in the terminal.

./LT --user {user's login email} --key {user's access key} --tunnelName {user's tunnel name}
  1. In desired capability, add the capability tunnel: true.

If multiple tunnels are running, you can add tunnel and tunnel ID capabilities.

'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",
'tunnel': false, // Add tunnel configuration if testing locally hosted webpage
'tunnelName': '' // Optional
}
};

You can view test reports for your local tests on the LambdaTest automation dashboard.

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

Book Demo

Help and Support

Related Articles