设置等待操作

package Page;

import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class element {
    private static WebElement element = null;
// 等待判断
    public static boolean isExistWebElement(WebDriver driver, String xpath) {

        // WebDriverWait wait = new WebDriverWait(driver, 2);
        try {
            WebDriverWait wait = new WebDriverWait(driver, 2);
            wait.until(ExpectedConditions.presenceOfElementLocated(By
                    .xpath(xpath)));
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}

 

posted @ 2016-06-18 11:18  好奇的小明  阅读(148)  评论(0编辑  收藏  举报