转载:selenium通过WebDriverWait实现ajax测试

AndroidDriver driver = new AndroidDriver();  
driver.get("http://m.taobao.com");  
WebElement inputBox = driver.findElement(By.id("J_SKey"));  
inputBox.sendKeys("1");  
new WebDriverWait(driver, 10).until (new ExpectedCondition<Boolean>() {  
    @Override  
    public Boolean apply(WebDriver driver) {  
        Boolean result = false;  
        try {  
            driver.findElement(By.xpath("//div[@class='suggest']//li"));  
            result = true;  
        } catch(Exception e){         
        }  
        return result;  
    }  
});  
assertTrue(driver.findElement(By.xpath("//div[@class='suggest']//li")).getText().contains("1"));  

  

原文地址:https://www.cnblogs.com/louytu/p/4255193.html