@atomic-testing/playwright 0.27.0 → 0.29.0
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.
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { ClickOption, CssProperty, EnterTextOption, Interactor,
|
|
1
|
+
import { ClickOption, CssProperty, EnterTextOption, Interactor, Optional, PartLocator } from '@atomic-testing/core';
|
|
2
2
|
import { Page } from '@playwright/test';
|
|
3
3
|
export declare class PlaywrightInteractor implements Interactor {
|
|
4
4
|
readonly page: Page;
|
|
5
5
|
constructor(page: Page);
|
|
6
|
-
selectOptionValue(locator:
|
|
7
|
-
getInputValue(locator:
|
|
8
|
-
getSelectValues(locator:
|
|
9
|
-
getSelectLabels(locator:
|
|
10
|
-
getStyleValue(locator:
|
|
11
|
-
enterText(locator:
|
|
12
|
-
click(locator:
|
|
13
|
-
hover(locator:
|
|
6
|
+
selectOptionValue(locator: PartLocator, values: string[]): Promise<void>;
|
|
7
|
+
getInputValue(locator: PartLocator): Promise<Optional<string>>;
|
|
8
|
+
getSelectValues(locator: PartLocator): Promise<Optional<readonly string[]>>;
|
|
9
|
+
getSelectLabels(locator: PartLocator): Promise<Optional<readonly string[]>>;
|
|
10
|
+
getStyleValue(locator: PartLocator, propertyName: CssProperty): Promise<Optional<string>>;
|
|
11
|
+
enterText(locator: PartLocator, text: string, option?: Optional<Partial<EnterTextOption>>): Promise<void>;
|
|
12
|
+
click(locator: PartLocator, option?: ClickOption): Promise<void>;
|
|
13
|
+
hover(locator: PartLocator): Promise<void>;
|
|
14
14
|
wait(ms: number): Promise<void>;
|
|
15
|
-
getAttribute(locator:
|
|
16
|
-
getAttribute(locator:
|
|
17
|
-
getAttribute(locator:
|
|
18
|
-
getText(locator:
|
|
19
|
-
exists(locator:
|
|
20
|
-
isChecked(locator:
|
|
21
|
-
isDisabled(locator:
|
|
22
|
-
isReadonly(locator:
|
|
23
|
-
isVisible(locator:
|
|
24
|
-
hasCssClass(locator:
|
|
25
|
-
hasAttribute(locator:
|
|
15
|
+
getAttribute(locator: PartLocator, name: string, isMultiple: true): Promise<readonly string[]>;
|
|
16
|
+
getAttribute(locator: PartLocator, name: string, isMultiple: false): Promise<Optional<string>>;
|
|
17
|
+
getAttribute(locator: PartLocator, name: string): Promise<Optional<string>>;
|
|
18
|
+
getText(locator: PartLocator): Promise<Optional<string>>;
|
|
19
|
+
exists(locator: PartLocator): Promise<boolean>;
|
|
20
|
+
isChecked(locator: PartLocator): Promise<boolean>;
|
|
21
|
+
isDisabled(locator: PartLocator): Promise<boolean>;
|
|
22
|
+
isReadonly(locator: PartLocator): Promise<boolean>;
|
|
23
|
+
isVisible(locator: PartLocator): Promise<boolean>;
|
|
24
|
+
hasCssClass(locator: PartLocator, className: string): Promise<boolean>;
|
|
25
|
+
hasAttribute(locator: PartLocator, name: string): Promise<boolean>;
|
|
26
26
|
clone(): Interactor;
|
|
27
27
|
}
|
|
@@ -17,24 +17,21 @@ class PlaywrightInteractor {
|
|
|
17
17
|
}
|
|
18
18
|
selectOptionValue(locator, values) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
20
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(locator, this);
|
|
21
21
|
yield this.page.locator(cssLocator).selectOption(values);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
getInputValue(locator) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
26
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(locator, this);
|
|
27
27
|
return this.page.locator(cssLocator).inputValue();
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
getSelectValues(locator) {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const optionLocator =
|
|
33
|
-
type: core_1.LocatorType.Css,
|
|
34
|
-
selector: 'option:checked',
|
|
35
|
-
};
|
|
32
|
+
const optionLocator = (0, core_1.byCssSelector)('option:checked');
|
|
36
33
|
const selectedOptionLocator = core_1.locatorUtil.append(locator, optionLocator);
|
|
37
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(selectedOptionLocator);
|
|
34
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(selectedOptionLocator, this);
|
|
38
35
|
const allOptions = yield this.page.locator(cssLocator).all();
|
|
39
36
|
const values = [];
|
|
40
37
|
for (const option of allOptions) {
|
|
@@ -48,12 +45,9 @@ class PlaywrightInteractor {
|
|
|
48
45
|
}
|
|
49
46
|
getSelectLabels(locator) {
|
|
50
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
const optionLocator =
|
|
52
|
-
type: core_1.LocatorType.Css,
|
|
53
|
-
selector: 'option:checked',
|
|
54
|
-
};
|
|
48
|
+
const optionLocator = (0, core_1.byCssSelector)('option:checked');
|
|
55
49
|
const selectedOptionLocator = core_1.locatorUtil.append(locator, optionLocator);
|
|
56
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(selectedOptionLocator);
|
|
50
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(selectedOptionLocator, this);
|
|
57
51
|
const allOptions = yield this.page.locator(cssLocator).all();
|
|
58
52
|
const labels = [];
|
|
59
53
|
for (const option of allOptions) {
|
|
@@ -67,7 +61,7 @@ class PlaywrightInteractor {
|
|
|
67
61
|
}
|
|
68
62
|
getStyleValue(locator, propertyName) {
|
|
69
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
64
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(locator, this);
|
|
71
65
|
const elLocator = this.page.locator(cssLocator);
|
|
72
66
|
const value = yield elLocator.evaluate((element, prop) => {
|
|
73
67
|
return window.getComputedStyle(element).getPropertyValue(prop);
|
|
@@ -77,7 +71,7 @@ class PlaywrightInteractor {
|
|
|
77
71
|
}
|
|
78
72
|
enterText(locator, text, option) {
|
|
79
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
74
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(locator, this);
|
|
81
75
|
if (!(option === null || option === void 0 ? void 0 : option.append)) {
|
|
82
76
|
yield this.page.locator(cssLocator).clear();
|
|
83
77
|
}
|
|
@@ -86,13 +80,13 @@ class PlaywrightInteractor {
|
|
|
86
80
|
}
|
|
87
81
|
click(locator, option) {
|
|
88
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
83
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(locator, this);
|
|
90
84
|
yield this.page.locator(cssLocator).click();
|
|
91
85
|
});
|
|
92
86
|
}
|
|
93
87
|
hover(locator) {
|
|
94
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
89
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(locator, this);
|
|
96
90
|
yield this.page.locator(cssLocator).hover();
|
|
97
91
|
});
|
|
98
92
|
}
|
|
@@ -101,7 +95,7 @@ class PlaywrightInteractor {
|
|
|
101
95
|
}
|
|
102
96
|
getAttribute(locator, name, isMultiple) {
|
|
103
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
98
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(locator, this);
|
|
105
99
|
const elLocator = this.page.locator(cssLocator);
|
|
106
100
|
if (isMultiple) {
|
|
107
101
|
const locators = yield elLocator.all();
|
|
@@ -120,28 +114,28 @@ class PlaywrightInteractor {
|
|
|
120
114
|
}
|
|
121
115
|
getText(locator) {
|
|
122
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
117
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(locator, this);
|
|
124
118
|
const text = yield this.page.locator(cssLocator).textContent();
|
|
125
119
|
return text !== null && text !== void 0 ? text : undefined;
|
|
126
120
|
});
|
|
127
121
|
}
|
|
128
122
|
exists(locator) {
|
|
129
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
124
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(locator, this);
|
|
131
125
|
const count = yield this.page.locator(cssLocator).count();
|
|
132
126
|
return count > 0;
|
|
133
127
|
});
|
|
134
128
|
}
|
|
135
129
|
isChecked(locator) {
|
|
136
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
131
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(locator, this);
|
|
138
132
|
const checked = yield this.page.locator(cssLocator).isChecked();
|
|
139
133
|
return checked;
|
|
140
134
|
});
|
|
141
135
|
}
|
|
142
136
|
isDisabled(locator) {
|
|
143
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
-
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
138
|
+
const cssLocator = yield core_1.locatorUtil.toCssSelector(locator, this);
|
|
145
139
|
const isDisabled = yield this.page.locator(cssLocator).isDisabled();
|
|
146
140
|
return isDisabled;
|
|
147
141
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaywrightInteractor.js","sourceRoot":"","sources":["../src/PlaywrightInteractor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"PlaywrightInteractor.js","sourceRoot":"","sources":["../src/PlaywrightInteractor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAU8B;AAG9B,MAAa,oBAAoB;IAC/B,YAA4B,IAAU;QAAV,SAAI,GA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,CAAC;QACnC,CAAC;KAAA;IAEK,YAAY,CAAC,OAAoB,EAAE,IAAY;;YACnD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACzD,OAAO,SAAS,IAAI,IAAI,CAAC;QAC3B,CAAC;KAAA;IAED,KAAK;QACH,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF;AA1KD,oDA0KC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomic-testing/playwright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "Atomic Testing Playwright Adapter",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"url": "https://github.com/atomic-testing/atomic-testing.git"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@atomic-testing/core": "0.
|
|
19
|
-
"@atomic-testing/test-runner": "0.
|
|
18
|
+
"@atomic-testing/core": "0.29.0",
|
|
19
|
+
"@atomic-testing/test-runner": "0.29.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@playwright/test": "^1.32.1",
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
byCssSelector,
|
|
2
3
|
ClickOption,
|
|
3
4
|
CssProperty,
|
|
4
5
|
EnterTextOption,
|
|
5
6
|
Interactor,
|
|
6
|
-
LocatorChain,
|
|
7
|
-
LocatorType,
|
|
8
7
|
locatorUtil,
|
|
9
8
|
Optional,
|
|
10
|
-
|
|
9
|
+
PartLocator,
|
|
11
10
|
timingUtil,
|
|
12
11
|
} from '@atomic-testing/core';
|
|
13
12
|
import { Page } from '@playwright/test';
|
|
@@ -15,23 +14,20 @@ import { Page } from '@playwright/test';
|
|
|
15
14
|
export class PlaywrightInteractor implements Interactor {
|
|
16
15
|
constructor(public readonly page: Page) {}
|
|
17
16
|
|
|
18
|
-
async selectOptionValue(locator:
|
|
19
|
-
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
17
|
+
async selectOptionValue(locator: PartLocator, values: string[]): Promise<void> {
|
|
18
|
+
const cssLocator = await locatorUtil.toCssSelector(locator, this);
|
|
20
19
|
await this.page.locator(cssLocator).selectOption(values);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
async getInputValue(locator:
|
|
24
|
-
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
22
|
+
async getInputValue(locator: PartLocator): Promise<Optional<string>> {
|
|
23
|
+
const cssLocator = await locatorUtil.toCssSelector(locator, this);
|
|
25
24
|
return this.page.locator(cssLocator).inputValue();
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
async getSelectValues(locator:
|
|
29
|
-
const optionLocator:
|
|
30
|
-
type: LocatorType.Css,
|
|
31
|
-
selector: 'option:checked',
|
|
32
|
-
};
|
|
27
|
+
async getSelectValues(locator: PartLocator): Promise<Optional<readonly string[]>> {
|
|
28
|
+
const optionLocator: PartLocator = byCssSelector('option:checked');
|
|
33
29
|
const selectedOptionLocator = locatorUtil.append(locator, optionLocator);
|
|
34
|
-
const cssLocator = locatorUtil.toCssSelector(selectedOptionLocator);
|
|
30
|
+
const cssLocator = await locatorUtil.toCssSelector(selectedOptionLocator, this);
|
|
35
31
|
const allOptions = await this.page.locator(cssLocator).all();
|
|
36
32
|
const values: string[] = [];
|
|
37
33
|
for (const option of allOptions) {
|
|
@@ -43,13 +39,10 @@ export class PlaywrightInteractor implements Interactor {
|
|
|
43
39
|
return values;
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
async getSelectLabels(locator:
|
|
47
|
-
const optionLocator:
|
|
48
|
-
type: LocatorType.Css,
|
|
49
|
-
selector: 'option:checked',
|
|
50
|
-
};
|
|
42
|
+
async getSelectLabels(locator: PartLocator): Promise<Optional<readonly string[]>> {
|
|
43
|
+
const optionLocator: PartLocator = byCssSelector('option:checked');
|
|
51
44
|
const selectedOptionLocator = locatorUtil.append(locator, optionLocator);
|
|
52
|
-
const cssLocator = locatorUtil.toCssSelector(selectedOptionLocator);
|
|
45
|
+
const cssLocator = await locatorUtil.toCssSelector(selectedOptionLocator, this);
|
|
53
46
|
const allOptions = await this.page.locator(cssLocator).all();
|
|
54
47
|
const labels: string[] = [];
|
|
55
48
|
for (const option of allOptions) {
|
|
@@ -61,8 +54,8 @@ export class PlaywrightInteractor implements Interactor {
|
|
|
61
54
|
return labels;
|
|
62
55
|
}
|
|
63
56
|
|
|
64
|
-
async getStyleValue(locator:
|
|
65
|
-
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
57
|
+
async getStyleValue(locator: PartLocator, propertyName: CssProperty): Promise<Optional<string>> {
|
|
58
|
+
const cssLocator = await locatorUtil.toCssSelector(locator, this);
|
|
66
59
|
const elLocator = this.page.locator(cssLocator);
|
|
67
60
|
const value = await elLocator.evaluate((element, prop) => {
|
|
68
61
|
return window.getComputedStyle(element).getPropertyValue(prop as string);
|
|
@@ -70,21 +63,21 @@ export class PlaywrightInteractor implements Interactor {
|
|
|
70
63
|
return value;
|
|
71
64
|
}
|
|
72
65
|
|
|
73
|
-
async enterText(locator:
|
|
74
|
-
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
66
|
+
async enterText(locator: PartLocator, text: string, option?: Optional<Partial<EnterTextOption>>): Promise<void> {
|
|
67
|
+
const cssLocator = await locatorUtil.toCssSelector(locator, this);
|
|
75
68
|
if (!option?.append) {
|
|
76
69
|
await this.page.locator(cssLocator).clear();
|
|
77
70
|
}
|
|
78
71
|
await this.page.locator(cssLocator).type(text);
|
|
79
72
|
}
|
|
80
73
|
|
|
81
|
-
async click(locator:
|
|
82
|
-
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
74
|
+
async click(locator: PartLocator, option?: ClickOption): Promise<void> {
|
|
75
|
+
const cssLocator = await locatorUtil.toCssSelector(locator, this);
|
|
83
76
|
await this.page.locator(cssLocator).click();
|
|
84
77
|
}
|
|
85
78
|
|
|
86
|
-
async hover(locator:
|
|
87
|
-
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
79
|
+
async hover(locator: PartLocator): Promise<void> {
|
|
80
|
+
const cssLocator = await locatorUtil.toCssSelector(locator, this);
|
|
88
81
|
await this.page.locator(cssLocator).hover();
|
|
89
82
|
}
|
|
90
83
|
|
|
@@ -92,15 +85,15 @@ export class PlaywrightInteractor implements Interactor {
|
|
|
92
85
|
return timingUtil.wait(ms);
|
|
93
86
|
}
|
|
94
87
|
|
|
95
|
-
async getAttribute(locator:
|
|
96
|
-
async getAttribute(locator:
|
|
97
|
-
async getAttribute(locator:
|
|
88
|
+
async getAttribute(locator: PartLocator, name: string, isMultiple: true): Promise<readonly string[]>;
|
|
89
|
+
async getAttribute(locator: PartLocator, name: string, isMultiple: false): Promise<Optional<string>>;
|
|
90
|
+
async getAttribute(locator: PartLocator, name: string): Promise<Optional<string>>;
|
|
98
91
|
async getAttribute(
|
|
99
|
-
locator:
|
|
92
|
+
locator: PartLocator,
|
|
100
93
|
name: string,
|
|
101
94
|
isMultiple?: boolean,
|
|
102
95
|
): Promise<Optional<string> | readonly string[]> {
|
|
103
|
-
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
96
|
+
const cssLocator = await locatorUtil.toCssSelector(locator, this);
|
|
104
97
|
const elLocator = this.page.locator(cssLocator);
|
|
105
98
|
if (isMultiple) {
|
|
106
99
|
const locators = await elLocator.all();
|
|
@@ -117,36 +110,36 @@ export class PlaywrightInteractor implements Interactor {
|
|
|
117
110
|
return value ?? undefined;
|
|
118
111
|
}
|
|
119
112
|
|
|
120
|
-
async getText(locator:
|
|
121
|
-
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
113
|
+
async getText(locator: PartLocator): Promise<Optional<string>> {
|
|
114
|
+
const cssLocator = await locatorUtil.toCssSelector(locator, this);
|
|
122
115
|
const text = await this.page.locator(cssLocator).textContent();
|
|
123
116
|
return text ?? undefined;
|
|
124
117
|
}
|
|
125
118
|
|
|
126
|
-
async exists(locator:
|
|
127
|
-
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
119
|
+
async exists(locator: PartLocator): Promise<boolean> {
|
|
120
|
+
const cssLocator = await locatorUtil.toCssSelector(locator, this);
|
|
128
121
|
const count = await this.page.locator(cssLocator).count();
|
|
129
122
|
return count > 0;
|
|
130
123
|
}
|
|
131
124
|
|
|
132
|
-
async isChecked(locator:
|
|
133
|
-
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
125
|
+
async isChecked(locator: PartLocator): Promise<boolean> {
|
|
126
|
+
const cssLocator = await locatorUtil.toCssSelector(locator, this);
|
|
134
127
|
const checked = await this.page.locator(cssLocator).isChecked();
|
|
135
128
|
return checked;
|
|
136
129
|
}
|
|
137
130
|
|
|
138
|
-
async isDisabled(locator:
|
|
139
|
-
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
131
|
+
async isDisabled(locator: PartLocator): Promise<boolean> {
|
|
132
|
+
const cssLocator = await locatorUtil.toCssSelector(locator, this);
|
|
140
133
|
const isDisabled = await this.page.locator(cssLocator).isDisabled();
|
|
141
134
|
return isDisabled;
|
|
142
135
|
}
|
|
143
136
|
|
|
144
|
-
async isReadonly(locator:
|
|
137
|
+
async isReadonly(locator: PartLocator): Promise<boolean> {
|
|
145
138
|
const readonly = await this.getAttribute(locator, 'readonly');
|
|
146
139
|
return readonly != null;
|
|
147
140
|
}
|
|
148
141
|
|
|
149
|
-
async isVisible(locator:
|
|
142
|
+
async isVisible(locator: PartLocator): Promise<boolean> {
|
|
150
143
|
const exists = await this.exists(locator);
|
|
151
144
|
if (!exists) {
|
|
152
145
|
return false;
|
|
@@ -170,7 +163,7 @@ export class PlaywrightInteractor implements Interactor {
|
|
|
170
163
|
return true;
|
|
171
164
|
}
|
|
172
165
|
|
|
173
|
-
async hasCssClass(locator:
|
|
166
|
+
async hasCssClass(locator: PartLocator, className: string): Promise<boolean> {
|
|
174
167
|
const classNames = await this.getAttribute(locator, 'class');
|
|
175
168
|
if (classNames == null) {
|
|
176
169
|
return false;
|
|
@@ -180,7 +173,7 @@ export class PlaywrightInteractor implements Interactor {
|
|
|
180
173
|
return names.includes(className);
|
|
181
174
|
}
|
|
182
175
|
|
|
183
|
-
async hasAttribute(locator:
|
|
176
|
+
async hasAttribute(locator: PartLocator, name: string): Promise<boolean> {
|
|
184
177
|
const attrValue = await this.getAttribute(locator, name);
|
|
185
178
|
return attrValue != null;
|
|
186
179
|
}
|