Naveen Naveen - 1 year ago 127
Java Question

Select calendar button using selenium webdriver

I'm trying to select a calendar button. Here is my code:

By.className("ui-datepicker-trigger ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only")

Primefaces Calendar with Button

Html code

Answer Source

Actually Selenium does not support compound class to locate an element using By.className(), you should try using By.cssSelector() instead as below :-

driver.findElement(By.cssSelector("button.ui-datepicker-trigger.ui-button[aria-label='Show Calendar']")).click();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download