isEnabled() 找不到元素

isEnabled() failed to find element

我是硒的新手。我试图通过 isEnabled() 检查按钮是否启用。但是当我 运行 这个程序时,它会生成一个错误,作为按钮的 "Unable to locate element"。

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class test 
{
static WebDriver driver;
public static void main(String[] args) 
{
    System.setProperty("webdriver.chrome.driver", "D:\rakesh\software\selenium browser\New folder\chromedriver.exe");
    driver=new ChromeDriver();
    driver.get("https://app.crossover.com/");
    driver.manage().window().maximize();
    JavascriptExecutor js= (JavascriptExecutor) driver;
    js.executeScript("window.scrollBy(0,5500)", "");

    driver.findElement(By.linkText("Available Jobs")).click();

    Boolean search_btn_ele = driver.findElement(By.xpath(".//*[@id='available-jobs']/div[2]/form/div/div[3]/button")).isEnabled();

    if(search_btn_ele.FALSE)
    {
        System.out.println("Button is disable before giving search keys");
    }
    else
    {
        System.out.println("Button is enable before giving search keys");
    }

    WebElement search_txtfield_ele= driver.findElement(By.xpath(".//*[@id='available-jobs']/div[2]/form/div/div[1]/div/input"));
    search_txtfield_ele.sendKeys("Chief");
}
}

使用 WebDriverWait 等待元素出现:

new WebDriverWait(driver, TimeSpan.FromSeconds(45)).Until(ExpectedConditions.ElementIsVisible((By.Id("ctl00_ContentPlaceHolder1_drp85"))));