Javascript 如何等待所有重定向完成使用intern/web驱动程序?
我试图测试应用程序是否将用户重定向到经过身份验证的路由之外,因为他们不是管理员 但我需要一种方法,在调用getCurrentUrl之前等待所有重定向完成Javascript 如何等待所有重定向完成使用intern/web驱动程序?,javascript,node.js,intern,leadfoot,Javascript,Node.js,Intern,Leadfoot,我试图测试应用程序是否将用户重定向到经过身份验证的路由之外,因为他们不是管理员 但我需要一种方法,在调用getCurrentUrl之前等待所有重定向完成 可能最简单的方法是查找应该位于非保护页面而不是受保护页面上的内容。一旦找到了预期的内容,请检查URL以验证您所在的位置 it('should not allow regular user access', test => { return test.remote .then(e2e.impersonate('test@test
可能最简单的方法是查找应该位于非保护页面而不是受保护页面上的内容。一旦找到了预期的内容,请检查URL以验证您所在的位置
it('should not allow regular user access', test => {
return test.remote
.then(e2e.impersonate('test@test.com'))
.get('/protected-route')
.findByCssSelector('.something.that.should.be.visible')
.getCurrentUrl()
.then(url => {
console.log('url', url);
expect(url.indexOf('/landing-page')).not.toBe(-1);
return true;
});
});
你能举个例子说明怎么做吗?只要在登录页上找到一些东西就行了。我用一个例子更新了答案。
it('should not allow regular user access', test => {
return test.remote
.then(e2e.impersonate('test@test.com'))
.get('/protected-route')
.findByCssSelector('.something.that.should.be.visible')
.getCurrentUrl()
.then(url => {
console.log('url', url);
expect(url.indexOf('/landing-page')).not.toBe(-1);
return true;
});
});