Naveen Naveen - 2 months ago 11
Java Question

Select calendar button using selenium webdriver

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

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


Primefaces Calendar with Button

Html code

Answer

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();
Comments