Java selenium被显示出来

时间:2016-07-03 17:03:00

标签: java selenium selenium-webdriver

     WebElement Name = driver.findElement(By.id("FirstName"));
    WebElement Email = driver.findElement(By.id("MemberName"));
    WebElement Error = driver.findElement(By.className("alert-error"));


   BufferedReader br = new BufferedReader(new FileReader("emails.txt"));
    String line;
    while((line = br.readLine()) != null) {

        Email.sendKeys(line);
        Name.click();
        Thread.sleep(2000);
        Email.sendKeys(Keys.chord(Keys.CONTROL, "a", Keys.BACK_SPACE));
        if (Error.isDisplayed())
        {
            System.out.println("Taken " + line );
        } else
        {
            System.out.println("Not taken "+ line+ "  ###################################");
        }
    }

出于某种原因,它总是会这样称呼它。 System.out.println("Not taken "+ line+ " ###################################"); 我想要它做什么,如果显示错误,然后打印“Taken”+ Line

1 个答案:

答案 0 :(得分:0)

请确保WebElement实际上是 显示  在https://w3c.github.io/webdriver/webdriver-spec.html#dfn-element-displayed的文档中指定的术语。