Selenium WebDriver 在执行一次后退出 for 循环时遇到问题。大概是在页面加载之前获取内容和循环开始的问题。是否有可能让 webdriver 等到页面加载?
List<WebElement> albums = new ArrayList<WebElement>();
albums = driver.findElements(By.className("album_title"));
for (WebElement we : albums) {
we.click();
if (driver.findElement(By.id("delete_album_prompt")).isDisplayed()) {
driver.findElement(By.id("delete_album_prompt")).click();
driver.findElement(By.id("delete_album_yes")).click();
} else {
break;
}
}