Skip to content

Commit

Permalink
fix: page object parameters type and default xpath root
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkenos committed Apr 7, 2024
1 parent ad21b29 commit c49e551
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/page-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export abstract class PageObject<ParametersType = WorldParameters> {
protected readonly logger: World["logger"];
protected readonly context: BrowserContext;
protected page: Page;
protected parameters: ParametersType | WorldParameters;
protected parameters: ParametersType;
abstract url: string;
abstract title: string;

Expand All @@ -16,7 +16,7 @@ export abstract class PageObject<ParametersType = WorldParameters> {
this.logger = world.logger;
this.context = world.context;
this.page = world.page;
this.parameters = world.parameters;
this.parameters = world.parameters as any;
}

async navigate() {
Expand Down
7 changes: 6 additions & 1 deletion src/core/utils/xpath-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class XPathBuilder {

constructor(selector?: string) {
this.conditionals = [];
this.selector = selector || `//${this.ANY}`;
this.selector = selector || `//self::${this.ANY}`;
}

private wrap(condition: string, not = false) {
Expand Down Expand Up @@ -246,6 +246,11 @@ export class XPathBuilder {
return this;
}

self(tag = this.ANY) {
this.conditionals.push(`/self::${this.unslash(tag)}`);
return this;
}

build(index?: number | string) {
const selector = this.selector + this.conditionals.join("");
return this.index(selector, index as any);
Expand Down

0 comments on commit c49e551

Please sign in to comment.