【发布时间】:2017-12-27 09:40:53
【问题描述】:
我已使用以下内容,但我得到此驱动程序实例没有有效的会话 ID(您是否调用了 WebDriver.quit()?)并且可能不再使用。有人可以帮忙吗?
Sample.js 文件,代码如下:
describe('angularjs homepage', function() {
beforeAll(function(){
browser.get('https://xxxx/');
console.log('calling before all');
});
afterAll(function(done){
console.log('calling after all');
browser.quit();
process.nextTick(done);
});
另一个也有相同代码的文件:
describe('angularjs homepage', function() {
beforeAll(function(){
browser.get('https://xxxx/');
console.log('calling before all');
});
afterAll(function(done){
console.log('calling after all');
browser.quit();
process.nextTick(done);
});
现在我想使用 beforeAll 和 AfterAll 函数,浏览器应该通过它们在每个 js 文件执行中打开和关闭。当我采用这种方法时,我收到错误,因为此驱动程序实例没有有效的会话 ID(您是否调用了 WebDriver.quit()?)并且可能不再使用。
【问题讨论】:
-
使用
browser.close()。 -
我也使用了相同的,但问题仍然相同。我想为每个描述块打开和关闭浏览器。
-
你可以试试:
beforeAll(async function() { await browser.get('h.ttp...'); })。也许量角器不知道您正在beforeAll()中执行异步函数。
标签: protractor