2015-08-09 40 views
1

我想测试我的注册模态是否存在点击注册按钮时,我的问题是,它似乎是量角器在角度打开模式和测试失败之前完成测试,我的另一个解决方案是使用预期条件,但由于某些原因,这不起作用,等待功能不会等待我设置的时间,测试正常运行并失败。角度量角器测试存在的模态

var SignUpPage = require('./signup.page'); 

describe('signup page', function() { 
    var SignupPage; 
    beforeEach(function() { 
    browser.get('http://localhost:9000'); 
    browser.waitForAngular(); 
    SignupPage = new SignUpPage(); 
    }); 

    it('should open the modal when clicking signup in the main nav', function() { 
    var EC = protractor.ExpectedConditions; 
    SignupPage.clickModalBtn(); 

    browser.wait(EC.presenceOf(SignupPage.getModalEle()), 10000); 

    expect(SignupPage.getModalEle().isPresent()).toBe(true); 
    }); 

}); 

的Signuppage:

function SignUpPage() { 
    this.openModalBtn = element(by.css('.nav-sign-in-btn')); 
    this.modal = element(by.css('.reSkill-auth')); 
    this.email = element(by.css('input[type="email"')); 
    this.password = element(by.css('input[type="password"')); 
    this.signInBtn = element(by.css('button[type="submit"]')); 
} 

SignUpPage.prototype.clickModalBtn = function() { 
    this.openModalBtn.click(); 
} 

SignUpPage.prototype.getModalEle = function() { 
    return this.modal; 
} 

SignUpPage.prototype.setEmailAndPassword = function() { 
    this.email.sendkeys('[email protected]'); 
    this.password.sendkeys('123456789'); 
} 

SignUpPage.prototype.clickSignIn = function() { 
    this.signInBtn.click(); 
} 

module.exports = SignUpPage; 

如何测试呢?

+0

您可以发布'SignupPage',尤其是'getModalEle'的相关代码? –

+0

我添加了注册码 – Bazinga

回答

0

有一两件事可以帮助是增加默认茉莉超时间隔

jasmineNodeOpts: { 
    showColors: true, 
    isVerbose: true, 
    includeStackTrace: true, 
    defaultTimeoutInterval: 60000 // 60 seconds 
}