E2E量角器:页面对象映射找不到模块

时间:2018-09-08 04:02:12

标签: object design-patterns protractor

当前,我正在尝试使用页面对象进行e2e测试以减少维护工作,并且我能够编写如下内容:

Test1-声明登录页面字段

var xxxx_Page_Mdemo = function () {

    var companycode = element(by.id('company-code'));
    var username = element(by.id('username'));
    var password = element(by.id('password'));
    var signclick = element(by.css('section>form>button'));

    this.get = function () {
        browser.get('https://xxxx.com');
    };

    this.setCompanycode = function (ccode) {
        companycode.sendKeys(ccode);
    };

    this.setUsername = function (uname) {
        username.sendKeys(uname);
    };

    this.setPassword = function (pasword) {
        password.sendKeys(pasword);
    };

    this.setsignclick = function (signin) {
        signclick.click(signin);
    };
};

module.exports = new xxxx_Page_Mdemo();

Test2

var xxxxlogin_Page_Mdemo = require('./PageAdminuserlogsuper.js');

describe('xxlogin page', function () {

    beforeEach(function () {
        browser.waitForAngularEnabled(false);
    });

    afterEach(function () {
        browser.executeScript('window.sessionStorage.clear();');
        browser.executeScript('window.localStorage.clear();');
        browser.restart();
    });

    it('should login to thexxx dashboard', function () {
        login_Page_Mdemo.get();
        var EC = protractor.ExpectedConditions;
        browser.wait(EC.visibilityOf($('#company-code')))
            .then(function () {
                login_Page_Mdemo.setCompanycode('cc90');
                login_Page_Mdemo.setUsername('xxxx.com');
                xxxx_Page_Mdemo.setPassword('pass');
                xxxx_Page_Mdemo.setsignclick();
                browser.wait(EC.urlContains('https://.xxx.com/#/xxx/index'), 100000).then(function () {
                     console.log('xxxx');
                     browser.sleep(4000);
                });
           });
     });
});

从此我能够登录到特定页面, 我的问题是登录后我必须导航到应用程序内的其他字段,然后在单独的页面上单击一下。我已经为此创建了相同的页面对象,并且无法链接登录功能到此错误。任何意见?

    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
[09:25:28] E/launcher - Process exited with error code 100

Process finished with exit code 4
Empty test suite.

我的conf文件是这样的:

'./tests/MainObjects/PageAdminuserlogsuper.js',
'./tests/MainObjects/AdminuserlogPageobjectadopt.js',

'./tests/MainObjects/PageEmployeetemplatesuper.js',
'./tests/MainObjects/QE35CustomizeEmptemplate.js'

0 个答案:

没有答案