Protractor TypeScript PageObject 属性未定义。

3

嗨,当我在使用带有angular cli的protractor typescript时,我遇到了以下错误:“无法读取未定义的属性'sendUsername'”。我是typescript的新手,请建议我如何解决这个问题。

错误

失败:无法读取未定义的属性'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();
}
}

Angular的版本是什么? - alphapilgrim
1个回答

0

它没有选择文件路径,而是使用单点。请使用双点,这意味着它将从父级中选择路径,例如:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接