Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (19.7k points)

<div class="value test" /> I'd like to identify that web element. It only has these two classes defined. I cannot do the following as className does not take a space-separated value. What are the alternatives?

@FindBy(className = "value test")


private WebElement test;

1 Answer

0 votes
by (62.9k points)

Using classname locator:

Use the below syntax:

driver.findElement(By.className(“required_field cityPadRight ac_input”));

Java code:

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;



public class WebElementWithMultipleClassNames {


public static void main(String[] args) {

WebDriver driver;


driver=new ChromeDriver(); 


driver.findElement(By.className("required_field cityPadRight ac_input")).sendKeys("fewfazf");



I hope this helps!

Browse Categories