Check if element is clickable in Selenium Java

前端 未结 7 2020
南旧
南旧 2020-11-29 08:19

I\'m new to Selenium and need to check if element is clickable in Selenium Java, since element.click() passes both on

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 08:45

    wait.until(ExpectedConditions) won't return null, it will either meet the condition or throw TimeoutException.

    You can check if the element is displayed and enabled

    WebElement element = driver.findElement(By.xpath);
    if (element.isDisplayed() && element.isEnabled()) {
        element.click();
    }
    

提交回复
热议问题