Hey there, I'm facing an issue while using POM in Protractor with TypeScript in Angular CLI. The error I'm encountering is "Cannot read property 'sendUsername' of undefined". Since I'm new to TypeScript, can someone guide me on how to fix this problem?
error
Error Message: Cannot read property 'sendUsername' of undefined
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();
}
}