Skip to main content

Running Gauge Test Automation On LambdaTest Selenium Grid


The creators of Selenium, Thoughtworks came up with another open-source test framework for handling test automation of web-applications and they named it Gauge. The Gauge test framework helps you to do more acceptance testing with less involvement of code. Like Selenium, Gauge also offers support for various languages such as JavaScript, C#, Ruby, Python, and Java.

This document will help you perform Selenium testing with Gauge framework in Java, over the LambdaTest Selenium Grid.

Prerequisites For Gauge Automation Testing#


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

  • Install Maven.

  • Gauge plugin must be configured with your IDE or Gauge test framework must be installled if you are running test from CMD/Terminal.

  • Make sure you have Java installed in your system. We recommend installing Java 8 or above version for more stable execution.

  • LambdaTest Authentication Credentials

    You will need 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 Linux/Mac:
$ export LT_USERNAME= undefined$ export LT_ACCESS_KEY= undefined
  • For Windows:
$ set LT_USERNAME= undefined$ set LT_ACCESS_KEY= undefined

Note: You can also mention your LambdaTest credentials in env/default.properties file.

Executing Your First Automation Script On LambdaTest using Gauge test framework#


Step 1: Navigate to the LambdaTest Gauge test automation cloned directory.

Step 2: Compile Maven dependencies. Using the below command.

Note: You may also want to run the command below to check for outdated dependencies. Please be sure to verify and review updates before editing your pom.xml file. The updated packages may or may not be compatible with your code.

$ mvn versions:display-dependency-updates

Test Scenario: Go to Google and search for LambdaTest login. After that, verify the page title.

package driver.driver;import com.thoughtworks.gauge.Step;import org.openqa.selenium.By;import org.openqa.selenium.Keys;import org.openqa.selenium.WebDriver;import org.openqa.selenium.WebElement;import org.openqa.selenium.interactions.Actions;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
public class StepImplementation_Google {
    private final WebDriver driver;
    public StepImplementation_Google() {        this.driver = DriverFactory.getDriver();    }
    @Step("User is on Google home page")    public void googlePage() throws InterruptedException {
        driver.get("https://www.google.com/");        driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);    }
    @Step("User search for <loginpage>")    public void searchLogin(String loginpage) throws InterruptedException {
        WebElement input = driver.findElement(By.name("q"));        input.sendKeys(loginpage);
        Actions action = new Actions(driver);        action.sendKeys(Keys.ENTER).build().perform();
        Thread.sleep(2000);
    }
    @Step("Verify the page title")    public void loginTest() throws InterruptedException {
        String title = driver.getTitle();        assertEquals(title,"lambdatest login - Google Search");        Thread.sleep(2000);
    }}

Step 3: Navigate to the cloned gauge-selenium-sample and run either of the following commands in cmd/ terminal:

mvn clean install

Or

mvn test

Testing Locally Hosted Pages Using Gauge Test Framework#


LambdaTest offers an SSH(Secure Shell) tunnel that helps you build a unique and secure connection between your system and our cloud servers so you could perform cross browser testing over your locally hosted web applications. We call it the LambdaTest Tunnel.

OS-specific instructions to download and set up LambdaTest Tunnel binary can be found at the following links:

To execute automated browser testing using the LambdaTest Tunnel you need to set the tunnel flag to true as your desired capabilities. You can set tunnel to true by adding the below capabilities in env/[browser]/lambdatest.properties file:

//For Google ChromeBROWSER = chromeBROWSER_VERSION = 78PLATFORM = WIN10TUNNEL = TRUE

Note: If you wish to change your desired capabilities then you can leverage our Desired Capabilities Generator.

Parallel Testing With Gauge Automation Framework#


LambdaTest GitHub repository for Gauge test framework will help you run parallel testing over our online Selenium Grid. If you look at the cloned repository, you will find the below code for another test scenario.

Test Scenario 2: Open the sample Todo App. Select the desired items and add new item "Yay, we are using the Gauge test automation framework".

package driver.driver;
import com.thoughtworks.gauge.Step;import driver.driver.DriverFactory;import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.openqa.selenium.WebElement;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
public class StepImplementation_ToDo {
    private final WebDriver driver;
    public StepImplementation_ToDo() {        this.driver = DriverFactory.getDriver();    }
  @Step("Open the todo app")  public void gotoApp() throws InterruptedException {
        System.out.println(DriverFactory.getDriver());        driver.get("https://lambdatest.github.io/sample-todo-app/");        String title = driver.getTitle();        assertEquals(title,"Sample page - lambdatest.com");  }
  @Step("Select the desired items")  public void selectItems() throws InterruptedException {
      WebElement itemOne = driver.findElement(By.name("li1"));      itemOne.click();
      driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
      WebElement itemThird = driver.findElement(By.name("li3"));      itemThird.click();  }
  @Step("Add new item <itemName>")  public void addNewItem(String itemName) throws InterruptedException {
      WebElement addItem  = driver.findElement(By.id("sampletodotext"));      addItem.sendKeys(itemName);      Thread.sleep(2000);
      WebElement addButton = driver.findElement(By.id("addbutton"));      addButton.click();  }}

Navigate to the cloned gauge-selenium-sample and run either of the following commands in cmd/ terminal:

mvn clean install

Or

mvn test

Kudos! That is all you need to know to learn Gauge test automation scripts on LambdaTest online Selenium Grid. In case you have an questions feel to let us know. You can drop a message to our 24/7 Customer chat support, or you could mail them to us over [email protected]. Happy testing! ๐Ÿ™‚

Last updated on