javaselenium-webdriver

How can I click on Tuesday April 15 2025 button?


enter image description here

I am using Eclipse/Java with Selenium. I'm unable to locate and click the April 15st 2025 button.

Code

driver.findElement(By.xpath("//div[contains(@class, 'eoY5cb') and text()='Tuesday, April 15, 2025, return date.']')]")).sendKeys("Tuesday, April 15, 2025");
driver.findElement(By.cssSelector("div[class*='eoY5cb']")).click();

Solution

  • A CSS selector should work fine.

    div[aria-label='Tuesday, April 15, 2025']
    

    The full code to click it with a wait would be,

    WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
    wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("div[aria-label='Tuesday, April 15, 2025']"))).click();