@allwright.dev/core 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -76,6 +76,10 @@ export interface PageInfo {
76
76
  sessionId: string;
77
77
  browserSessionId: string;
78
78
  }
79
+ export interface LocatorInfo {
80
+ page: Page;
81
+ selector: string;
82
+ }
79
83
  interface PingResponse {
80
84
  message?: string;
81
85
  }
@@ -383,6 +387,7 @@ export declare class Page {
383
387
  });
384
388
  readonly sessionId: string;
385
389
  readonly browserSessionId: string;
390
+ locator(selector: string): Locator;
386
391
  goto(url: string, options?: CommandOptions): Promise<NavigateResult>;
387
392
  click(selector: string, options?: CommandOptions): Promise<ClickResult>;
388
393
  count(selector: string, options?: CommandOptions): Promise<CountResult>;
@@ -399,6 +404,22 @@ export declare class Page {
399
404
  pageInfo(): PageInfo;
400
405
  navigate(url: string, options?: CommandOptions): Promise<NavigateResult>;
401
406
  }
407
+ export declare class Locator {
408
+ readonly page: Page;
409
+ readonly selector: string;
410
+ constructor(input: LocatorInfo);
411
+ click(options?: CommandOptions): Promise<ClickResult>;
412
+ count(options?: CommandOptions): Promise<CountResult>;
413
+ highlight(options?: HighlightOptions): Promise<HighlightResult>;
414
+ focus(options?: CommandOptions): Promise<ElementResult>;
415
+ fill(value: string, options?: CommandOptions): Promise<FillResult>;
416
+ hover(options?: CommandOptions): Promise<ElementResult>;
417
+ press(key: string, options?: PressOptions): Promise<PressResult>;
418
+ textContent(options?: CommandOptions): Promise<TextResult>;
419
+ innerText(options?: CommandOptions): Promise<TextResult>;
420
+ waitFor(options?: WaitForSelectorOptions): Promise<WaitForSelectorResult>;
421
+ locator(selector: string): Locator;
422
+ }
402
423
  export declare const chromium: BrowserType;
403
424
  export type Tab = Page;
404
425
  export declare function ping(): Promise<string>;
package/dist/index.js CHANGED
@@ -185,6 +185,9 @@ export class Page {
185
185
  }
186
186
  sessionId;
187
187
  browserSessionId;
188
+ locator(selector) {
189
+ return new Locator({ page: this, selector });
190
+ }
188
191
  async goto(url, options = {}) {
189
192
  const handle = await this.#getHandle();
190
193
  this.#ensureOpen(handle);
@@ -578,6 +581,50 @@ export class Page {
578
581
  return this.#handlePromise;
579
582
  }
580
583
  }
584
+ export class Locator {
585
+ page;
586
+ selector;
587
+ constructor(input) {
588
+ this.page = input.page;
589
+ this.selector = input.selector;
590
+ }
591
+ async click(options = {}) {
592
+ return this.page.click(this.selector, options);
593
+ }
594
+ async count(options = {}) {
595
+ return this.page.count(this.selector, options);
596
+ }
597
+ async highlight(options = {}) {
598
+ return this.page.highlight(this.selector, options);
599
+ }
600
+ async focus(options = {}) {
601
+ return this.page.focus(this.selector, options);
602
+ }
603
+ async fill(value, options = {}) {
604
+ return this.page.fill(this.selector, value, options);
605
+ }
606
+ async hover(options = {}) {
607
+ return this.page.hover(this.selector, options);
608
+ }
609
+ async press(key, options = {}) {
610
+ return this.page.press(this.selector, key, options);
611
+ }
612
+ async textContent(options = {}) {
613
+ return this.page.textContent(this.selector, options);
614
+ }
615
+ async innerText(options = {}) {
616
+ return this.page.innerText(this.selector, options);
617
+ }
618
+ async waitFor(options = {}) {
619
+ return this.page.waitForSelector(this.selector, options);
620
+ }
621
+ locator(selector) {
622
+ return new Locator({
623
+ page: this.page,
624
+ selector: `${this.selector} ${selector}`,
625
+ });
626
+ }
627
+ }
581
628
  export const chromium = new BrowserType();
582
629
  export async function ping() {
583
630
  const runtime = await getRuntime();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allwright.dev/core",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "description": "High-level TypeScript client for the allwright automation engine.",
5
5
  "license": "MIT",
6
6
  "type": "module",