Selenium webdriver 如何处理selenium webdriver中的意外“警报”
PS:driver.switchTo.alert.accept;它不起作用了 我想自动测试显示随机警报的网页* 因此,我不知道将driver.switchTo.alert.accept放在哪里,因为警报的发生事先不知道 所以请帮助我。。这里是简单的摩卡硒测试。。。我已经注释掉了alert.accept部分 我想知道怎么处理 意外警报提示错误:意外警报打开:{警报文本:} 一劳永逸 我读了selenium文档,但找不到任何 这是我的密码Selenium webdriver 如何处理selenium webdriver中的意外“警报”,selenium-webdriver,exception-handling,automated-tests,mocha.js,Selenium Webdriver,Exception Handling,Automated Tests,Mocha.js,PS:driver.switchTo.alert.accept;它不起作用了 我想自动测试显示随机警报的网页* 因此,我不知道将driver.switchTo.alert.accept放在哪里,因为警报的发生事先不知道 所以请帮助我。。这里是简单的摩卡硒测试。。。我已经注释掉了alert.accept部分 我想知道怎么处理 意外警报提示错误:意外警报打开:{警报文本:} 一劳永逸 我读了selenium文档,但找不到任何 这是我的密码 describe( 'handling alerts' ,
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();
});
});
});
您可以在定义驱动程序对象时设置功能
有关如何设置功能,请参阅此链接。这将帮助您在警报间歇时定义一般行为。AWWW。。。定义泛型行为将是一个很大的帮助,谢谢
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();
});
});
});