Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.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 量角器不';不要等待重定向_Javascript_Angularjs_Protractor_Angularjs E2e_E2e Testing - Fatal编程技术网

Javascript 量角器不';不要等待重定向

Javascript 量角器不';不要等待重定向,javascript,angularjs,protractor,angularjs-e2e,e2e-testing,Javascript,Angularjs,Protractor,Angularjs E2e,E2e Testing,我有一个用Jasmine编写的量角器代码,应该登录用户。不幸的是,在转到根url之后,有一个重定向正在进行,这需要相当长的时间(大约5秒),我不能让量角器等待它。我已经尝试了浏览器。等等,,我尝试过使用承诺,我尝试过使用,但没有任何效果。它仍然没有等待。登录页面是来自Keyclope服务器的页面,这就是为什么我使用driver.findElement而不是element。以下是我当前的代码: describe('my app', function() { it('login', functi

我有一个用Jasmine编写的量角器代码,应该登录用户。不幸的是,在转到根url之后,有一个重定向正在进行,这需要相当长的时间(大约5秒),我不能让量角器等待它。我已经尝试了
浏览器。等等,
,我尝试过使用承诺,我尝试过使用,但没有任何效果。它仍然没有等待。登录页面是来自Keyclope服务器的页面,这就是为什么我使用
driver.findElement
而不是
element
。以下是我当前的代码:

describe('my app', function() {
  it('login', function() {
    var driver = browser.driver;
    browser.get('/');
    console.log('get');
    driver.findElement(by.id('username')).isPresent().then(function() {
      console.log('waited');
      driver.findElement(by.id('username')).sendKeys("test");
      driver.findElement(by.id('password')).sendKeys("test");
      driver.findElement(by.id('kc-login')).click();
      driver.findElement(by.css('.page-header')).isPresent().then(function() {
        console.log('ok');
        expect(browser.getLocationAbsUrl()).toMatch("/test");
      });
    });
  });
});
你知道我能做些什么让它工作吗?我已使用此种子启动了量角器项目:

您需要关闭同步:


注意,我还更新了测试:切换回
元素
浏览器
,添加了内置预期条件的
浏览器.wait()

上述代码对我不起作用。我收到一个等待超时错误
var EC = protractor.ExpectedConditions;

describe('my app', function() {

  beforeEach(function () {
      browser.ignoreSynchronization = true;
      browser.get('/');
  });

  it('login', function() {
    var username = element(by.id('username'));
    browser.wait(EC.visibilityOf(username), 10000);

    username.sendKeys("test");
    element(by.id('password')).sendKeys("test");
    element(by.id('kc-login')).click();

    var header = element(by.css('.page-header'));

    browser.wait(EC.visibilityOf(header), 10000).then(function () {
        console.log('logged in');
    });
  });
});