Thursday, December 18, 2014

Solving Compound class names are not supported error in Selenium


When your running your selenium based test cases if you come across a issue like
"org.openqa.selenium.InvalidSelectorException: Compound class names are not supported. Consider searching for one class name and filtering the results or use CSS selectors." 

This issue is getting due to currently selendroid can not find elements by name or className with value contains white space. 
 
This is a simple way to resolve the issue.

Imagine you have a Div class like div class ="ddArrow arrowoff" and you want to use the Xpath to identify the element and you will get the above error.

  @FindBy(how = How.CLASS_NAME, using = "ddArrow arrowoff")
    private static WebElement ddarrow;

To resolve the issue you need to use cssSelector . The selector will be 
"div.dwn-arrow" 
 
driver.findElement(By.cssSelector("div.dwn-arrow")



No comments:

Post a Comment