Compound class names not permitted error Webdriver

Solution 1:

You can access the element if it has multiple classes using "By":

from selenium.webdriver.common.by import By
driver.findElement(By.cssSelector(".alert.alert-success"));

Solution 2:

You can use

driver.findElement(By.className("alert-success"));

or

driver.findElement(By.className("alert"));

As right now selenium doesn't support multiple class name.If your class name includes a space, WebDriver will see it as a "compound selector". You can use cssSelector or id for selecting the webelement.

Solution 3:

If usage of class name is must you can use the following ways:

1) css selectors:

driver.findElement(By.cssSelector(".alert.alert-success");

2) using xpath

driver.findElement(By.xpath("//div[@class='alert alert-success']"))

Try avoiding xpath and use css selectors instead.