【发布时间】:2018-07-23 23:51:15
【问题描述】:
我是量角器的新手,我正在准备用它和黄瓜安装一个项目。
剧情如下
Scenario: User login
Given the page is open
And email is set with value n@n.com
And password is set with value 123
When the user click on login button
Then home page is displayed
实现步骤定义,login_page.js如下
var chai = require('chai').use(require('chai-as-promised'));
var expect = chai.expect;
var LoginPage = function() {
this.get = function() {
browser.get('https://aaa/login');
};
this.setEmail = function(value) {
element(by.id('login-email')).sendKeys(value);
};
this.setPassword = function(value) {
element(by.id('login-password')).sendKeys(value);
};
this.clickAccede = function() {
element(by.id('login-submit')).click()
};
this.pageIsLoaded = function() {
browser.waitForAngular();
expect(browser.getTitle()).to.be.eventually.equals('page title');
};
};
然后,当我运行该场景时,我会收到以下结果
Scenario: User login
✔ Given the page is open
✔ And email is set with value n@n.com
✔ And password is set with value 123
✔ When the user click on login button
✔ Then home page is displayed
1 scenario (1 passed)
5 steps (5 passed)
0m00.005s
[16:23:50] E/launcher - expected 'aaa' to equal 'page title'
[16:23:50] E/launcher - AssertionError: expected 'aaa' to equal 'page title'
[16:23:50] E/launcher - Process exited with error code 199
如您所见,断言失败但结果返回成功。 我错过了什么?
【问题讨论】:
-
不要在页面对象protractortest.org/#/style-guide中使用
expect
标签: javascript protractor cucumber chai