@winning-test/component 0.0.78 → 0.0.80
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/lis60/component/BlockComponent.js +5 -65
- package/lis60/component/MessageComponent.js +32 -2
- package/lis60/page/Page.js +4 -42
- package/lis60/test/component.test.js +12 -10
- package/package.json +2 -2
- package/rpes5.6/component/BlockComponent.js +234 -0
- package/rpes5.6/component/ButtonComponent.js +23 -0
- package/rpes5.6/component/CheckboxComponent.js +53 -0
- package/rpes5.6/component/Component.js +77 -0
- package/rpes5.6/component/DialogComponent.js +23 -0
- package/rpes5.6/component/InputComponent.js +31 -0
- package/rpes5.6/component/ListComponent.js +53 -0
- package/rpes5.6/component/MessageComponent.js +23 -0
- package/{lis60 → rpes5.6}/component/RadioComponent.js +4 -1
- package/rpes5.6/component/SelectComponent.js +76 -0
- package/{lis60 → rpes5.6}/component/SwitchComponent.js +7 -5
- package/rpes5.6/component/TableComponent.js +104 -0
- package/rpes5.6/component/TextComponent.js +23 -0
- package/rpes5.6/component/TextareaComponent.js +27 -0
- package/rpes5.6/component/TopMenuComponent.js +33 -0
- package/rpes5.6/page/Page.js +173 -0
- package/rpes5.6/test/component.test.js +114 -0
- package/rpes5.6/test/component.test.json +13 -0
- package/rpes5.6/test/func.js +87 -0
- package/lis60/component/CascaderComponent.js +0 -51
|
@@ -48,22 +48,6 @@ class BlockComponent extends require("./Component") {
|
|
|
48
48
|
return new ButtonComponent(this.browser, text);
|
|
49
49
|
}
|
|
50
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
51
|
/**
|
|
68
52
|
* 获取复选框组件
|
|
69
53
|
* @param {String} label 标签
|
|
@@ -111,31 +95,17 @@ class BlockComponent extends require("./Component") {
|
|
|
111
95
|
}
|
|
112
96
|
|
|
113
97
|
/**
|
|
114
|
-
*
|
|
115
|
-
* @returns
|
|
116
|
-
*/
|
|
117
|
-
leftMenuComponent() {
|
|
118
|
-
let that = this;
|
|
119
|
-
class LeftMenuComponent extends require("./MenuComponent") {
|
|
120
|
-
_createRootXpath() {
|
|
121
|
-
return that.getXpath();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return new LeftMenuComponent(this.browser);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 获取列表组件
|
|
129
|
-
* @returns 列表组件
|
|
98
|
+
* 获取菜单组件
|
|
99
|
+
* @returns 菜单组件
|
|
130
100
|
*/
|
|
131
|
-
|
|
101
|
+
menuComponent() {
|
|
132
102
|
let that = this;
|
|
133
|
-
class
|
|
103
|
+
class MenuComponent extends require("./MenuComponent") {
|
|
134
104
|
_createRootXpath() {
|
|
135
105
|
return that.getXpath();
|
|
136
106
|
}
|
|
137
107
|
}
|
|
138
|
-
return new
|
|
108
|
+
return new MenuComponent(this.browser);
|
|
139
109
|
}
|
|
140
110
|
|
|
141
111
|
/**
|
|
@@ -153,21 +123,6 @@ class BlockComponent extends require("./Component") {
|
|
|
153
123
|
return new MessageComponent(this.browser, text);
|
|
154
124
|
}
|
|
155
125
|
|
|
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
126
|
/**
|
|
172
127
|
* 获取选择器组件
|
|
173
128
|
* @param {String} label 标签
|
|
@@ -184,21 +139,6 @@ class BlockComponent extends require("./Component") {
|
|
|
184
139
|
return new SelectComponent(this.browser, label, placeholder);
|
|
185
140
|
}
|
|
186
141
|
|
|
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
142
|
/**
|
|
203
143
|
* 获取表格组件
|
|
204
144
|
* @returns 表格组件
|
|
@@ -8,14 +8,16 @@ class MessageComponent extends require("./Component") {
|
|
|
8
8
|
* 消息组件
|
|
9
9
|
* @param {Browser} browser 浏览器
|
|
10
10
|
* @param {String} text 消息内容
|
|
11
|
+
* @param {Boolean} iframe 是否在iframe内
|
|
11
12
|
*/
|
|
12
|
-
constructor(browser, text) {
|
|
13
|
+
constructor(browser, text, iframe = false) {
|
|
13
14
|
super(browser)
|
|
14
15
|
this.text = text;
|
|
16
|
+
this.iframe = iframe;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
_createXpath() {
|
|
18
|
-
return `//*[contains(normalize-space(text()),'${this.text}')]/ancestor-or-self::*[@
|
|
20
|
+
return `//*[contains(normalize-space(text()),'${this.text}')]/ancestor-or-self::*[contains(@class,'el-message')]`;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -23,8 +25,15 @@ class MessageComponent extends require("./Component") {
|
|
|
23
25
|
* @returns 消息内容
|
|
24
26
|
*/
|
|
25
27
|
async getText() {
|
|
28
|
+
if (!this.iframe) {
|
|
29
|
+
await this.browser.switchToFrame();
|
|
30
|
+
}
|
|
26
31
|
let xpath = this.getXpath();
|
|
27
32
|
let text = await (await this.browser.findElement(xpath)).getText();
|
|
33
|
+
if (!this.iframe) {
|
|
34
|
+
xpath = "//iframe[not (@style='display: none;')]";
|
|
35
|
+
await this.browser.switchToFrame(xpath)
|
|
36
|
+
}
|
|
28
37
|
return text;
|
|
29
38
|
}
|
|
30
39
|
|
|
@@ -32,24 +41,45 @@ class MessageComponent extends require("./Component") {
|
|
|
32
41
|
* 等待出现
|
|
33
42
|
*/
|
|
34
43
|
async waitUntilBeVisible() {
|
|
44
|
+
if (!this.iframe) {
|
|
45
|
+
await this.browser.switchToFrame();
|
|
46
|
+
}
|
|
35
47
|
let xpath = this.getXpath();
|
|
36
48
|
await this.browser.waitUntilElementBeVisible(xpath);
|
|
49
|
+
if (!this.iframe) {
|
|
50
|
+
xpath = "//iframe[not (@style='display: none;')]";
|
|
51
|
+
await this.browser.switchToFrame(xpath);
|
|
52
|
+
}
|
|
37
53
|
}
|
|
38
54
|
|
|
39
55
|
/**
|
|
40
56
|
* 等待消失
|
|
41
57
|
*/
|
|
42
58
|
async waitUntilBeNotVisible() {
|
|
59
|
+
if (!this.iframe) {
|
|
60
|
+
await this.browser.switchToFrame();
|
|
61
|
+
}
|
|
43
62
|
let xpath = this.getXpath();
|
|
44
63
|
await this.browser.waitUntilElementBeNotVisible(xpath);
|
|
64
|
+
if (!this.iframe) {
|
|
65
|
+
xpath = "//iframe[not (@style='display: none;')]";
|
|
66
|
+
await this.browser.switchToFrame(xpath);
|
|
67
|
+
}
|
|
45
68
|
}
|
|
46
69
|
|
|
47
70
|
/**
|
|
48
71
|
* 关闭
|
|
49
72
|
*/
|
|
50
73
|
async close() {
|
|
74
|
+
if (!this.iframe) {
|
|
75
|
+
await this.browser.switchToFrame();
|
|
76
|
+
}
|
|
51
77
|
let xpath = `${this.getXpath()}//i[contains(@class,'el-message__closeBtn')]`;
|
|
52
78
|
await (await this.browser.findElement(xpath)).click();
|
|
79
|
+
if (!this.iframe) {
|
|
80
|
+
xpath = "//iframe[not (@style='display: none;')]";
|
|
81
|
+
await this.browser.switchToFrame(xpath);
|
|
82
|
+
}
|
|
53
83
|
}
|
|
54
84
|
|
|
55
85
|
}
|
package/lis60/page/Page.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
const BlockComponent = require("../component/BlockComponent");
|
|
2
2
|
const ButtonComponent = require("../component/ButtonComponent");
|
|
3
|
-
const CascaderComponent = require("../component/CascaderComponent");
|
|
4
3
|
const CheckboxComponent = require("../component/CheckboxComponent");
|
|
5
4
|
const DialogComponent = require("../component/DialogComponent");
|
|
6
5
|
const InputComponent = require("../component/InputComponent");
|
|
7
|
-
const ListComponent = require("../component/ListComponent");
|
|
8
6
|
const MenuComponent = require("../component/MenuComponent");
|
|
9
7
|
const MessageComponent = require("../component/MessageComponent");
|
|
10
|
-
const RadioComponent = require("../component/RadioComponent");
|
|
11
8
|
const SelectComponent = require("../component/SelectComponent");
|
|
12
|
-
const SwitchComponent = require("../component/SwitchComponent");
|
|
13
9
|
const TableComponent = require("../component/TableComponent");
|
|
14
10
|
const TextComponent = require("../component/TextComponent");
|
|
15
11
|
|
|
@@ -44,16 +40,6 @@ class Page extends require("@winning-test/autotest-webui").Page {
|
|
|
44
40
|
return new ButtonComponent(this.browser, text);
|
|
45
41
|
}
|
|
46
42
|
|
|
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
43
|
/**
|
|
58
44
|
* 获取复选框组件
|
|
59
45
|
* @param {String} label 标签
|
|
@@ -82,17 +68,10 @@ class Page extends require("@winning-test/autotest-webui").Page {
|
|
|
82
68
|
return new InputComponent(this.browser, label, placeholder);
|
|
83
69
|
}
|
|
84
70
|
|
|
85
|
-
/**
|
|
86
|
-
* 获取列表组件
|
|
87
|
-
* @returns 列表组件
|
|
88
|
-
*/
|
|
89
|
-
listComponent() {
|
|
90
|
-
return new ListComponent(this.browser);
|
|
91
|
-
}
|
|
92
71
|
|
|
93
72
|
/**
|
|
94
73
|
* 获取菜单组件
|
|
95
|
-
* @returns
|
|
74
|
+
* @returns 菜单组件
|
|
96
75
|
*/
|
|
97
76
|
menuComponent() {
|
|
98
77
|
return new MenuComponent(this.browser);
|
|
@@ -101,10 +80,11 @@ class Page extends require("@winning-test/autotest-webui").Page {
|
|
|
101
80
|
/**
|
|
102
81
|
* 获取消息组件
|
|
103
82
|
* @param {Stirng} text 文本
|
|
83
|
+
* @param {Boolean} iframe 是否在iframe内
|
|
104
84
|
* @returns 消息组件
|
|
105
85
|
*/
|
|
106
|
-
messageComponent(text) {
|
|
107
|
-
return new MessageComponent(this.browser, text);
|
|
86
|
+
messageComponent(text, iframe = false) {
|
|
87
|
+
return new MessageComponent(this.browser, text, iframe);
|
|
108
88
|
}
|
|
109
89
|
|
|
110
90
|
/**
|
|
@@ -117,15 +97,6 @@ class Page extends require("@winning-test/autotest-webui").Page {
|
|
|
117
97
|
return new SelectComponent(this.browser, label, placeholder);
|
|
118
98
|
}
|
|
119
99
|
|
|
120
|
-
/**
|
|
121
|
-
* 获取开关组件
|
|
122
|
-
* @param {String} label 标签
|
|
123
|
-
* @returns 开关组件
|
|
124
|
-
*/
|
|
125
|
-
switchComponent(label) {
|
|
126
|
-
return new SwitchComponent(this.browser, label);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
100
|
/**
|
|
130
101
|
* 获取表格组件
|
|
131
102
|
* @returns 表格组件
|
|
@@ -143,15 +114,6 @@ class Page extends require("@winning-test/autotest-webui").Page {
|
|
|
143
114
|
return new TextComponent(this.browser, text);
|
|
144
115
|
}
|
|
145
116
|
|
|
146
|
-
/**
|
|
147
|
-
* 获取单选框组件
|
|
148
|
-
* @param {String} label 标签
|
|
149
|
-
* @returns 单选框组件
|
|
150
|
-
*/
|
|
151
|
-
radioComponent(label) {
|
|
152
|
-
return new RadioComponent(this.browser, label)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
117
|
/**
|
|
156
118
|
* 等待加载
|
|
157
119
|
*/
|
|
@@ -13,11 +13,11 @@ test.skip("001", async () => {
|
|
|
13
13
|
await page.inputComponent(null, "请输入登录账户").input("yj");
|
|
14
14
|
await page.inputComponent(null, "请输入登录密码").input("1");
|
|
15
15
|
await page.buttonComponent().click();
|
|
16
|
-
await page.menuComponent().select("标本采集","门诊采集");
|
|
17
|
-
await page.menuComponent().select("标本采集","标本查询");
|
|
18
|
-
await page.inputComponent("扫描条码").input("1111",Key.ENTER);
|
|
16
|
+
await page.menuComponent().select("标本采集", "门诊采集");
|
|
17
|
+
await page.menuComponent().select("标本采集", "标本查询");
|
|
18
|
+
await page.inputComponent("扫描条码").input("1111", Key.ENTER);
|
|
19
19
|
await page.inputComponent("发票号").input("22222");
|
|
20
|
-
await page.checkboxComponent("病人类型").select("门诊","体检","其他");
|
|
20
|
+
await page.checkboxComponent("病人类型").select("门诊", "体检", "其他");
|
|
21
21
|
await page.checkboxComponent("病人类型").unselect("住院");
|
|
22
22
|
await page.selectComponent("标本状态").select("已绑定");
|
|
23
23
|
})
|
|
@@ -27,14 +27,14 @@ test.skip("002", async () => {
|
|
|
27
27
|
await page.inputComponent(null, "请输入登录账户").input("yj");
|
|
28
28
|
await page.inputComponent(null, "请输入登录密码").input("1");
|
|
29
29
|
await page.buttonComponent().click();
|
|
30
|
-
await page.menuComponent().select("标本采集","门诊采集");
|
|
31
|
-
await page.inputComponent(null,"读卡用F8或←").input("000002319",Key.ENTER);
|
|
30
|
+
await page.menuComponent().select("标本采集", "门诊采集");
|
|
31
|
+
await page.inputComponent(null, "读卡用F8或←").input("000002319", Key.ENTER);
|
|
32
32
|
await page.loading();
|
|
33
33
|
await page.loading();
|
|
34
34
|
await page.loading();
|
|
35
35
|
await page.buttonComponent("打印条码").click();
|
|
36
36
|
await page.loading();
|
|
37
|
-
await page.inputComponent(null,"读卡用F8或←").input("000002319",Key.ENTER);
|
|
37
|
+
await page.inputComponent(null, "读卡用F8或←").input("000002319", Key.ENTER);
|
|
38
38
|
await page.blockComponent("//*[@class='mzcj-list-history-ul-bottom']").moveMouseTo();
|
|
39
39
|
await page.textComponent("取消绑定").click();
|
|
40
40
|
await page.dialogComponent("取消绑定原因").waitUntilBeVisible();
|
|
@@ -49,21 +49,23 @@ test("003", async () => {
|
|
|
49
49
|
await page.inputComponent(null, "请输入登录账户").input("yj");
|
|
50
50
|
await page.inputComponent(null, "请输入登录密码").input("1");
|
|
51
51
|
await page.buttonComponent().click();
|
|
52
|
-
await page.menuComponent().select("标本采集","标本查询");
|
|
52
|
+
await page.menuComponent().select("标本采集", "标本查询");
|
|
53
53
|
await page.browser.sleep(1000);
|
|
54
|
-
await page.inputComponent("
|
|
54
|
+
await page.inputComponent("磁卡号").input("2023100901");
|
|
55
55
|
await page.checkboxComponent("病人类型").select("门诊");
|
|
56
56
|
await page.buttonComponent("查询标本列表").click();
|
|
57
57
|
let bbtm = await page.blockComponent("//*[@class='query-table-bottom']//input").getValue();
|
|
58
|
-
await page.menuComponent().select("日常操作","标本签收");
|
|
58
|
+
await page.menuComponent().select("日常操作", "标本签收");
|
|
59
59
|
await page.inputComponent("扫描条码").input(bbtm, Key.ENTER);
|
|
60
60
|
let td = await page.tableComponent().getTableData();
|
|
61
61
|
console.log(td);
|
|
62
|
+
await page.messageComponent("标本签收成功").waitUntilBeVisible();
|
|
62
63
|
await page.tableComponent().blockComponent(1).textComponent("撤销").click();
|
|
63
64
|
await page.dialogComponent("撤销签收").waitUntilBeVisible();
|
|
64
65
|
await page.dialogComponent("撤销签收").selectComponent("受话人").select("1");
|
|
65
66
|
await page.dialogComponent("撤销签收").inputComponent("原因").input("1");
|
|
66
67
|
await page.dialogComponent("撤销签收").buttonComponent("确 定").click();
|
|
67
68
|
await page.dialogComponent("撤销签收").waitUntilBeNotVisible();
|
|
69
|
+
await page.messageComponent("成功", true).waitUntilBeVisible();
|
|
68
70
|
})
|
|
69
71
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@winning-test/component",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "",
|
|
6
6
|
"scripts": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/jest": "^29.5.3",
|
|
17
17
|
"@winning-test/autotest-webui": "^0.1.51",
|
|
18
|
-
"chromedriver": "^
|
|
18
|
+
"chromedriver": "^118.0.0",
|
|
19
19
|
"jest": "^29.6.2"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -0,0 +1,234 @@
|
|
|
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} id id
|
|
24
|
+
* @param {String} xpath xpath
|
|
25
|
+
* @returns 块组件
|
|
26
|
+
*/
|
|
27
|
+
blockComponent(id, xpath) {
|
|
28
|
+
let that = this;
|
|
29
|
+
class _BlockComponent extends BlockComponent {
|
|
30
|
+
_createRootXpath() {
|
|
31
|
+
return that.getXpath();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return new _BlockComponent(this.browser, id, xpath);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 获取按钮组件
|
|
39
|
+
* @param {String} text 文本
|
|
40
|
+
* @returns 按钮组件
|
|
41
|
+
*/
|
|
42
|
+
buttonComponent(text) {
|
|
43
|
+
let that = this;
|
|
44
|
+
class ButtonComponent extends require("./ButtonComponent") {
|
|
45
|
+
_createRootXpath() {
|
|
46
|
+
return that.getXpath();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return new ButtonComponent(this.browser, text);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 获取复选框组件
|
|
54
|
+
* @param {String} label 标签
|
|
55
|
+
* @returns 复选框组件
|
|
56
|
+
*/
|
|
57
|
+
checkboxComponent(label) {
|
|
58
|
+
let that = this;
|
|
59
|
+
class CheckboxComponent extends require("./CheckboxComponent") {
|
|
60
|
+
_createRootXpath() {
|
|
61
|
+
return that.getXpath();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return new CheckboxComponent(this.browser, label);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 获取对话框组件
|
|
69
|
+
* @param {String} title 标题
|
|
70
|
+
* @returns 对话框组件
|
|
71
|
+
*/
|
|
72
|
+
dialogComponent(title) {
|
|
73
|
+
let that = this;
|
|
74
|
+
class DialogComponent extends require("./DialogComponent") {
|
|
75
|
+
_createRootXpath() {
|
|
76
|
+
return that.getXpath();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return new DialogComponent(this.browser, title);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 获取输入框组件
|
|
84
|
+
* @param {String} placeholder 背景文字
|
|
85
|
+
* @param {String} label 标签
|
|
86
|
+
* @returns 输入框组件
|
|
87
|
+
*/
|
|
88
|
+
inputComponent(placeholder, label) {
|
|
89
|
+
let that = this;
|
|
90
|
+
class InputComponent extends require("./InputComponent") {
|
|
91
|
+
_createRootXpath() {
|
|
92
|
+
return that.getXpath();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return new InputComponent(this.browser, placeholder, label);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 获取列表组件
|
|
101
|
+
* @returns 列表组件
|
|
102
|
+
*/
|
|
103
|
+
listComponent() {
|
|
104
|
+
let that = this;
|
|
105
|
+
class ListComponent extends require("./ListComponent") {
|
|
106
|
+
_createRootXpath() {
|
|
107
|
+
return that.getXpath();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return new ListComponent(this.browser);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 获取消息组件
|
|
115
|
+
* @param {Stirng} text 文本
|
|
116
|
+
* @returns 消息组件
|
|
117
|
+
*/
|
|
118
|
+
messageComponent(text) {
|
|
119
|
+
let that = this;
|
|
120
|
+
class MessageComponent extends require("./MessageComponent") {
|
|
121
|
+
_createRootXpath() {
|
|
122
|
+
return that.getXpath();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return new MessageComponent(this.browser, text);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 获取单选组件
|
|
130
|
+
* @param {Stirng} label 标签
|
|
131
|
+
* @returns 单选组件
|
|
132
|
+
*/
|
|
133
|
+
radioComponent(label) {
|
|
134
|
+
let that = this;
|
|
135
|
+
class RadioComponent extends require("./RadioComponent") {
|
|
136
|
+
_createRootXpath() {
|
|
137
|
+
return that.getXpath();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return new RadioComponent(this.browser, label);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 获取选择器组件
|
|
145
|
+
* @param {String} placeholder 背景文字
|
|
146
|
+
* @param {String} label 标签
|
|
147
|
+
* @returns 选择器组件
|
|
148
|
+
*/
|
|
149
|
+
selectComponent(placeholder, label) {
|
|
150
|
+
let that = this;
|
|
151
|
+
class SelectComponent extends require("./SelectComponent") {
|
|
152
|
+
_createRootXpath() {
|
|
153
|
+
return that.getXpath();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return new SelectComponent(this.browser, placeholder, label);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 获取开关组件
|
|
161
|
+
* @param {String} label 标签
|
|
162
|
+
* @returns 开关组件
|
|
163
|
+
*/
|
|
164
|
+
switchComponent(label) {
|
|
165
|
+
let that = this;
|
|
166
|
+
class SwitchComponent extends require("./SwitchComponent") {
|
|
167
|
+
_createRootXpath() {
|
|
168
|
+
return that.getXpath();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return new SwitchComponent(this.browser, label);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 获取表格组件
|
|
176
|
+
* @returns 表格组件
|
|
177
|
+
*/
|
|
178
|
+
tableComponent() {
|
|
179
|
+
let that = this;
|
|
180
|
+
class TableComponent extends require("./TableComponent") {
|
|
181
|
+
_createRootXpath() {
|
|
182
|
+
return that.getXpath();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return new TableComponent(this.browser);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 获取多行文本输入组件
|
|
190
|
+
* @param {String} textarea 多行文本输入
|
|
191
|
+
* @returns 多行文本输入组件
|
|
192
|
+
*/
|
|
193
|
+
textareaComponent(placeholder, label) {
|
|
194
|
+
let that = this;
|
|
195
|
+
class TextareaComponent extends require("./TextareaComponent") {
|
|
196
|
+
_createRootXpath() {
|
|
197
|
+
return that.getXpath();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return new TextareaComponent(this.browser, placeholder, label);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* 获取文本组件
|
|
205
|
+
* @param {String} text 文本
|
|
206
|
+
* @returns 文本组件
|
|
207
|
+
*/
|
|
208
|
+
textComponent(text) {
|
|
209
|
+
let that = this;
|
|
210
|
+
class TextComponent extends require("./TextComponent") {
|
|
211
|
+
_createRootXpath() {
|
|
212
|
+
return that.getXpath();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return new TextComponent(this.browser, text);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* 获取顶部菜单组件
|
|
220
|
+
* @returns 顶部菜单组件
|
|
221
|
+
*/
|
|
222
|
+
topMenuComponent() {
|
|
223
|
+
let that = this;
|
|
224
|
+
class TopMenuComponent extends require("./TopMenuComponent") {
|
|
225
|
+
_createRootXpath() {
|
|
226
|
+
return that.getXpath();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return new TopMenuComponent(this.browser);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
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,53 @@
|
|
|
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}']/..//input[@type='checkbox']`;
|
|
20
|
+
}
|
|
21
|
+
return "//input[@type='checkbox']";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 选择
|
|
26
|
+
*/
|
|
27
|
+
async select() {
|
|
28
|
+
if (!(await (await this.browser.findElement(this.getXpath())).isSelected())) {
|
|
29
|
+
await (await this.browser.findElement(this.getXpath())).click();
|
|
30
|
+
await this.browser.sleep(CheckboxComponent.delayTime);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 取消选择
|
|
36
|
+
*/
|
|
37
|
+
async unselect() {
|
|
38
|
+
if (await (await this.browser.findElement(this.getXpath())).isSelected()) {
|
|
39
|
+
await (await this.browser.findElement(this.getXpath())).click();
|
|
40
|
+
await this.browser.sleep(CheckboxComponent.delayTime);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 选择状态
|
|
46
|
+
*/
|
|
47
|
+
async isSelected() {
|
|
48
|
+
return await (await this.browser.findElement(this.getXpath())).isSelected();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = CheckboxComponent;
|