Back

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")

@CacheLookup

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;

import org.openqa.selenium.chrome.ChromeDriver;

 

public class WebElementWithMultipleClassNames {

 

public static void main(String[] args) {

WebDriver driver;

System.setProperty("webdriver.chrome.driver","./exefiles/chromedriver.exe");

driver=new ChromeDriver(); 

driver.get("https://www.intellipaat.com/");

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

}

}

I hope this helps!

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...