Compound class names are not supported error in WebDriver

This is exactly as expected. If your class name includes a space, WebDriver will see it as a "compound selector". You can either remove the space in your By.className() locator, which should still find the elements you're looking for; or you can move to finding by CSS selectors, using something like By.cssSelector(".cashout_noCash"), which offer far more flexibility for similar functionality. This is exactly what the exception message says.


You can include compound class names selectors by leaving no gap between any of them.

For example if your div is:

<div class="k-calendar-container k-popup k-group k-reset"></div>

Then your selector will be:

driver.findElement(By.cssSelector("k-calendar-container.k-popup.k-group.k-reset"));

Here is a Ruby answer if anyone needs it. The conclusion I reached is that some of the solutions that worked for java above either don't work on my machine or don't work for Ruby at all (although I am not sure which is the case).

If the html is:

<a class="button orange-bg" href="http://www.MyCarmelHome.com" target="_blank">
     access web portal
</a>

The format to find this element would be:

logInBtn = driver.find_element(:css, ".button.orange-bg")

I used this because the following wouldn't work:

  1. Replacing the spaces with '.' and finding by css selector (you need to put a period at the front).

  2. Removing the spaces in the compound class name and using the class name locator.