【发布时间】:2018-01-22 13:56:49
【问题描述】:
PS: driver.switchTo().alert().accept();不工作
好吧,我想自动测试显示随机警报*的网页
*random alerts :JavaScript Alert which are not controlled and can appear any time
所以我不知道该放在哪里driver.switchTo().alert().accept()因为事先不知道警报的发生。
所以请帮助我.. 这是简单的 mocha selenium 测试...我已经注释掉了 alert.accept() 部分..
我想知道怎么处理
UnexpectedAlertOpenError:意外警报打开:{警报文本:}
一劳永逸....
我阅读了 selenium 文档,但找不到任何...
这是我的代码
describe( 'handling alerts' , function(done){
after(function(done){
return driver.quit();
done();
});
it( 'should check title ', function(done){
driver.get("https://www.google.in");
driver.findElement(By.id("q"));
driver.get("https://jsfiddle.net/cwthh0y7/");
// driver.switchTo().alert().accept();
driver.getTitle().then(function(title){
assert.equal(title, "Edit fiddle - JSFiddle");
done();
});
});
});
【问题讨论】:
标签: selenium-webdriver exception-handling automated-tests mocha.js