鍍金池/ 問(wèn)答/Python  測(cè)試  HTML/ Selenium Webdriver NoAlertPresentExcepti

Selenium Webdriver NoAlertPresentException: no alert open

圖片描述
//點(diǎn)擊保存
driver.findElement(By.xpath("http://*[@id="btn-submit"]")).click();
然后有一個(gè)彈出框,需要點(diǎn)擊確認(rèn)
//我以為這個(gè)是alter

Alert javascriptConfirm = driver.switchTo().alert();
javascriptConfirm.accept();

但是報(bào)錯(cuò):
Exception in thread "main" org.openqa.selenium.NoAlertPresentException: no alert open

回答
編輯回答
喵小咪

剛提問(wèn)就被我自己解決了,真尷尬
sleep 2秒就好了
執(zhí)行的太快,alter還沒(méi)出來(lái),selenium就去執(zhí)行了

2018年3月11日 07:11