Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何等待所有重定向完成使用intern/web驱动程序?_Javascript_Node.js_Intern_Leadfoot - Fatal编程技术网

Javascript 如何等待所有重定向完成使用intern/web驱动程序?

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

我试图测试应用程序是否将用户重定向到经过身份验证的路由之外,因为他们不是管理员

但我需要一种方法,在调用getCurrentUrl之前等待所有重定向完成


可能最简单的方法是查找应该位于非保护页面而不是受保护页面上的内容。一旦找到了预期的内容,请检查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;
    });
});