@winning-test/component 0.0.101 → 0.0.103
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/TechBookCenter/component/BlockComponent.js +173 -0
- package/TechBookCenter/component/ButtonComponent.js +26 -0
- package/TechBookCenter/component/CheckboxComponent.js +46 -0
- package/TechBookCenter/component/Component.js +109 -0
- package/TechBookCenter/component/DialogComponent.js +26 -0
- package/TechBookCenter/component/InputComponent.js +31 -0
- package/TechBookCenter/component/MenuComponent.js +36 -0
- package/TechBookCenter/component/MessageComponent.js +87 -0
- package/TechBookCenter/component/RadioComponent.js +41 -0
- package/TechBookCenter/component/SelectComponent.js +43 -0
- package/TechBookCenter/component/TableComponent.js +113 -0
- package/TechBookCenter/component/TextComponent.js +23 -0
- package/TechBookCenter/page/Page.js +172 -0
- package/package.json +1 -1
- package/rfds5.6/component/BlockComponent.js +248 -0
- package/rfds5.6/component/ButtonComponent.js +23 -0
- package/rfds5.6/component/CanvasComponent.js +36 -0
- package/rfds5.6/component/CheckboxComponent.js +53 -0
- package/rfds5.6/component/Component.js +93 -0
- package/rfds5.6/component/DialogComponent.js +23 -0
- package/rfds5.6/component/InputComponent.js +31 -0
- package/rfds5.6/component/ListComponent.js +53 -0
- package/rfds5.6/component/ListCompositeComponent.js +93 -0
- package/rfds5.6/component/MessageComponent.js +23 -0
- package/rfds5.6/component/RadioComponent.js +44 -0
- package/rfds5.6/component/SelectComponent.js +77 -0
- package/rfds5.6/component/SelectCompositeComponent.js +47 -0
- package/rfds5.6/component/SwitchComponent.js +50 -0
- package/rfds5.6/component/TableComponent.js +113 -0
- package/rfds5.6/component/TextComponent.js +23 -0
- package/rfds5.6/component/TextareaComponent.js +27 -0
- package/rfds5.6/page/Page.js +238 -0
- package/rfds5.6/test/component.test.js +64 -0
- package/rfds5.6/test/component.test.json +13 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 多行输入框组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class TextareaComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 多行输入框组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} placeholder 背景文字
|
|
11
|
+
* @param {String} label 标签
|
|
12
|
+
*/
|
|
13
|
+
constructor(browser, label) {
|
|
14
|
+
super(browser);
|
|
15
|
+
this.label = label;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_createXpath() {
|
|
19
|
+
if (this.label) {
|
|
20
|
+
return `//*[normalize-space(text())='${this.label}']/ancestor-or-self::label/..//textarea`;
|
|
21
|
+
}
|
|
22
|
+
return "//textarea"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = TextareaComponent;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
const BlockComponent = require("../component/BlockComponent");
|
|
2
|
+
const ButtonComponent = require("../component/ButtonComponent");
|
|
3
|
+
const CheckboxComponent = require("../component/CheckboxComponent");
|
|
4
|
+
const CanvasComponent = require("../component/CanvasComponent");
|
|
5
|
+
const DialogComponent = require("../component/DialogComponent");
|
|
6
|
+
const InputComponent = require("../component/InputComponent");
|
|
7
|
+
const ListComponent = require("../component/ListComponent");
|
|
8
|
+
const ListCompositeComponent = require("../component/ListCompositeComponent");
|
|
9
|
+
const MessageComponent = require("../component/MessageComponent");
|
|
10
|
+
const RadioComponent = require("../component/RadioComponent");
|
|
11
|
+
const SelectComponent = require("../component/SelectComponent");
|
|
12
|
+
const SelectCompositeComponent = require("../component/SelectCompositeComponent");
|
|
13
|
+
const SwitchComponent = require("../component/SwitchComponent");
|
|
14
|
+
const TableComponent = require("../component/TableComponent");
|
|
15
|
+
const TextareaComponent = require("../component/TextareaComponent");
|
|
16
|
+
const TextComponent = require("../component/TextComponent");
|
|
17
|
+
/**
|
|
18
|
+
* 页面类
|
|
19
|
+
*/
|
|
20
|
+
class Page extends require("@winning-test/autotest-webui").Page {
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 页面类
|
|
24
|
+
* @param {Browser} browser 浏览器
|
|
25
|
+
*/
|
|
26
|
+
constructor(browser) {
|
|
27
|
+
super(browser);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 获取块组件
|
|
32
|
+
* @param {String} xpath xpath
|
|
33
|
+
* @returns 块组件
|
|
34
|
+
*/
|
|
35
|
+
blockComponent(xpath) {
|
|
36
|
+
return new BlockComponent(this.browser, xpath);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 获取按钮组件
|
|
41
|
+
* @param {String} text 文本
|
|
42
|
+
* @returns 按钮组件
|
|
43
|
+
*/
|
|
44
|
+
buttonComponent(text) {
|
|
45
|
+
return new ButtonComponent(this.browser, text);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 获取复选框组件
|
|
50
|
+
* @param {String} label 标签
|
|
51
|
+
* @returns 复选框组件
|
|
52
|
+
*/
|
|
53
|
+
checkboxComponent(label) {
|
|
54
|
+
return new CheckboxComponent(this.browser, label);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 获取画图板组件
|
|
59
|
+
* @returns 画图板组件
|
|
60
|
+
*/
|
|
61
|
+
canvasComponent() {
|
|
62
|
+
return new CanvasComponent(this.browser);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 获取对话框组件
|
|
67
|
+
* @param {String} title 标题
|
|
68
|
+
* @returns 对话框组件
|
|
69
|
+
*/
|
|
70
|
+
dialogComponent(title) {
|
|
71
|
+
return new DialogComponent(this.browser, title);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 获取输入框组件
|
|
76
|
+
* @param {String} placeholder 背景文字
|
|
77
|
+
* @param {String} label 标签
|
|
78
|
+
* @returns 输入框组件
|
|
79
|
+
*/
|
|
80
|
+
inputComponent(placeholder, label) {
|
|
81
|
+
return new InputComponent(this.browser, placeholder, label);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 获取列表组件
|
|
87
|
+
* @returns 列表组件
|
|
88
|
+
*/
|
|
89
|
+
listCompositeComponent() {
|
|
90
|
+
return new ListCompositeComponent(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} label 标签
|
|
113
|
+
* @returns 单选组件
|
|
114
|
+
*/
|
|
115
|
+
radioComponent(label) {
|
|
116
|
+
return new RadioComponent(this.browser, label);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 获取选择器组件
|
|
121
|
+
* @param {String} placeholder 背景文字
|
|
122
|
+
* @param {String} label 标签
|
|
123
|
+
* @param {String} forceMulti 多选标志
|
|
124
|
+
* @returns 选择器组件
|
|
125
|
+
*/
|
|
126
|
+
selectComponent(placeholder, label, forceMulti) {
|
|
127
|
+
return new SelectComponent(this.browser, placeholder, label, forceMulti);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 获取复合选择器组件
|
|
132
|
+
* @param {String} placeholder 背景文字
|
|
133
|
+
* @param {String} label 标签
|
|
134
|
+
* @param {String} forceMulti 多选标志
|
|
135
|
+
* @returns 选择器组件
|
|
136
|
+
*/
|
|
137
|
+
selectCompositeComponent(placeholder, label, forceMulti) {
|
|
138
|
+
return new SelectCompositeComponent(this.browser, placeholder, label, forceMulti);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 获取开关组件
|
|
143
|
+
* @param {String} label 标签
|
|
144
|
+
* @returns 开关组件
|
|
145
|
+
*/
|
|
146
|
+
switchComponent(label) {
|
|
147
|
+
return new SwitchComponent(this.browser, label);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 获取表格组件
|
|
152
|
+
* @returns 表格组件
|
|
153
|
+
*/
|
|
154
|
+
tableComponent() {
|
|
155
|
+
return new TableComponent(this.browser);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 获取多行文本输入组件
|
|
160
|
+
* @param {String} placeholder 背景文字
|
|
161
|
+
* @param {String} label 标签
|
|
162
|
+
* @returns 多行文本输入组件
|
|
163
|
+
*/
|
|
164
|
+
textareaComponent(label) {
|
|
165
|
+
return new TextareaComponent(this.browser, label);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 获取文本组件
|
|
170
|
+
* @param {String} text 文本
|
|
171
|
+
* @returns 文本组件
|
|
172
|
+
*/
|
|
173
|
+
textComponent(text) {
|
|
174
|
+
return new TextComponent(this.browser, text);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 获取顶部菜单组件
|
|
179
|
+
* @returns 顶部菜单组件
|
|
180
|
+
*/
|
|
181
|
+
topMenuComponent(firstItem) {
|
|
182
|
+
return new TopMenuComponent(this.browser, firstItem);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 等待加载
|
|
187
|
+
*/
|
|
188
|
+
async loading() {
|
|
189
|
+
try {
|
|
190
|
+
const xpath = "//*[contains(@class, 'loading-mask') and (not (ancestor-or-self::*[contains(@style,'display: none')]))]";
|
|
191
|
+
if (await this.browser.isDisplayed(xpath, 500)) {
|
|
192
|
+
await this.browser.waitUntilElementBeNotVisible(xpath);
|
|
193
|
+
}
|
|
194
|
+
await this.browser.sleep(1000);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 获取菜单组件
|
|
202
|
+
* @param {String} firstItem 大菜单项
|
|
203
|
+
* @returns ...菜单组件
|
|
204
|
+
*/
|
|
205
|
+
menuComponent() {
|
|
206
|
+
let that = this;
|
|
207
|
+
class MenuComponent extends require("../component/Component") {
|
|
208
|
+
constructor(browser) {
|
|
209
|
+
super(browser);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* 选择菜单
|
|
214
|
+
* @param {String} leftMenuItem 左侧菜单项
|
|
215
|
+
* @param {String} menuItem 菜单项
|
|
216
|
+
*/
|
|
217
|
+
async select(leftMenuItem, menuItem) {
|
|
218
|
+
await that.blockComponent(`//*[@class="nav-right"]//span[contains(@class,'w-menu-item')]`).click();
|
|
219
|
+
let xpath = `//*[contains(@class,"menu-popover-content")]//div[@class='w-popover__content']`;
|
|
220
|
+
await that.blockComponent(xpath).waitUntilBeVisible();
|
|
221
|
+
await that.blockComponent(`${xpath}//div[contains(@class, 'left-menu')]//div[@class='w-menu-item--content'][normalize-space(text())='${leftMenuItem}']`).click();
|
|
222
|
+
await that.blockComponent(`${xpath}//div[contains(@class, 'right-menu')]//p[@title='${menuItem}']`).waitUntilBeVisible();
|
|
223
|
+
await that.blockComponent(`${xpath}//div[contains(@class, 'right-menu')]//p[@title='${menuItem}']`).click();
|
|
224
|
+
let moveXpath = `//div[@class="nav-title"]`
|
|
225
|
+
await that.browser.moveMouseTo(moveXpath);
|
|
226
|
+
await that.blockComponent(xpath).waitUntilBeNotVisible();
|
|
227
|
+
await that.loading();
|
|
228
|
+
await that.loading();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
return new MenuComponent(that.browser)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
module.exports = Page;
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
const func = require("./func");
|
|
6
|
+
|
|
7
|
+
beforeAll(async () => {
|
|
8
|
+
await browser.maximize();
|
|
9
|
+
await browser.get(config.url.login);
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test("input/button", async () => {
|
|
13
|
+
const page = new Page(browser);
|
|
14
|
+
await page.inputComponent("请输入用户名").input(config.家医登录.user.xlc.用户名);
|
|
15
|
+
await page.inputComponent("请输入密码").input(config.家医登录.user.xlc.密码);
|
|
16
|
+
await page.buttonComponent("登 录").click();
|
|
17
|
+
await page.blockComponent(`//div[@id="tab-1"][text()='医生首页']`).waitUntilBeVisible();
|
|
18
|
+
await page.browser.sleep(2000);
|
|
19
|
+
await page.loading();
|
|
20
|
+
await page.loading();
|
|
21
|
+
await page.loading();
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test.skip("menu/selectComposite/input/select/block/check/button/table", async () => {
|
|
25
|
+
const page = new Page(browser);
|
|
26
|
+
await page.menuComponent().select('居民管理','已签约居民');
|
|
27
|
+
await page.textComponent('更多查询').click();
|
|
28
|
+
await page.textComponent('折叠查询').waitUntilBeVisible();
|
|
29
|
+
await page.selectComponent('请选择履约情况').select('未履约');
|
|
30
|
+
await page.selectComponent('', '查询类型').select('按登录用户查询');
|
|
31
|
+
await page.inputComponent('', '关键字').input('王金龙');
|
|
32
|
+
// await page.selectCompositeComponent('', '签约团队').select(['兴隆测试团队']);
|
|
33
|
+
// await page.selectCompositeComponent('', '所属人群').select({'所有':['精神病','肿瘤非晚期']});
|
|
34
|
+
// await page.blockComponent(`//*[normalize-space(text())='协议止日']/following-sibling::*`)
|
|
35
|
+
// .inputComponent('起').input('2024-03-28');
|
|
36
|
+
// await page.blockComponent(`//*[normalize-space(text())='协议止日']/following-sibling::*`)
|
|
37
|
+
// .inputComponent('止').input('2024-03-28');
|
|
38
|
+
// await page.selectComponent('', '人群大类').select('一般人群');
|
|
39
|
+
// await page.checkboxComponent('是否并且').select();
|
|
40
|
+
await page.buttonComponent('查询').click();
|
|
41
|
+
await page.loading();
|
|
42
|
+
let tableData = await page.tableComponent().getTableData();
|
|
43
|
+
console.log(tableData);
|
|
44
|
+
|
|
45
|
+
// await page.menuComponent().select('签约记录','签约记录');
|
|
46
|
+
// //有重复的,只能选择第一个
|
|
47
|
+
// await page.selectCompositeComponent('', '签约团队').select(['兴隆测试团队', '兴隆测试团队']);
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test("dialog/canvas", async () => {
|
|
51
|
+
const page = new Page(browser);
|
|
52
|
+
await page.menuComponent().select('居民管理','未签约居民');
|
|
53
|
+
await page.tableComponent().blockComponent(1).buttonComponent('签约').click();
|
|
54
|
+
await page.loading();
|
|
55
|
+
await page.dialogComponent('签约').buttonComponent('下一步').click();
|
|
56
|
+
await page.dialogComponent('签约').blockComponent(`//*[normalize-space(text())='所有人群基础包']/ancestor::label`).checkboxComponent().select();
|
|
57
|
+
await page.dialogComponent('签约').buttonComponent('下一步').click();
|
|
58
|
+
await page.blockComponent(`(//*[text()='居民签字:']/following-sibling::*)[1]`).click();
|
|
59
|
+
await page.dialogComponent('居民签字').canvasComponent().draw();
|
|
60
|
+
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|