当您访问url时,
https://staging.keela.co/login有一个阻止UI的Ajax加载器,因此我们必须等待Ajax加载器完成所有WebElement的加载,并且
password字段变为可见。为了实现这一目标,我们将推出
ExplicitWait即
WebDriverWait与
ExpectedConditions设置为
elementToBeClickable对
System.setProperty("webdriver.gecko.driver","C:\Utility\BrowserDrivers\geckodriver.exe");WebDriver driver = new FirefoxDriver();driver.get("https://staging.keela.co/login");WebDriverWait wait = new WebDriverWait (driver, 15);WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='login-email']")));element.sendKeys("bandanakeela@yopmail.com");driver.findElement(By.xpath("//input[@id='login-password']")).sendKeys("keela");driver.findElement(By.xpath("//button[@]")).click();

![线程“ main” org.openqa.selenium.NoSuchElementException中的异常:无法找到元素:// * [@@ id='login-email'] 线程“ main” org.openqa.selenium.NoSuchElementException中的异常:无法找到元素:// * [@@ id='login-email']](http://www.mshxw.com/aiimages/31/670870.png)
