-
Notifications
You must be signed in to change notification settings - Fork 261
/
base.component.ts
31 lines (26 loc) · 1.11 KB
/
base.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
*
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
*/
import { Locator, Page } from '@playwright/test';
import { PlaywrightBase } from '../playwright-base';
export abstract class BaseComponent extends PlaywrightBase {
private rootElement: string;
constructor(page: Page,rootElement: string) {
super(page);
this.rootElement = rootElement;
}
/**
* Method which should be used across the repository, while creating
* reference to elements, which are in root element of component.
* @param cssLocator css selector as String. Need to be in the tree under the root element
* @param options if you want to localize it by text, then provide an optional hasText
* @returns Locator object
*/
getChild(cssLocator: string, options?: { hasText: string | RegExp }): Locator {
return this.page.locator(`${this.rootElement} ${cssLocator}`, options);
}
}