2017-04-13 46 views
0

在我的測試中,我有如何使用量角器在我的測試運行之前創建一個助手來登錄我?

var LoginHelper = require('../helpers/functional/login.js') 

describe('Passport Navigation', function() { 

    beforeAll(function() { 
    return LoginHelper() 
    }) 

    it('should properly load the All Skills view', function() { 
    browser.get('https://example.com/ng-app/profile') 
    element(by.model('myModel')).sendKeys('test stuff') 
    element(by.css('btn')).click() 

    expect(myModel()).toEqual('more') 
    }) 
}) 

我的助手是:

module.exports = function() { 
    browser.ignoreSynchronization = false 
    browser.driver.get('https://example.com/ng-app') 


    browser.driver.findElement(by.id('username')).sendKeys("myusername"); 
    browser.driver.findElement(by.id('password')).sendKeys("mypassword"); 
    return browser.driver.findElement(by.tagName('input')).click() 

} 

的問題是我的網站登錄不形成棱角部位和什麼情況是(據我可以告訴) ,它加載登錄頁面,然後輸入用戶名/密碼出錯退出

1) Passport Navigation should properly load the All Skills view 
    Message: 
    Failed: Angular could not be found on the page https://example.com/ng-app/profile.If this is not an Angular application, you may need to turn off waiting fo 
r Angular. 
           Please see 
           https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load 
    Stack: 
    Error: Angular could not be found on the page https://example.com/ng-app/profile.If this is not an Angular application, you may need to turn off waiting for 
Angular. 
+0

添加到protractor.conf: ... onPrepare:{ browser.driver.get(URL);瀏覽器.driver.findElement(by.id('username'))。sendKeys(...); ...有些等待登錄成功 –

回答

3

browser.ignoreSynchronization =假,告訴量角器等待角。如果網站登錄不是角度的,那麼你應該將它設置爲true。

browser.ignoreSynchronization = true;

從量角器網站的一個例子

browser.ignoreSynchronization = true; 
browser.get('/non-angular-login-page.html'); 

element(by.id('username')).sendKeys('Jane'); 
element(by.id('password')).sendKeys('1234'); 
element(by.id('clickme')).click(); 

browser.ignoreSynchronization = false; 
browser.get('/page-containing-angular.html'); 
相關問題