protractor typescript pageobject属性undefined

时间:2017-08-08 13:38:58

标签: angular typescript jasmine angular-cli pageobjects

嗨,当我在带有角度cli&#34的量角器打字稿中使用POM时,我收到以下错误;无法读取属性' sendUsername'未定义"。我是打字稿的新手,请建议我如何解决这个问题。

error

失败:无法读取属性' sendUsername'未定义的

app.e2e-spec.ts

import { PatientInquiryPrototypePage } from './patiq-common.po';
import { LoginAdmin } from './patiq-login.po';

describe('patient-inquiry-prototype App', () => {
let page: PatientInquiryPrototypePage;
let loginAdmin: LoginAdmin;

beforeEach(() => {
page = new PatientInquiryPrototypePage();
});

it('Launch the Test URL', () => {
  page.navigateTo();
});

it('Login as Administrator', () => {

  loginAdmin.sendUsername('PILabAdmin');
  loginAdmin.sendPassword('password$123');
  loginAdmin.openHostSystem();
  loginAdmin.selectHostSystem();
  loginAdmin.openHostRole();
  loginAdmin.selectHostRole();

  });
  });

patiq-login.po.ts

import { browser, by, element, protractor, ExpectedConditions, $, $$ } from 'protractor';

export class LoginAdmin {

sendUsername(Username: string) {
    return element(by.css('[formcontrolname="username"]')).sendKeys(Username);
}

sendPassword(Password: string) {
    return element(by.css('[formcontrolname="password"]')).sendKeys(Password);
}

openHostSystem() {
    return element(by.css('[formcontrolname="hostSystem"]')).click();
}

selectHostSystem() {
    return element(by.css('[class="mat-option"]')).get(0).click();
}

openHostRole() {
    return element(by.css('[formcontrolname="hostRole"]')).click();
}

selectHostRole() {
    return element(by.css('[class="mat-option"]')).get(6).click();
}
}

1 个答案:

答案 0 :(得分:0)

它不采用文件路径而不是单个点。放置双点,这意味着它将选择父级的路径,例如

import { PatientInquiryPrototypePage } from '../patiq-common.po';
import { LoginAdmin } from '../patiq-login.po';
相关问题