如何在黄瓜+量角器中编写可重用的方法

时间:2016-04-21 07:03:35

标签: protractor cucumberjs

/* jshint -W117 */
'use strict';

var Support = require('./_support');
var $ = new Support();
var LoginPage = require('./login.page');


/**
 * Collection of basic steps definitions reusable across features
 */
var basicSteps = function (page) {
    //var page = new LoginPage();
    this.Then(/^the title should equal "([^"]*)"$/, function (arg1, callback) {
        $.expect(browser.getTitle()).to.eventually.equal(arg1).and.notify(callback);
    });

    this.Then(/^I should see validation message "([^"]*)"$/, function (arg1, callback) {
        $.expect(LoginPage.hasErrors()).to.eventually.equal(arg1).and.notify(callback);
    });

    this.Then(/^the "([^"]*)" button should be disabled$/, function (arg1, callback) {
        $.expect(LoginPage.buttonDisabled.isEnabled()).to.eventually.to.equal(false).and.notify(callback);;

    });

};

module.exports = basicSteps;

我想将此代码用于所有页面文件以使其可重用。 我有其他login.page文件,所以如果我根据功能创建任何其他页面文件我应该能够重用此代码

0 个答案:

没有答案