2015-06-01 29 views
1

我写简单的量角器虫虫我们的应用程序:量角器synchrozation - 超时

  • 登录页面是没有angularhs - 做工精细
  • 其他所有的页面都与angularjs

,当我想写angularhs测试 - 我得到这个错误(安装后this):

Timed out waiting for Protractor to synchronize with the page after 40002ms. Please see https://github.com/angular/protractor/blob/master/docs/faq.md 

配置:

exports.config = { 
    seleniumAddress: 'http://localhost:4444/wd/hub', 
    specs: ['login-spec.js'], 
    baseUrl: 'https:/xyz/', 
    allScriptsTimeout: 40000, 

    capabilities: { 
    'browserName': 'firefox' 
    } 
} 

而且我的规格:

describe('Login #1', function() { 
    // BEFORE LOGIN 
    it('should pass to next login step', function() { 
    browser.driver.get('https://xyz/login'); 
    browser.driver.findElement(by.css(".factorFirst > [name='username']:first-child")).sendKeys('123456'); 

    .... other login stuff 

    }, 90000); 

    // AFTER LOGIN TEST 
    it('Simple Angular Test', function() { 
    browser.get('/page'); 

    element(by.model('payment.userSpecified.message')).sendKeys(1); 

    }, 45000); 


}); 

我们没有在我们的body元素属性ng-app。这可能是一个问题吗?

回答

1

你需要让protractor知道登录页面是非角度的,并且它不需要等待角度“稳定下来”。登录前设置ignoreSynchronizationtrue和后置回false

describe('Login #1', function() { 

    afterEach(function() { 
    browser.ignoreSynchronization = false; 
    }); 

    it('should pass to next login step', function() { 
    browser.ignoreSynchronization = true; 

    browser.driver.get('https://xyz/login'); 
    browser.driver.findElement(by.css(".factorFirst > [name='username']:first-child")).sendKeys('123456'); 
    }, 90000); 

    it('Simple Angular Test', function() { 
    browser.get('/page'); 

    element(by.model('payment.userSpecified.message')).sendKeys(1); 

    }, 45000); 
}); 
+0

谢谢你的答复。当我设置'browser.ignoreSynchronization = false;'在角度测试中,我实际上得到超时错误。当我将它设置为TRUE - >我可以发送键给模型。但是,我必须与未来的对象合作。 –

+1

@ Mato.Duris是的,这就是我说的 - 当你在一个非角度页面上时,你需要'ignoreSynchronization'为'true'。之后,当你到达一个角度页面时 - 将其设置回默认的“false”值。你有没有试过我提供的代码?谢谢。 – alecxe

+0

This works:http://pastebin.com/uYRrB7ks ...当我删除'browser.ignoreSynchronization = true;' - >我收到超时错误。 (afterEach功能,我已经添加为你推荐)。这很奇怪。测试工作,但我需要与未来的对象工作有什么缺点。 –