javaselenium-webdriver

How can I click on DONE button?


Eclipse/Java with selenium; I"d want to click on DONE buttonenter image description here

I have tried this driver.findElement(By.cssSelector("button[aria-label='Done. Search for round trip flights, departing on March 15, 2025 and returning on April 15, 2025']")).click();


Solution

  • I used a more generic version of a CSS selector,

    button[aria-label^='Done.']
    

    With a WebDriverWait, the full code would be

    WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
    wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[aria-label^='Done.']"))).click();