2017-04-13 12 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'); 
相关问题