You can try and get it by cssSelector
instead. As far as I remember by className
is only for one class.
driver.findElement(By.cssSelector(".btn.btn-main.dropdown-toggle")).click();
Executing a click via webdriver has sometime unexpected behaviors.If its not working then alternate way JavascriptExecutor
class to do this.
Its always preferable to use click()
method of the WebElement
.
WebElement element = driver.findElement(By.cssSelector(".btn.btn-main.dropdown-toggle"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);