CAPABILITY GENERATOR

LambdaTest DocumentationAutomation Testing ● Quick Guide To Run Node.js Tests on LambdaTest Selenium Grid

Quick Guide To Run Node.js Tests on LambdaTest Selenium Grid


LambdaTest Selenium Automation Grid enables you to perform end-to-end automation tests on a secure, reliable, and scalable Selenium infrastructure. You can run your Node.js automation test scripts on 2000+ browser and operating system environments giving you a higher test coverage and at significantly less built times. This post will help you to quickly get started with running your Node.js test scripts on LambdaTest Selenium automation grid.

Prerequisites


  • The first step is to download and install node.js and node package manager or npm. We recommend using the latest version of node.js.
  • You can download it from here https://nodejs.org/en/
  • If you have npm already installed, you may want to upgrade it to latest version. Here the code you can run in your terminal to upgrade npm.

Installing Selenium Dependencies For Node.js


Next step is to install Selenium dependencies for Node.js using npm. Here’s the command to run:

Sample Node.js and Selenium Test To Get You started


Once you have installed necessary dependencies, you are all set to run your Node.js automation scripts on LambdaTest Selenium grid. To get started you can try out the code below. It’s a simple Node.js scripts that opens up Google.com, search LambdaTest in Google search, and then output the title of the search result page. You can also fork it from our Node.js GitHub repository. Do make sure to create the JS file in the same folder where you have downloaded Selenium.

Do make sure to add the Username and Key in the code below. You can find both these values in profiles section.

Sample Node.js and Selenium Automation Script


You can execute the test from your terminal through this command.

Do note the use of remote webdriver here. We have passed browser environment configurations through capabilities class. You can set your environment details as you wish.

To setup your own choice of environment for the test in the code, you can leverage our Capability Generator tool.

Tear Down: The tear down method helps LambdaTest platform understand when the execution of a test is finished. It’s important to tear down each test or else it will give timeout errors.