export class BasePage {
// protected: accessible within this class and subclasses
protected readonly baseUrl: string;constructor(baseUrl: string) {
this.baseUrl = baseUrl;
}
public getUrl(path: string): string {
return ${this.baseUrl}${path};
}
}
// Inheritance with extends & super:
export class LoginPage extends BasePage {
// private: only accessible inside LoginPage
private readonly loginPath: string = "/login";
constructor(baseUrl: string) {
super(baseUrl); // calls constructor of BasePage
}
public getLoginUrl(): string {
return this.getUrl(this.loginPath);
}
}