CAPABILITY GENERATOR

LambdaTest DocumentationAutomation Testing ● Cucumberjs With Selenium – Running Cucumberjs Automation Scripts On LambdaTest Selenium Grid

Cucumberjs With Selenium – Running Cucumberjs Automation Scripts On LambdaTest Selenium Grid


LambdaTest Selenium Automation Grid is a cloud-based Selenium testing platform which enables you to run your automation scripts on 2000+ different browsers and operating systems. You can now run your JavaScript Selenium automated test cases on a scalable Selenium infrastructure that is running real browsers and real operating systems.

This post will help you in getting started with configuring and running your JavaScript based automation test scripts on LambdaTest Selenium cloud platform using Cucumberjs. This topic will help you to:

  • Run a sample Selenium Webdriver test using Cucumberjs on LambdaTest Automation.
  • Comprehend and configure Selenium test suite with respect to your capabilities.
  • Selecting the specific browsers to run your test on.
  • To run your test cases in parallel to reduce build times.
  • To test your locally hosted pages.

Prerequisites For Running Cucumberjs and Selenium


Before getting started with Automated Scripts using Selenium with Cucumberjs on LambdaTest Automation, you need to:

  • The first step is to download and install node.js and node package manager or npm. You should be having nodejs v6 or newer. Click here to download.
  • Make sure you have Cucumber installed in your system, you can install it using the below command through npm:
  • Install Cucumber through npm
  • Download Selenium JavaScript bindings from the official Selenium website.
  • Once you download the JavaScript bindings, extract the ZIP file which you’ve downloaded. After extracting the file, you need to add Selenium JavaScript bindings which is a JAR file and all the dependent libraries to your classpath.
  • Download Lambda Tunnel binary file if you wish to test your locally hosted or privately hosted projects.

Installing Selenium Dependencies For Node.js


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

LambdaTest Authentication Credentials


Be aware of your LambdaTest authentication credentials i.e. your LambdaTest username, access key and HubURL. You need to set them up as your environment variables. You can retrieve them from your LambdaTest automation dashboard by clicking on the key icon near the help button.

  • For Windows user:

  • set LT_USERNAME="YOUR_USERNAME"
    set LT_ACCESS_KEY="YOUR ACCESS KEY"

  • For macOS/Linux user:

  • export LT_USERNAME="YOUR_USERNAME"
    export LT_ACCESS_KEY="YOUR ACCESS KEY"

Basic Setup To Run Your Cucumberjs Tests On LambdaTest


First, you need to clone the code from our GitHub repository for Cucumberjs. You can use this repository to find all the code that we will be covering in this topic.

Now create step definition file.

Now create cucumber js runner file.

Now, we need to add username and accesskey in cred.conf.js file located in conf folder. You can export your username and accesskey using 2 ways mentioned below.

Or, you can simply export username and accesskey using the below command as well.

Executing Single Test Of Cucumberjs With Selenium Grid


If you wish to run a single test, execute the below command.

If you wish to set up your Cucumberjs tests through Jenkins, then refer to our Jenkins documentation.

Executing Parallel Tests Of Cucumberjs With Selenium Grid


One of the most important feature of LambdaTest Selenium grid is the ability to run your test cases in parallel. What that means is that if you have more than one concurrent session, you can run your test cases on more than one machine at a time, which greatly cuts down your test times. To put it in perspective, if you have 100 test cases each with an average run time of 1 minute, without parallel testing it would take 100 minutes to execute. However with 2 concurrent session, you can run 2 test cases in parallel at a time and can cut down the build’s test time to 50 minutes. With four concurrent session it would cut down to 25 minutes. With eight, well you got the picture (smile)

Test Your Locally Hosted Cucumberjs Tests With LambdaTest


To help you perform cross browser testing of your locally stored web pages, LambdaTest provides an SSH(Secure Shell) tunnel connection with the name Lambda Tunnel. With Lambda Tunnel, you can execute a test of your locally hosted Cucumberjs tests on cloud to perform automated cross browser testing on 2000+ browsers offered by Selenium Grid on LambdaTest. So you make sure how well your changes look, even before your customers. Curious to know more about Lambda Tunnel?

Download:

Once, the tunnel is successfully set up. You can add the below code to your capabilities for testing internal servers on your network.

Tunnel Capabilities

Follow our documentation on Lambda Tunnel to know it all. OS specific instructions to download and setup tunnel binary can be found at the following links.

Fast track your automated cross browser testing process with Selenide + LambdaTest integration. Happy testing!