@winning-test/component 0.0.104 → 0.0.107
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/cms60/component/BlockComponent.js +233 -0
- package/cms60/component/ButtonComponent.js +23 -0
- package/cms60/component/CascaderComponent.js +51 -0
- package/cms60/component/CheckboxComponent.js +46 -0
- package/cms60/component/Component.js +109 -0
- package/cms60/component/DialogComponent.js +26 -0
- package/cms60/component/InputComponent.js +31 -0
- package/cms60/component/LeftMenuComponent.js +39 -0
- package/cms60/component/ListComponent.js +52 -0
- package/cms60/component/MessageComponent.js +57 -0
- package/cms60/component/RadioComponent.js +41 -0
- package/cms60/component/SelectComponent.js +74 -0
- package/cms60/component/SwitchComponent.js +48 -0
- package/cms60/component/TableComponent.js +94 -0
- package/cms60/component/TextComponent.js +23 -0
- package/cms60/page/Page.js +187 -0
- package/cms60/test/component.test.js +26 -0
- package/cms60/test/component.test.json +15 -0
- package/package.json +1 -1
- package/winex-region/page/Page.js +5 -4
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 块组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class BlockComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 块组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} xpath xpath
|
|
11
|
+
*/
|
|
12
|
+
constructor(browser, xpath) {
|
|
13
|
+
super(browser);
|
|
14
|
+
this.xpath = xpath;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_createXpath() {
|
|
18
|
+
return this.xpath;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 获取块组件
|
|
23
|
+
* @param {String} xpath xpath
|
|
24
|
+
* @returns 块组件
|
|
25
|
+
*/
|
|
26
|
+
blockComponent(xpath) {
|
|
27
|
+
let that = this;
|
|
28
|
+
class _BlockComponent extends BlockComponent {
|
|
29
|
+
_createRootXpath() {
|
|
30
|
+
return that.getXpath();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return new _BlockComponent(this.browser, xpath);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 获取按钮组件
|
|
38
|
+
* @param {String} text 文本
|
|
39
|
+
* @returns 按钮组件
|
|
40
|
+
*/
|
|
41
|
+
buttonComponent(text) {
|
|
42
|
+
let that = this;
|
|
43
|
+
class ButtonComponent extends require("./ButtonComponent") {
|
|
44
|
+
_createRootXpath() {
|
|
45
|
+
return that.getXpath();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return new ButtonComponent(this.browser, text);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 获取级联选择器组件
|
|
53
|
+
* @param {String} placeholder 背景文字
|
|
54
|
+
* @param {String} label 标签
|
|
55
|
+
* @returns 级联选择器组件
|
|
56
|
+
*/
|
|
57
|
+
cascaderComponent(placeholder, label) {
|
|
58
|
+
let that = this;
|
|
59
|
+
class CascaderComponent extends require("./CascaderComponent") {
|
|
60
|
+
_createRootXpath() {
|
|
61
|
+
return that.getXpath();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return new CascaderComponent(this.browser, placeholder, label);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 获取复选框组件
|
|
69
|
+
* @param {String} label 标签
|
|
70
|
+
* @returns 复选框组件
|
|
71
|
+
*/
|
|
72
|
+
checkboxComponent(label) {
|
|
73
|
+
let that = this;
|
|
74
|
+
class CheckboxComponent extends require("./CheckboxComponent") {
|
|
75
|
+
_createRootXpath() {
|
|
76
|
+
return that.getXpath();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return new CheckboxComponent(this.browser, label);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 获取对话框组件
|
|
84
|
+
* @param {String} title 标题
|
|
85
|
+
* @returns 对话框组件
|
|
86
|
+
*/
|
|
87
|
+
dialogComponent(title) {
|
|
88
|
+
let that = this;
|
|
89
|
+
class DialogComponent extends require("./DialogComponent") {
|
|
90
|
+
_createRootXpath() {
|
|
91
|
+
return that.getXpath();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return new DialogComponent(this.browser, title);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 获取输入框组件
|
|
99
|
+
* @param {String} placeholder 背景文字
|
|
100
|
+
* @param {String} label 标签
|
|
101
|
+
* @returns 输入框组件
|
|
102
|
+
*/
|
|
103
|
+
inputComponent(placeholder, label) {
|
|
104
|
+
let that = this;
|
|
105
|
+
class InputComponent extends require("./InputComponent") {
|
|
106
|
+
_createRootXpath() {
|
|
107
|
+
return that.getXpath();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return new InputComponent(this.browser, placeholder, label);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 获取左侧菜单组件
|
|
115
|
+
* @returns 左侧菜单组件
|
|
116
|
+
*/
|
|
117
|
+
leftMenuComponent() {
|
|
118
|
+
let that = this;
|
|
119
|
+
class LeftMenuComponent extends require("./LeftMenuComponent") {
|
|
120
|
+
_createRootXpath() {
|
|
121
|
+
return that.getXpath();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return new LeftMenuComponent(this.browser);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 获取列表组件
|
|
129
|
+
* @returns 列表组件
|
|
130
|
+
*/
|
|
131
|
+
listComponent() {
|
|
132
|
+
let that = this;
|
|
133
|
+
class ListComponent extends require("./ListComponent") {
|
|
134
|
+
_createRootXpath() {
|
|
135
|
+
return that.getXpath();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return new ListComponent(this.browser);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 获取消息组件
|
|
143
|
+
* @param {Stirng} text 文本
|
|
144
|
+
* @returns 消息组件
|
|
145
|
+
*/
|
|
146
|
+
messageComponent(text) {
|
|
147
|
+
let that = this;
|
|
148
|
+
class MessageComponent extends require("./MessageComponent") {
|
|
149
|
+
_createRootXpath() {
|
|
150
|
+
return that.getXpath();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return new MessageComponent(this.browser, text);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* 获取单选框组件
|
|
158
|
+
* @param {Stirng} label 标签
|
|
159
|
+
* @returns 单选框组件
|
|
160
|
+
*/
|
|
161
|
+
radioComponent(label) {
|
|
162
|
+
let that = this;
|
|
163
|
+
class RadioComponent extends require("./RadioComponent") {
|
|
164
|
+
_createRootXpath() {
|
|
165
|
+
return that.getXpath();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return new RadioComponent(this.browser, label);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 获取选择器组件
|
|
173
|
+
* @param {String} placeholder 背景文字
|
|
174
|
+
* @param {String} label 标签
|
|
175
|
+
* @returns 选择器组件
|
|
176
|
+
*/
|
|
177
|
+
selectComponent(placeholder, label) {
|
|
178
|
+
let that = this;
|
|
179
|
+
class SelectComponent extends require("./SelectComponent") {
|
|
180
|
+
_createRootXpath() {
|
|
181
|
+
return that.getXpath();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return new SelectComponent(this.browser, placeholder, label);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* 获取开关组件
|
|
189
|
+
* @param {String} label 标签
|
|
190
|
+
* @returns 开关组件
|
|
191
|
+
*/
|
|
192
|
+
switchComponent(label) {
|
|
193
|
+
let that = this;
|
|
194
|
+
class SwitchComponent extends require("./SwitchComponent") {
|
|
195
|
+
_createRootXpath() {
|
|
196
|
+
return that.getXpath();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return new SwitchComponent(this.browser, label);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* 获取表格组件
|
|
204
|
+
* @returns 表格组件
|
|
205
|
+
*/
|
|
206
|
+
tableComponent() {
|
|
207
|
+
let that = this;
|
|
208
|
+
class TableComponent extends require("./TableComponent") {
|
|
209
|
+
_createRootXpath() {
|
|
210
|
+
return that.getXpath();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return new TableComponent(this.browser);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 获取文本组件
|
|
218
|
+
* @param {String} text 文本
|
|
219
|
+
* @returns 文本组件
|
|
220
|
+
*/
|
|
221
|
+
textComponent(text) {
|
|
222
|
+
let that = this;
|
|
223
|
+
class TextComponent extends require("./TextComponent") {
|
|
224
|
+
_createRootXpath() {
|
|
225
|
+
return that.getXpath();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return new TextComponent(this.browser, text);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
module.exports= BlockComponent;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 按钮组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class ButtonComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 按钮组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} text 文本
|
|
11
|
+
*/
|
|
12
|
+
constructor(browser, text) {
|
|
13
|
+
super(browser);
|
|
14
|
+
this.text = text;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_createXpath() {
|
|
18
|
+
return `//*[normalize-space(text())='${this.text}']/ancestor-or-self::button`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = ButtonComponent;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 级联选择器组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class CascaderComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 级联选择器组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} placeholder 背景文字
|
|
11
|
+
* @param {String} label 标签
|
|
12
|
+
*/
|
|
13
|
+
constructor(browser, placeholder, label) {
|
|
14
|
+
super(browser);
|
|
15
|
+
this.placeholder = placeholder;
|
|
16
|
+
this.label = label;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_createXpath() {
|
|
20
|
+
if (this.placeholder) {
|
|
21
|
+
return `//input[@placeholder='${this.placeholder}']`;
|
|
22
|
+
}
|
|
23
|
+
if (this.label) {
|
|
24
|
+
return `//*[normalize-space(text())='${this.label}']/..//input`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 选择
|
|
30
|
+
* @param {...String} items 选项
|
|
31
|
+
*/
|
|
32
|
+
async select(...items) {
|
|
33
|
+
class ListComponent extends require("./ListComponent") {
|
|
34
|
+
_createXpath() {
|
|
35
|
+
return "//*[contains(@class,'el-scrollbar')]//ul"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
let xpath = this.getXpath();
|
|
39
|
+
await (await this.browser.findElement(xpath)).click();
|
|
40
|
+
let listComponent = new ListComponent(this.browser);
|
|
41
|
+
await listComponent.waitUntilBeVisible();
|
|
42
|
+
for (let i = 0; i < items.length; i++) {
|
|
43
|
+
let item = items[i];
|
|
44
|
+
let listComponent = new ListComponent(this.browser);
|
|
45
|
+
await listComponent.select(item);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = CascaderComponent;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 复选框组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class CheckboxComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 复选框组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} label 标签
|
|
11
|
+
*/
|
|
12
|
+
constructor(browser, label) {
|
|
13
|
+
super(browser);
|
|
14
|
+
this.label = label;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_createXpath() {
|
|
18
|
+
if (this.label){
|
|
19
|
+
return `//*[normalize-space(text())='${this.label}']/ancestor-or-self::label//input[@type='checkbox']`;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return "//input[@type='checkbox']";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 选择
|
|
28
|
+
*/
|
|
29
|
+
async select() {
|
|
30
|
+
if (!(await (await this.browser.findElement(this.getXpath())).isSelected())) {
|
|
31
|
+
await (await this.browser.findElement(this.getXpath())).click();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 取消选择
|
|
37
|
+
*/
|
|
38
|
+
async unselect() {
|
|
39
|
+
if (await (await this.browser.findElement(this.getXpath())).isSelected()) {
|
|
40
|
+
await (await this.browser.findElement(this.getXpath())).click();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = CheckboxComponent;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class Component extends require("@winning-test/autotest-webui/src/Component") {
|
|
6
|
+
|
|
7
|
+
static delayTime = 200;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 组件
|
|
11
|
+
* @param {Browser} browser
|
|
12
|
+
*/
|
|
13
|
+
constructor(browser) {
|
|
14
|
+
super(browser)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getXpath() {
|
|
18
|
+
return `${super.getXpath()}[not (ancestor-or-self::*[contains(@style,'display: none')])]`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async click() {
|
|
22
|
+
await super.click();
|
|
23
|
+
await this.browser.sleep(Component.delayTime);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async doubleClick() {
|
|
27
|
+
await super.doubleClick();
|
|
28
|
+
await this.browser.sleep(Component.delayTime);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async input(...agrs) {
|
|
32
|
+
await super.input(...agrs);
|
|
33
|
+
await this.browser.sleep(Component.delayTime);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async clear() {
|
|
37
|
+
await super.clear();
|
|
38
|
+
await this.browser.sleep(Component.delayTime);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async getText() {
|
|
42
|
+
await this.browser.sleep(Component.delayTime);
|
|
43
|
+
return await super.getText();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async getValue() {
|
|
47
|
+
await this.browser.sleep(Component.delayTime);
|
|
48
|
+
return await super.getValue();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
async getAttribute(attributeName) {
|
|
53
|
+
await this.browser.sleep(Component.delayTime);
|
|
54
|
+
return await super.getAttribute(attributeName);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async waitUntilBeDisabled() {
|
|
58
|
+
await super.waitUntilBeDisabled();
|
|
59
|
+
await this.browser.sleep(Component.delayTime);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async waitUntilBeEnabled() {
|
|
63
|
+
await super.waitUntilBeEnabled();
|
|
64
|
+
await this.browser.sleep(Component.delayTime);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async waitUntilBeNotVisible() {
|
|
68
|
+
await super.waitUntilBeNotVisible();
|
|
69
|
+
await this.browser.sleep(Component.delayTime);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async waitUntilBeVisible() {
|
|
73
|
+
await super.waitUntilBeVisible();
|
|
74
|
+
await this.browser.sleep(Component.delayTime);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async isEnabled() {
|
|
78
|
+
return await super.isEnabled();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 鼠标移动到组件后悬停
|
|
83
|
+
*/
|
|
84
|
+
async moveMouseTo() {
|
|
85
|
+
await this.browser.moveMouseTo(this.getXpath());
|
|
86
|
+
await this.browser.sleep(Component.delayTime);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 滚动页面到元素位置
|
|
91
|
+
*/
|
|
92
|
+
async scrollIntoView() {
|
|
93
|
+
(await this.browser.findElement(this.getXpath())).scrollIntoView();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 右击
|
|
98
|
+
*/
|
|
99
|
+
async contextClick() {
|
|
100
|
+
const { By, until } = require("selenium-webdriver");
|
|
101
|
+
const xpath = this.getXpath();
|
|
102
|
+
await this.browser.webDriver.wait(until.elementLocated(By.xpath(xpath)), this.browser.config.timeout);
|
|
103
|
+
let actions = this.browser.webDriver.actions();
|
|
104
|
+
actions.contextClick(await this.browser.webDriver.findElement(By.xpath(xpath)))
|
|
105
|
+
await actions.perform();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = Component;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 对话框组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class DialogComponent extends require("./BlockComponent") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 对话框组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} title 标题
|
|
11
|
+
*/
|
|
12
|
+
constructor(browser, title) {
|
|
13
|
+
super(browser, null, null);
|
|
14
|
+
this.title = title;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_createXpath() {
|
|
18
|
+
if (this.title){
|
|
19
|
+
return `//*[contains(normalize-space(text()),'${this.title}')]/ancestor::*[@role='dialog']`;
|
|
20
|
+
}
|
|
21
|
+
return `//*[@role='dialog']`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = DialogComponent;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 输入框组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class InputComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 输入框组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} placeholder 背景文字
|
|
11
|
+
* @param {String} label 标签
|
|
12
|
+
*/
|
|
13
|
+
constructor(browser, placeholder, label) {
|
|
14
|
+
super(browser);
|
|
15
|
+
this.placeholder = placeholder;
|
|
16
|
+
this.label = label;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_createXpath() {
|
|
20
|
+
if (this.placeholder) {
|
|
21
|
+
return `//input[@placeholder='${this.placeholder}']`;
|
|
22
|
+
}
|
|
23
|
+
if (this.label) {
|
|
24
|
+
return `//*[normalize-space(text())='${this.label}']/..//input`;
|
|
25
|
+
}
|
|
26
|
+
return "//input[@type='text']";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = InputComponent;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 住院左侧菜单组件类
|
|
3
|
+
* @作者 zhang.hao
|
|
4
|
+
*/
|
|
5
|
+
class LeftMenuComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 住院左侧菜单组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
*/
|
|
11
|
+
constructor(browser) {
|
|
12
|
+
super(browser);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_createXpath() {
|
|
16
|
+
return `//*[@class="toggle-sidebar-main"]`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 选择菜单
|
|
22
|
+
* @param {...String} menuItems 菜单项
|
|
23
|
+
*/
|
|
24
|
+
async select(...menuItems) {
|
|
25
|
+
if (menuItems.length > 0) {
|
|
26
|
+
let xpath = `${this.getXpath()}//*[normalize-space(text())='${menuItems[0]}']/..`;
|
|
27
|
+
await this.browser.waitUntilElementBeVisible(xpath);
|
|
28
|
+
await (await this.browser.findElement(xpath))._click();
|
|
29
|
+
}
|
|
30
|
+
if (menuItems.length > 1) {
|
|
31
|
+
let xpath = `${this.getXpath()}//*[normalize-space(text())='${menuItems[0]}']/ancestor::li//*[normalize-space(text())='${menuItems[1]}']/..`;
|
|
32
|
+
await this.browser.waitUntilElementBeVisible(xpath);
|
|
33
|
+
await (await this.browser.findElement(xpath))._click();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = LeftMenuComponent;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 列表组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class ListComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 列表组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
*/
|
|
11
|
+
constructor(browser) {
|
|
12
|
+
super(browser);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_createXpath() {
|
|
16
|
+
return `//ul`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 选择列表
|
|
21
|
+
* @param {...String} items 列表项
|
|
22
|
+
*/
|
|
23
|
+
async select(...items) {
|
|
24
|
+
let xpath = `${this.getXpath()}`;
|
|
25
|
+
await this.browser.waitUntilElementBeVisible(xpath);
|
|
26
|
+
for (let i = 0; i < items.length; i++) {
|
|
27
|
+
let item = items[i];
|
|
28
|
+
xpath = `${this.getXpath()}//*[normalize-space(text())='${item}']/ancestor-or-self::li`;
|
|
29
|
+
await this.browser.waitUntilElementBeVisible(xpath);
|
|
30
|
+
await (await this.browser.findElement(xpath)).scrollIntoView();
|
|
31
|
+
await (await this.browser.findElement(xpath)).click();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 获取列表项
|
|
37
|
+
* @returns 列表项
|
|
38
|
+
*/
|
|
39
|
+
async getListItems() {
|
|
40
|
+
let ret = [];
|
|
41
|
+
let xpath = `${this.getXpath()}//li`;
|
|
42
|
+
let elements = await this.browser.findElements(xpath);
|
|
43
|
+
for (let i = 0; i < elements.length; i++) {
|
|
44
|
+
let element = elements[i];
|
|
45
|
+
ret.push(await element.getText(true));
|
|
46
|
+
}
|
|
47
|
+
return ret;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = ListComponent;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 消息组件类
|
|
3
|
+
* @作者: MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class MessageComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 消息组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} text 消息内容
|
|
11
|
+
*/
|
|
12
|
+
constructor(browser, text) {
|
|
13
|
+
super(browser)
|
|
14
|
+
this.text = text;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_createXpath() {
|
|
18
|
+
return `//*[contains(normalize-space(text()),'${this.text}')]/ancestor-or-self::*[@role='alert']`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 获取消息内容
|
|
23
|
+
* @returns 消息内容
|
|
24
|
+
*/
|
|
25
|
+
async getText() {
|
|
26
|
+
let xpath = this.getXpath();
|
|
27
|
+
let text = await (await this.browser.findElement(xpath)).getText();
|
|
28
|
+
return text;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 等待出现
|
|
33
|
+
*/
|
|
34
|
+
async waitUntilBeVisible() {
|
|
35
|
+
let xpath = this.getXpath();
|
|
36
|
+
await this.browser.waitUntilElementBeVisible(xpath);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 等待消失
|
|
41
|
+
*/
|
|
42
|
+
async waitUntilBeNotVisible() {
|
|
43
|
+
let xpath = this.getXpath();
|
|
44
|
+
await this.browser.waitUntilElementBeNotVisible(xpath);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 关闭
|
|
49
|
+
*/
|
|
50
|
+
async close() {
|
|
51
|
+
let xpath = `${this.getXpath()}//i[contains(@class,'el-message__closeBtn')]`;
|
|
52
|
+
await (await this.browser.findElement(xpath)).click();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = MessageComponent;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 单选框组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class RadioComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 单选框组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} label 标签
|
|
11
|
+
*/
|
|
12
|
+
constructor(browser, label) {
|
|
13
|
+
super(browser);
|
|
14
|
+
this.label = label;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_createXpath() {
|
|
18
|
+
return `//*[normalize-space(text())='${this.label}']/ancestor-or-self::label//input[@type='radio']`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 选择
|
|
23
|
+
*/
|
|
24
|
+
async select() {
|
|
25
|
+
if (!(await (await this.browser.findElement(this.getXpath())).isSelected())) {
|
|
26
|
+
await (await this.browser.findElement(this.getXpath())).click();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 取消选择
|
|
32
|
+
*/
|
|
33
|
+
async unselect() {
|
|
34
|
+
if (await (await this.browser.findElement(this.getXpath())).isSelected()) {
|
|
35
|
+
await (await this.browser.findElement(this.getXpath())).click();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = RadioComponent;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 选择器组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class SelectComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 选择器组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} placeholder 背景文字
|
|
11
|
+
* @param {String} label 标签
|
|
12
|
+
*/
|
|
13
|
+
constructor(browser, placeholder, label) {
|
|
14
|
+
super(browser);
|
|
15
|
+
this.placeholder = placeholder;
|
|
16
|
+
this.label = label;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_createXpath() {
|
|
20
|
+
if (this.placeholder) {
|
|
21
|
+
return `//input[@placeholder='${this.placeholder}']`;
|
|
22
|
+
}
|
|
23
|
+
if (this.label) {
|
|
24
|
+
return `//*[normalize-space(text())='${this.label}']/..//input`;
|
|
25
|
+
}
|
|
26
|
+
return "//input[@type='text']";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 选择选项
|
|
31
|
+
* @param {...String} items 选项
|
|
32
|
+
*/
|
|
33
|
+
async select(...items) {
|
|
34
|
+
let count = 2;
|
|
35
|
+
while (count > 0) {
|
|
36
|
+
try {
|
|
37
|
+
await this._select(...items);
|
|
38
|
+
const value = await this.getValue();
|
|
39
|
+
if (!(value && items.join().indexOf(value) !== -1)) {
|
|
40
|
+
throw new Error(`选择${items}失败`);
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (count > 1) {
|
|
45
|
+
count--;
|
|
46
|
+
await this.browser.sleep(500);
|
|
47
|
+
} else {
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async _select(...items) {
|
|
57
|
+
class ListComponent extends require("./ListComponent") {
|
|
58
|
+
_createXpath() {
|
|
59
|
+
return "//*[contains(@class,'el-scrollbar')]//ul"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
let xpath = this.getXpath();
|
|
63
|
+
await (await this.browser.findElement(xpath)).click();
|
|
64
|
+
let listComponent = new ListComponent(this.browser);
|
|
65
|
+
await listComponent.select(...items);
|
|
66
|
+
if (items.length > 1) {
|
|
67
|
+
xpath = this.getXpath();
|
|
68
|
+
await (await this.browser.findElement(xpath)).click();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = SelectComponent;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 开关组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class SwitchComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 开关组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} label 标签
|
|
11
|
+
*/
|
|
12
|
+
constructor(browser, label) {
|
|
13
|
+
super(browser);
|
|
14
|
+
this.label = label;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_createXpath() {
|
|
18
|
+
if (this.label){
|
|
19
|
+
return `//*[normalize-space(text())='${this.label}']/..//*[@role='switch']`;
|
|
20
|
+
}
|
|
21
|
+
return "//*[@role='switch']";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 打开
|
|
26
|
+
*/
|
|
27
|
+
async on() {
|
|
28
|
+
let xpath = `${this.getXpath()}//input[@type='checkbox']`;
|
|
29
|
+
let checked = Boolean(await (await this.browser.findElement(xpath)).getAttribute("checked"));
|
|
30
|
+
if (!checked) {
|
|
31
|
+
await (await this.browser.findElement(xpath)).click();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 关闭
|
|
37
|
+
*/
|
|
38
|
+
async off() {
|
|
39
|
+
let xpath = `${this.getXpath()}//input[@type='checkbox']`;
|
|
40
|
+
let checked = Boolean(await (await this.browser.findElement(xpath)).getAttribute("checked"));
|
|
41
|
+
if (checked) {
|
|
42
|
+
await (await this.browser.findElement(xpath)).click();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = SwitchComponent;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表格组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class TableComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 表格组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
*/
|
|
11
|
+
constructor(browser) {
|
|
12
|
+
super(browser);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_createRootXpath() {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_createXpath() {
|
|
20
|
+
return "//table";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_createHeaderXapth() {
|
|
24
|
+
return "//thead";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_createBodyXapth() {
|
|
28
|
+
return "//tbody";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 获取表格数据
|
|
33
|
+
* @returns 表格数据
|
|
34
|
+
*/
|
|
35
|
+
async getTableData() {
|
|
36
|
+
let ret = [];
|
|
37
|
+
let xpath = `(${this.getXpath()}${this._createBodyXapth()}//tr)[1]`;
|
|
38
|
+
if (!(await this.browser.isDisplayed(xpath, this.browser.config.timeout))) {
|
|
39
|
+
return ret;
|
|
40
|
+
}
|
|
41
|
+
await this.browser.sleep(TableComponent.delayTime);
|
|
42
|
+
// 处理表头
|
|
43
|
+
if (!this._createHeaderXapth()) {
|
|
44
|
+
return ret;
|
|
45
|
+
}
|
|
46
|
+
xpath = `(${this.getXpath()}${this._createHeaderXapth()}//tr)[1]/th`;
|
|
47
|
+
let titles = await this.browser.findElements(xpath);
|
|
48
|
+
for (let i = 0; i < titles.length; i++) {
|
|
49
|
+
titles[i] = (await titles[i].getText(true)).trim() || `#${String(i).padStart(3, "0")}`;
|
|
50
|
+
}
|
|
51
|
+
// 处理表体
|
|
52
|
+
xpath = `(${this.getXpath()}${this._createBodyXapth()})[1]//tr[not (ancestor-or-self::*[contains(@style,'display: none')])]`;
|
|
53
|
+
let trs = await this.browser.findElements(xpath);
|
|
54
|
+
for (let i = 0; i < trs.length; i++) {
|
|
55
|
+
xpath = `(${this.getXpath()}${this._createBodyXapth()}//tr[not (ancestor-or-self::*[contains(@style,'display: none')])])[${i + 1}]/td`;
|
|
56
|
+
let tds = await this.browser.findElements(xpath);
|
|
57
|
+
let row = {};
|
|
58
|
+
for (let j = 0; j < tds.length; j++) {
|
|
59
|
+
let title = titles[j]
|
|
60
|
+
let text = (await tds[j].getText(true)).replaceAll("\n", " ");
|
|
61
|
+
row[title] = text;
|
|
62
|
+
}
|
|
63
|
+
ret.push(row);
|
|
64
|
+
}
|
|
65
|
+
return ret;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 获取块组件
|
|
71
|
+
* @param {Number} rowNumber 行号
|
|
72
|
+
* @param {Number} columnNumber 列号
|
|
73
|
+
* @returns 块组件
|
|
74
|
+
*/
|
|
75
|
+
blockComponent(rowNumber, columnNumber) {
|
|
76
|
+
let that = this;
|
|
77
|
+
class _BlockComponent extends require("./BlockComponent") {
|
|
78
|
+
_createRootXpath() {
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
_createXpath() {
|
|
82
|
+
if (columnNumber) {
|
|
83
|
+
return `(${that.getXpath()}${that._createBodyXapth()}//tr)[${rowNumber}]/td[${columnNumber}]`;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
return `(${that.getXpath()}${that._createBodyXapth()}//tr)[${rowNumber}]`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return new _BlockComponent(this.browser, null);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = TableComponent;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文本组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class TextComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 文本组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} text 文本
|
|
11
|
+
*/
|
|
12
|
+
constructor(browser, text) {
|
|
13
|
+
super(browser);
|
|
14
|
+
this.text = text;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_createXpath() {
|
|
18
|
+
return `//*[normalize-space(text())='${this.text}']`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = TextComponent;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
const BlockComponent = require("../component/BlockComponent");
|
|
2
|
+
const ButtonComponent = require("../component/ButtonComponent");
|
|
3
|
+
const CascaderComponent = require("../component/CascaderComponent");
|
|
4
|
+
const CheckboxComponent = require("../component/CheckboxComponent");
|
|
5
|
+
const DialogComponent = require("../component/DialogComponent");
|
|
6
|
+
const InputComponent = require("../component/InputComponent");
|
|
7
|
+
const LeftMenuComponent = require("../component/LeftMenuComponent");
|
|
8
|
+
const ListComponent = require("../component/ListComponent");
|
|
9
|
+
const MessageComponent = require("../component/MessageComponent");
|
|
10
|
+
const RadioComponent = require("../component/RadioComponent");
|
|
11
|
+
const SelectComponent = require("../component/SelectComponent");
|
|
12
|
+
const SwitchComponent = require("../component/SwitchComponent");
|
|
13
|
+
const TableComponent = require("../component/TableComponent");
|
|
14
|
+
const TextComponent = require("../component/TextComponent");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 页面类
|
|
18
|
+
*/
|
|
19
|
+
class Page extends require("@winning-test/autotest-webui").Page {
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 页面类
|
|
23
|
+
* @param {Browser} browser 浏览器
|
|
24
|
+
*/
|
|
25
|
+
constructor(browser) {
|
|
26
|
+
super(browser);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 获取块组件
|
|
31
|
+
* @param {String} xpath xpath
|
|
32
|
+
* @returns 块组件
|
|
33
|
+
*/
|
|
34
|
+
blockComponent(xpath) {
|
|
35
|
+
return new BlockComponent(this.browser, xpath);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 获取按钮组件
|
|
40
|
+
* @param {String} text 文本
|
|
41
|
+
* @returns 按钮组件
|
|
42
|
+
*/
|
|
43
|
+
buttonComponent(text) {
|
|
44
|
+
return new ButtonComponent(this.browser, text);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 获取级联选择器组件
|
|
49
|
+
* @param {String} placeholder 背景文字
|
|
50
|
+
* @param {String} label 标签
|
|
51
|
+
* @returns 级联选择器组件
|
|
52
|
+
*/
|
|
53
|
+
cascaderComponent(placeholder, label) {
|
|
54
|
+
return new CascaderComponent(this.browser, placeholder, label);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 获取复选框组件
|
|
59
|
+
* @param {String} label 标签
|
|
60
|
+
* @returns 复选框组件
|
|
61
|
+
*/
|
|
62
|
+
checkboxComponent(label) {
|
|
63
|
+
return new CheckboxComponent(this.browser, label);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 获取对话框组件
|
|
68
|
+
* @param {String} title 标题
|
|
69
|
+
* @returns 对话框组件
|
|
70
|
+
*/
|
|
71
|
+
dialogComponent(title) {
|
|
72
|
+
return new DialogComponent(this.browser, title);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 获取输入框组件
|
|
77
|
+
* @param {String} placeholder 背景文字
|
|
78
|
+
* @param {String} label 标签
|
|
79
|
+
* @returns 输入框组件
|
|
80
|
+
*/
|
|
81
|
+
inputComponent(placeholder, label) {
|
|
82
|
+
return new InputComponent(this.browser, placeholder, label);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 获取左侧菜单组件
|
|
87
|
+
* @returns 左侧菜单组件
|
|
88
|
+
*/
|
|
89
|
+
leftMenuComponent() {
|
|
90
|
+
return new LeftMenuComponent(this.browser);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 获取列表组件
|
|
95
|
+
* @returns 列表组件
|
|
96
|
+
*/
|
|
97
|
+
listComponent() {
|
|
98
|
+
return new ListComponent(this.browser);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 获取消息组件
|
|
103
|
+
* @param {Stirng} text 文本
|
|
104
|
+
* @returns 消息组件
|
|
105
|
+
*/
|
|
106
|
+
messageComponent(text) {
|
|
107
|
+
return new MessageComponent(this.browser, text);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 获取选择器组件
|
|
112
|
+
* @param {String} placeholder 背景文字
|
|
113
|
+
* @param {String} label 标签
|
|
114
|
+
* @returns 选择器组件
|
|
115
|
+
*/
|
|
116
|
+
selectComponent(placeholder, label) {
|
|
117
|
+
return new SelectComponent(this.browser, placeholder, label);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 获取开关组件
|
|
122
|
+
* @param {String} label 标签
|
|
123
|
+
* @returns 开关组件
|
|
124
|
+
*/
|
|
125
|
+
switchComponent(label) {
|
|
126
|
+
return new SwitchComponent(this.browser, label);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 获取表格组件
|
|
131
|
+
* @returns 表格组件
|
|
132
|
+
*/
|
|
133
|
+
tableComponent() {
|
|
134
|
+
return new TableComponent(this.browser);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 获取文本组件
|
|
139
|
+
* @param {String} text 文本
|
|
140
|
+
* @returns 文本组件
|
|
141
|
+
*/
|
|
142
|
+
textComponent(text) {
|
|
143
|
+
return new TextComponent(this.browser, text);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 获取单选框组件
|
|
148
|
+
* @param {String} label 标签
|
|
149
|
+
* @returns 单选框组件
|
|
150
|
+
*/
|
|
151
|
+
radioComponent(label) {
|
|
152
|
+
return new RadioComponent(this.browser, label)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 等待加载
|
|
157
|
+
*/
|
|
158
|
+
async loading() {
|
|
159
|
+
try {
|
|
160
|
+
const xpath = "//*[contains(text(),'加载中') or @class='el-loading-mask' or @class='el-icon-loading'][not (ancestor-or-self::*[contains(@style,'display: none')])]";
|
|
161
|
+
if (await this.browser.isDisplayed(xpath, 1000)) {
|
|
162
|
+
await this.browser.waitUntilElementBeNotVisible(xpath);
|
|
163
|
+
}
|
|
164
|
+
} catch (error) {
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 关闭所有对话框
|
|
171
|
+
*/
|
|
172
|
+
async closeAllDialog() {
|
|
173
|
+
let count = 5;
|
|
174
|
+
while ((await this.dialogComponent().isDisplayed(500)) && count > 0) {
|
|
175
|
+
try {
|
|
176
|
+
await this.dialogComponent().blockComponent("//*[contains(@class,'el-dialog__close')]").click();
|
|
177
|
+
await this.dialogComponent().waitUntilBeNotVisible();
|
|
178
|
+
} catch (error) {
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
count--;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
module.exports = Page;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { Browser, Key } = require("@winning-test/autotest-webui");
|
|
2
|
+
const config = require("./component.test.json");
|
|
3
|
+
const Page = require("../page/Page")
|
|
4
|
+
const browser = new Browser();
|
|
5
|
+
|
|
6
|
+
beforeAll(async () => {
|
|
7
|
+
await browser.maximize();
|
|
8
|
+
await browser.get(config.url);
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test("input/button/text", async () => {
|
|
12
|
+
const page = new Page(browser);
|
|
13
|
+
await page.inputComponent("在此键入您的工号/账号").input(config.user.doctor.用户名);
|
|
14
|
+
await page.inputComponent("请输入您的密码").input(config.user.doctor.密码);
|
|
15
|
+
await page.selectComponent("在此选择院区").select(config.user.doctor.院区);
|
|
16
|
+
await page.selectComponent("请选择系统").select(config.user.doctor.系统)
|
|
17
|
+
await page.buttonComponent("登录").click();
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test("table", async () => {
|
|
21
|
+
const page = new Page(browser);
|
|
22
|
+
const tableData = await page.blockComponent("//*[@class='table-box']").tableComponent().getTableData();
|
|
23
|
+
console.log(tableData);
|
|
24
|
+
await page.blockComponent("//*[@class='table-box']").tableComponent().blockComponent(2).doubleClick();
|
|
25
|
+
})
|
|
26
|
+
|
package/package.json
CHANGED
|
@@ -234,22 +234,23 @@ class Page extends require("@winning-test/autotest-webui").Page {
|
|
|
234
234
|
*/
|
|
235
235
|
async select(firstItem, secondItem, thirdItem) {
|
|
236
236
|
await that.switchToDefultFrame();
|
|
237
|
-
let xpath = "//*[@class='more-menu
|
|
237
|
+
let xpath = "//*[@class='more-menu']"
|
|
238
238
|
await this.browser.waitUntilElementBeVisible(xpath)
|
|
239
239
|
xpath = "//*[contains(text(),'...')]";
|
|
240
240
|
await that.blockComponent(xpath).click();
|
|
241
|
-
xpath = `//*[@class='
|
|
241
|
+
xpath = `//*[@class='app-list']//*[contains(text(),'${firstItem}')]`;
|
|
242
242
|
await this.browser.waitUntilElementBeVisible(xpath);
|
|
243
243
|
await that.blockComponent(xpath).click();
|
|
244
244
|
await that.loading();
|
|
245
245
|
if (thirdItem) {
|
|
246
|
-
xpath = `//*[@class='
|
|
246
|
+
xpath = `//*[@class='menu-third-list-container']//span[contains(text(),'${thirdItem}')]`;
|
|
247
247
|
await this.browser.waitUntilElementBeVisible(xpath);
|
|
248
248
|
await that.blockComponent(xpath).click();
|
|
249
249
|
await that.loading();
|
|
250
250
|
}
|
|
251
251
|
if (!thirdItem) {
|
|
252
|
-
xpath = `//*[@class='
|
|
252
|
+
xpath = `//*[@class='menu-detail-list']//span[contains(text(),'${secondItem}')]`;
|
|
253
|
+
await this.browser.waitUntilElementBeVisible(xpath);
|
|
253
254
|
await that.blockComponent(xpath).click();
|
|
254
255
|
await that.loading();
|
|
255
256
|
}
|