@atomic-testing/playwright 0.2.0 → 0.7.1
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Tianzhen Lin (Tangent)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -7,13 +7,18 @@ export declare class PlaywrightInteractor implements IInteractor {
|
|
|
7
7
|
selectOptionValue(locator: LocatorChain, values: string[]): Promise<void>;
|
|
8
8
|
getInputValue(locator: LocatorChain): Promise<Optional<string>>;
|
|
9
9
|
getSelectValues(locator: LocatorChain): Promise<Optional<readonly string[]>>;
|
|
10
|
-
enterText(locator: LocatorChain, text: string, option?: Partial<IEnterTextOption
|
|
10
|
+
enterText(locator: LocatorChain, text: string, option?: Optional<Partial<IEnterTextOption>>): Promise<void>;
|
|
11
11
|
click(locator: LocatorChain, option?: IClickOption): Promise<void>;
|
|
12
|
+
hover(locator: LocatorChain): Promise<void>;
|
|
12
13
|
getAttribute(locator: LocatorChain, name: string, isMultiple: true): Promise<readonly string[]>;
|
|
13
14
|
getAttribute(locator: LocatorChain, name: string, isMultiple: false): Promise<Optional<string>>;
|
|
14
15
|
getAttribute(locator: LocatorChain, name: string): Promise<Optional<string>>;
|
|
15
16
|
getText(locator: LocatorChain): Promise<Optional<string>>;
|
|
16
17
|
exists(locator: LocatorChain): Promise<boolean>;
|
|
17
18
|
isChecked(locator: LocatorChain): Promise<boolean>;
|
|
19
|
+
isDisabled(locator: LocatorChain): Promise<boolean>;
|
|
20
|
+
isReadonly(locator: LocatorChain): Promise<boolean>;
|
|
21
|
+
hasCssClass(locator: LocatorChain, className: string): Promise<boolean>;
|
|
22
|
+
hasAttribute(locator: LocatorChain, name: string): Promise<boolean>;
|
|
18
23
|
clone(): IInteractor;
|
|
19
24
|
}
|
|
@@ -49,6 +49,9 @@ class PlaywrightInteractor {
|
|
|
49
49
|
enterText(locator, text, option) {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
51
|
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
52
|
+
if (!(option === null || option === void 0 ? void 0 : option.append)) {
|
|
53
|
+
yield this.page.locator(cssLocator).clear();
|
|
54
|
+
}
|
|
52
55
|
yield this.page.locator(cssLocator).type(text);
|
|
53
56
|
});
|
|
54
57
|
}
|
|
@@ -58,6 +61,12 @@ class PlaywrightInteractor {
|
|
|
58
61
|
yield this.page.locator(cssLocator).click();
|
|
59
62
|
});
|
|
60
63
|
}
|
|
64
|
+
hover(locator) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
67
|
+
yield this.page.locator(cssLocator).hover();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
61
70
|
getAttribute(locator, name, isMultiple) {
|
|
62
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
72
|
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
@@ -98,6 +107,35 @@ class PlaywrightInteractor {
|
|
|
98
107
|
return checked;
|
|
99
108
|
});
|
|
100
109
|
}
|
|
110
|
+
isDisabled(locator) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const cssLocator = core_1.locatorUtil.toCssSelector(locator);
|
|
113
|
+
const isDisabled = yield this.page.locator(cssLocator).isDisabled();
|
|
114
|
+
return isDisabled;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
isReadonly(locator) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const readonly = yield this.getAttribute(locator, 'readonly');
|
|
120
|
+
return readonly != null;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
hasCssClass(locator, className) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
const classNames = yield this.getAttribute(locator, 'class');
|
|
126
|
+
if (classNames == null) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
const names = classNames.split(/\s+/);
|
|
130
|
+
return names.includes(className);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
hasAttribute(locator, name) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
const attrValue = yield this.getAttribute(locator, name);
|
|
136
|
+
return attrValue != null;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
101
139
|
clone() {
|
|
102
140
|
return new PlaywrightInteractor(this.page);
|
|
103
141
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaywrightInteractor.js","sourceRoot":"","sources":["../src/PlaywrightInteractor.ts"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AU,GAAG,kBAAW,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YACtD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,UAAU,EAAE,CAAC;YACpE,OAAO,UAAU,CAAC;QACpB,CAAC;KAAA;IAEK,UAAU,CAAC,OAAqB;;YACpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YAC9D,OAAO,QAAQ,IAAI,IAAI,CAAC;QAC1B,CAAC;KAAA;IAEK,WAAW,CAAC,OAAqB,EAAE,SAAiB;;YACxD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7D,IAAI,UAAU,IAAI,IAAI,EAAE;gBACtB,OAAO,KAAK,CAAC;aACd;YAED,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtC,OAAO,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACnC,CAAC;KAAA;IAEK,YAAY,CAAC,OAAqB,EAAE,IAAY;;YACpD,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;AAxHD,oDAwHC"}
|
package/package.json
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomic-testing/playwright",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.7.1",
|
|
4
|
+
"description": "Atomic Testing Playwright Adapter",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
8
8
|
"src"
|
|
9
9
|
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "tsc",
|
|
12
|
-
"postbuild": "node ../../scripts/postBuild.js"
|
|
13
|
-
},
|
|
14
10
|
"author": "Tianzhen Lin <tangent@usa.net>",
|
|
15
11
|
"keywords": [],
|
|
16
12
|
"license": "MIT",
|
|
17
13
|
"repository": {
|
|
18
14
|
"type": "git",
|
|
19
|
-
"url": "https://github.com/tangentlin/
|
|
15
|
+
"url": "https://github.com/tangentlin/atomic-testing.git"
|
|
20
16
|
},
|
|
21
17
|
"dependencies": {
|
|
22
|
-
"@atomic-testing/core": "
|
|
18
|
+
"@atomic-testing/core": "0.7.1"
|
|
23
19
|
},
|
|
24
20
|
"devDependencies": {
|
|
25
21
|
"@playwright/test": "^1.31.2",
|
|
@@ -31,5 +27,9 @@
|
|
|
31
27
|
},
|
|
32
28
|
"peerDependencies": {
|
|
33
29
|
"@playwright/test": ">=1.30.2"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"postbuild": "node ../../scripts/postBuild.js"
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|
|
@@ -40,8 +40,11 @@ export class PlaywrightInteractor implements IInteractor {
|
|
|
40
40
|
return values;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
async enterText(locator: LocatorChain, text: string, option?: Partial<IEnterTextOption
|
|
43
|
+
async enterText(locator: LocatorChain, text: string, option?: Optional<Partial<IEnterTextOption>>): Promise<void> {
|
|
44
44
|
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
45
|
+
if (!option?.append) {
|
|
46
|
+
await this.page.locator(cssLocator).clear();
|
|
47
|
+
}
|
|
45
48
|
await this.page.locator(cssLocator).type(text);
|
|
46
49
|
}
|
|
47
50
|
|
|
@@ -50,6 +53,11 @@ export class PlaywrightInteractor implements IInteractor {
|
|
|
50
53
|
await this.page.locator(cssLocator).click();
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
async hover(locator: LocatorChain): Promise<void> {
|
|
57
|
+
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
58
|
+
await this.page.locator(cssLocator).hover();
|
|
59
|
+
}
|
|
60
|
+
|
|
53
61
|
async getAttribute(locator: LocatorChain, name: string, isMultiple: true): Promise<readonly string[]>;
|
|
54
62
|
async getAttribute(locator: LocatorChain, name: string, isMultiple: false): Promise<Optional<string>>;
|
|
55
63
|
async getAttribute(locator: LocatorChain, name: string): Promise<Optional<string>>;
|
|
@@ -93,6 +101,32 @@ export class PlaywrightInteractor implements IInteractor {
|
|
|
93
101
|
return checked;
|
|
94
102
|
}
|
|
95
103
|
|
|
104
|
+
async isDisabled(locator: LocatorChain): Promise<boolean> {
|
|
105
|
+
const cssLocator = locatorUtil.toCssSelector(locator);
|
|
106
|
+
const isDisabled = await this.page.locator(cssLocator).isDisabled();
|
|
107
|
+
return isDisabled;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async isReadonly(locator: LocatorChain): Promise<boolean> {
|
|
111
|
+
const readonly = await this.getAttribute(locator, 'readonly');
|
|
112
|
+
return readonly != null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async hasCssClass(locator: LocatorChain, className: string): Promise<boolean> {
|
|
116
|
+
const classNames = await this.getAttribute(locator, 'class');
|
|
117
|
+
if (classNames == null) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const names = classNames.split(/\s+/);
|
|
122
|
+
return names.includes(className);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async hasAttribute(locator: LocatorChain, name: string): Promise<boolean> {
|
|
126
|
+
const attrValue = await this.getAttribute(locator, name);
|
|
127
|
+
return attrValue != null;
|
|
128
|
+
}
|
|
129
|
+
|
|
96
130
|
clone(): IInteractor {
|
|
97
131
|
return new PlaywrightInteractor(this.page);
|
|
98
132
|
}
|