量角器 - 失败:道具未定义

Protractor - Failed: prop is not defined

请帮忙找出错误。我正在学习量角器并尝试使用页面对象创建一个简单的测试。

//login_pageObject.js

let loginContainer = function() {

this.usernameInput = $("input.login-form-01");
this.passwordInput = $("input#login-form-02");
this.loginBtn = $("input.btn");

this.get = function() {
    browser.get("https://www.cosmedicalsupplies.com/login.html");
};

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

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

this.clickOnLoginBtn = function() {
    loginBtn.click();
};
};
module.exports = new loginContainer();

//login.js
let loginPage = require('../page_objects/login_pageObject.js'); 

describe('login_logout autotests', () => {

beforeEach(() => {
    browser.ignoreSynchronization = true;
});

it("should sign in", () => {
    loginPage.get();
    loginPage.setUsername("test1");
    loginPage.setPassword("test2");
    loginPage.clickOnLoginBtn();
    //expect.....
});
});

因此,当我 运行 这段代码时,出现 "Failed: usernameInput is not defined" 错误。哪里错了?

您需要将其称为 this.usernameInput