How to use relative locators for automation test in Java-TestNG on LambdaTest?

Tell me how I can use relative locators for automation test in Java-TestNG on LambdaTest.

Hello Devan,

You can easily use relative locators for performing automation test in Java-TestNG on LambdaTest.

Here is an example of relative locators:

// find the height input using toRightOf relative locator
// input is right of height label
WebElement heightInput = driver.findElement(with(By.tagName("input"))
   .toRightOf(heightLabel));

// find the calculate button which is below the weight label
WebElement calculateButton = driver.findElement(with(By.tagName("input"))
   .below(weightLabel));

Download and configure the GitHub repo for more details: