CAPABILITY GENERATOR

LambdaTestAutomation Testing ● Running Serenity Test On Selenium Grid

Running Serenity Test On Selenium Grid


Serenity BDD is an open-source framework that enables you to write cleaner and maintainable tests faster. It provides support for automated web testing. It lets you generate comprehensive test reports, tracks your automated tests, keeps project status tabs, and creates more versatile and easy-to-maintain tests.

This document will help you run Serenity automation tests on LambdaTest cloud Selenium Grid. LambdaTest enables you to run your Serenity automated tests across 2000+ real browsers for desktop & mobile combinations.

Prerequisites


All the code samples in this documentation can be found in the Serenity LambdaTest Repository on GitHub. You can either download or clone the repository to quickly run your tests.

Before starting running your Selenium tests with Serenity, ensure you have the following things installed.

  1. Download Java development environment i.e. JDK 8 or higher. The latest version is recommended.
  2. An IDE(Integrated Development Environment) such as Eclipse or you can use CMD (Command Prompt).
  3. Make sure you have the following Maven dependencies installed.
  4. You can install it by running the following command in the terminal.

  5. To run your Serenity Tests on online Selenium Grid, you would need to set your LambdaTest username and access key in environment variables. You can get it from Automation Dashboard by clicking on the Key button from the top-right. You can set environment variables or update serenity.properties file with your LambdaTest Username and Access Key.
    • For Windows:

    • For Mac/Linux:

Running Your First Serenity Test


To run your first Serenity Test on LambdaTest Selenium Grid, let’s understand our test case scenario, the test case below checks for the word “LambdaTest” on Google and tests if the title of the resultant page is “LambdaTest-Google Search”.

Following below is the GooglePage.java file for the above Test Case Scenario.

Below is the LambdaTestSerenityDriver.java file that shows the integration of Serenity with LambdaTest.

Now run the following command in your terminal/cmd to run your Single Serenity Test on LambdaTest Grid.

Visit your Automation dashboard. You will find your single Serenity test is executed successfully.

Running Parallel Tests With Serenity


Parallel Testing is among the most stimulating features of the LambdaTest Selenium Grid. You can run more than one test case concurrently through parallel testing. This means that parallel testing will allow you to run a whole range of automation test cases. So you’re running a single test scenario across multiple browsers, or you might run different test scenarios across the same browser, but with different browser versions.

To run parallel tests with Serenity,we will run single.feature test case in four different environments Chrome, Firefox, IE, and Safari.

For ParallelChromeTest.java:

For ParallelFirefoxTest.java:

For ParallelIETest.java:

For ParallelSafariTest.java:

Now run the following command in your terminal/cmd to run your Parallel Serenity Test on LambdaTest Grid.

Visit your Automation dashboard. You will find your Parallel Serenity tests are executed successfully.

Note: Get your test coverage by using our Concurrency Test Calculator to know how many concurrent sessions you need.

Running Serenity Tests For Locally Hosted Websites


With Lambda Tunnel, you can perform Serenity tests of your locally hosted websites across 2000+ browsers/OS combinations running on real devices and operating systems. Lambda Tunnel allows you to test your website or web-pages for cross-browser compatibility before making them live.

Lambda Tunnel has several protocols including Web Socket, HTTPS, SSH(Encrypted Shell), etc to help you develop a secure and specialized tunnel connection between your device and LambdaTest cloud servers over corporate firewalls.

For more information, visit our Lambda Tunnel documentation.

To perform the Serenity test you would have to download the tunnel binary. You can find OS-specific instructions to download and set up tunnel binary at the following links.

You would need to update the serenity.properties file by setting the tunnel capibility lt_tunnel to true.

Now run the following command in your terminal/cmd to run your local Serenity Test.

Visit your Automation dashboard. You will find your Local Serenity tests are executed successfully. You can find the blue tunnel icon on the right corner that ensures the tunnel is active.

That’s all! You have successfully executed your Serenity Automation Tests. In case you come across any doubts, feel free to reach out through our 24/7 chat support or you can also drop a mail to [email protected].

Happy testing!