请帮我处理野生动物园的警报。
下面我得到的结果是safari不能处理警报,那么还有其他方法来处理警报吗?
package Default;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.safari.SafariDriver;
public class Safari_demo {
public static void main(String[] args) throws InterruptedException{
WebDriver driver = new SafariDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://www.htmlite.com/JS002.php");
Thread.sleep(6000);
Alert alert = driver.switchTo().alert();
alert.accept();
driver.close();
}
}发布于 2015-04-06 14:02:30
你需要http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html#alertIsPresent())
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();https://stackoverflow.com/questions/29471312
复制相似问题