@winning-test/component 0.0.102 → 0.0.104
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/package.json +1 -1
- package/rfds5.6/component/BlockComponent.js +264 -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 +46 -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 +230 -0
- package/rfds5.6/test/component.test.js +64 -0
- package/rfds5.6/test/component.test.json +13 -0
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
if (this.label) {
|
|
19
|
+
return `//*[normalize-space(text())='${this.label}']/..//input[@type='radio']`;
|
|
20
|
+
}
|
|
21
|
+
return "//input[@type='radio']";
|
|
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
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 取消选择
|
|
35
|
+
*/
|
|
36
|
+
async unselect() {
|
|
37
|
+
if (await (await this.browser.findElement(this.getXpath())).isSelected()) {
|
|
38
|
+
await (await this.browser.findElement(this.getXpath())).click();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = RadioComponent;
|
|
@@ -0,0 +1,77 @@
|
|
|
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, forceMulti = false) {
|
|
14
|
+
super(browser);
|
|
15
|
+
this.placeholder = placeholder;
|
|
16
|
+
this.label = label;
|
|
17
|
+
this.forceMulti = forceMulti;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_createXpath() {
|
|
21
|
+
if (this.placeholder) {
|
|
22
|
+
return `//input[@placeholder='${this.placeholder}']`;
|
|
23
|
+
}
|
|
24
|
+
if (this.label) {
|
|
25
|
+
return `//*[normalize-space(text())='${this.label}']/ancestor-or-self::label/..//input`;
|
|
26
|
+
}
|
|
27
|
+
return "//input[@type='text']";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 选择选项
|
|
32
|
+
* @param {...String} items 选项
|
|
33
|
+
*/
|
|
34
|
+
async select(...items) {
|
|
35
|
+
let count = 2;
|
|
36
|
+
while (count > 0) {
|
|
37
|
+
try {
|
|
38
|
+
await this._select(...items);
|
|
39
|
+
if (items.length > 1 || this.forceMulti){ // 多选不检查value
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
const value = await this.getValue();
|
|
43
|
+
if (!(value && items.join().indexOf(value) !== -1)) {
|
|
44
|
+
throw new Error(`选择${items}失败`);
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (count > 1) {
|
|
49
|
+
count--;
|
|
50
|
+
await this.browser.sleep(500);
|
|
51
|
+
} else {
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
await this.browser.sleep(SelectComponent.delayTime);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async _select(...items) {
|
|
60
|
+
class ListComponent extends require("./ListComponent") {
|
|
61
|
+
_createXpath() {
|
|
62
|
+
return "//*[@class='w-scrollbar']"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let xpath = this.getXpath();
|
|
66
|
+
await (await this.browser.findElement(xpath)).click();
|
|
67
|
+
let listComponent = new ListComponent(this.browser);
|
|
68
|
+
await listComponent.select(...items);
|
|
69
|
+
if (items.length > 1 || this.forceMulti) {
|
|
70
|
+
xpath = this.getXpath();
|
|
71
|
+
await (await this.browser.findElement(xpath)).click();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = SelectComponent;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 复合选择器组件
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
const ListCompositeComponent = require('./ListCompositeComponent');
|
|
6
|
+
class SelectCompositeComponent extends require("./Component") {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 复合选择器组件
|
|
10
|
+
* @param {Browser} browser 浏览器
|
|
11
|
+
* @param {String} placeholder 背景文字
|
|
12
|
+
* @param {String} label 标签
|
|
13
|
+
*/
|
|
14
|
+
constructor(browser, placeholder, label) {
|
|
15
|
+
super(browser);
|
|
16
|
+
this.placeholder = placeholder;
|
|
17
|
+
this.label = label;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_createXpath() {
|
|
21
|
+
if (this.placeholder) {
|
|
22
|
+
return `//input[@placeholder='${this.placeholder}']`;
|
|
23
|
+
}
|
|
24
|
+
if (this.label) {
|
|
25
|
+
return `//*[normalize-space(text())='${this.label}']/ancestor-or-self::label/..//input`;
|
|
26
|
+
}
|
|
27
|
+
return "//input[@type='text']";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 选择列表
|
|
32
|
+
*
|
|
33
|
+
* @param {Array or Object} items 列表项
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
async select(items) {
|
|
37
|
+
let xpath = this.getXpath();
|
|
38
|
+
await (await this.browser.findElement(xpath)).click();
|
|
39
|
+
let listCompositeComponent = new ListCompositeComponent(this.browser);
|
|
40
|
+
await listCompositeComponent.select(items);
|
|
41
|
+
await (await this.browser.findElement(xpath)).click();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = SelectCompositeComponent;
|
|
@@ -0,0 +1,50 @@
|
|
|
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}']//following-sibling::div//input[@type='checkbox']`;
|
|
20
|
+
}
|
|
21
|
+
return "//input[@type='checkbox' and @class='w-switch__input']";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 打开
|
|
26
|
+
*/
|
|
27
|
+
async on() {
|
|
28
|
+
let xpath = this.getXpath();
|
|
29
|
+
let checked = Boolean(await (await this.browser.findElement(xpath)).getAttribute("checked"));
|
|
30
|
+
if (!checked) {
|
|
31
|
+
await (await this.browser.findElement(xpath)).click();
|
|
32
|
+
await this.browser.sleep(SwitchComponent.delayTime);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 关闭
|
|
38
|
+
*/
|
|
39
|
+
async off() {
|
|
40
|
+
let xpath = this.getXpath();
|
|
41
|
+
let checked = Boolean(await (await this.browser.findElement(xpath)).getAttribute("checked"));
|
|
42
|
+
if (checked) {
|
|
43
|
+
await (await this.browser.findElement(xpath)).click();
|
|
44
|
+
await this.browser.sleep(SwitchComponent.delayTime);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = SwitchComponent;
|
|
@@ -0,0 +1,113 @@
|
|
|
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 "//*[contains(@class,'w-table ')]";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_createHeaderXapth() {
|
|
24
|
+
return "//*[contains(@class,'w-table__header-wrapper')]//thead";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_createBodyXapth() {
|
|
28
|
+
return "//*[contains(@class,'w-table__body-wrapper')]//tbody";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 获取表格数据
|
|
33
|
+
* @returns 表格数据
|
|
34
|
+
*/
|
|
35
|
+
async getTableData() {
|
|
36
|
+
let ret = [];
|
|
37
|
+
// 先判断表单是否有数据,没有的话返回[]
|
|
38
|
+
let z_xpath = `${this.getXpath()}${this._createBodyXapth()}`
|
|
39
|
+
if(!await this.browser.isDisplayed(`${z_xpath}`, 2000)) {
|
|
40
|
+
return ret;
|
|
41
|
+
}
|
|
42
|
+
if(!await this.browser.isDisplayed(`${z_xpath}//tr`, 2000)) {
|
|
43
|
+
return ret;
|
|
44
|
+
}
|
|
45
|
+
// 默认表格有数据
|
|
46
|
+
let xpath = `(${this.getXpath()}${this._createBodyXapth()}//tr)[1]`;
|
|
47
|
+
await this.browser.waitUntilElementBeVisible(xpath);
|
|
48
|
+
await this.browser.sleep(TableComponent.delayTime);
|
|
49
|
+
// 处理表头
|
|
50
|
+
if (!this._createHeaderXapth()) {
|
|
51
|
+
return ret;
|
|
52
|
+
}
|
|
53
|
+
xpath = `(${this.getXpath()}${this._createHeaderXapth()}//tr)[1]/th`;
|
|
54
|
+
let titles = await this.browser.findElements(xpath);
|
|
55
|
+
for (let i = 0; i < titles.length; i++) {
|
|
56
|
+
titles[i] = ((await titles[i].getText(true)).replaceAll("\n", "")).trim();
|
|
57
|
+
}
|
|
58
|
+
// 处理表体
|
|
59
|
+
xpath = `${this.getXpath()}${this._createBodyXapth()}//tr[contains(@class, 'w-table__row')]`;
|
|
60
|
+
let trs = await this.browser.findElements(xpath);
|
|
61
|
+
for (let i = 0; i < trs.length; i++) {
|
|
62
|
+
xpath = `(${this.getXpath()}${this._createBodyXapth()}//tr[contains(@class, 'w-table__row')])[${i + 1}]/td`;
|
|
63
|
+
let tds = await this.browser.findElements(xpath);
|
|
64
|
+
let row = {};
|
|
65
|
+
for (let j = 0; j < tds.length; j++) {
|
|
66
|
+
let title = titles[j]
|
|
67
|
+
if (title) {
|
|
68
|
+
let text = (await tds[j].getText(true)).replaceAll("\n", " ");
|
|
69
|
+
row[title] = text;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
ret.push(row);
|
|
73
|
+
}
|
|
74
|
+
ret = ret.filter(row => {
|
|
75
|
+
let isDelete = true;
|
|
76
|
+
Object.keys(row).forEach(key => {
|
|
77
|
+
if (row[key] !== "") {
|
|
78
|
+
isDelete = false;
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
return !isDelete;
|
|
82
|
+
})
|
|
83
|
+
return ret;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 获取块组件
|
|
89
|
+
* @param {Number} rowNumber 行号
|
|
90
|
+
* @param {Number} columnNumber 列号
|
|
91
|
+
* @returns 块组件
|
|
92
|
+
*/
|
|
93
|
+
blockComponent(rowNumber, columnNumber) {
|
|
94
|
+
let that = this;
|
|
95
|
+
class _BlockComponent extends require("./BlockComponent") {
|
|
96
|
+
_createRootXpath() {
|
|
97
|
+
return "";
|
|
98
|
+
}
|
|
99
|
+
_createXpath() {
|
|
100
|
+
if (columnNumber) {
|
|
101
|
+
return `${that.getXpath()}${that._createBodyXapth()}//tr[${rowNumber}]/td[${columnNumber}]`;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return `${that.getXpath()}${that._createBodyXapth()}//tr[${rowNumber}]`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return new _BlockComponent(this.browser, null);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
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,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,230 @@
|
|
|
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) {
|
|
138
|
+
return new SelectCompositeComponent(this.browser, placeholder, label);
|
|
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
|
+
*/
|
|
180
|
+
async loading() {
|
|
181
|
+
try {
|
|
182
|
+
const xpath = "//*[contains(@class, 'loading-mask') and (not (ancestor-or-self::*[contains(@style,'display: none')]))]";
|
|
183
|
+
if (await this.browser.isDisplayed(xpath, 500)) {
|
|
184
|
+
await this.browser.waitUntilElementBeNotVisible(xpath);
|
|
185
|
+
}
|
|
186
|
+
await this.browser.sleep(1000);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* 获取菜单组件
|
|
194
|
+
* @param {String} firstItem 大菜单项
|
|
195
|
+
* @returns ...菜单组件
|
|
196
|
+
*/
|
|
197
|
+
menuComponent() {
|
|
198
|
+
let that = this;
|
|
199
|
+
class MenuComponent extends require("../component/Component") {
|
|
200
|
+
constructor(browser) {
|
|
201
|
+
super(browser);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 选择菜单
|
|
206
|
+
* @param {String} leftMenuItem 左侧菜单项
|
|
207
|
+
* @param {String} menuItem 菜单项
|
|
208
|
+
*/
|
|
209
|
+
async select(leftMenuItem, menuItem) {
|
|
210
|
+
await that.blockComponent(`//*[@class="nav-right"]//span[contains(@class,'w-menu-item')]`).click();
|
|
211
|
+
let xpath = `//*[contains(@class,"menu-popover-content")]//div[@class='w-popover__content']`;
|
|
212
|
+
await that.blockComponent(xpath).waitUntilBeVisible();
|
|
213
|
+
await that.blockComponent(`${xpath}//div[contains(@class, 'left-menu')]//div[@class='w-menu-item--content'][normalize-space(text())='${leftMenuItem}']`).click();
|
|
214
|
+
await that.blockComponent(`${xpath}//div[contains(@class, 'right-menu')]//p[@title='${menuItem}']`).waitUntilBeVisible();
|
|
215
|
+
await that.blockComponent(`${xpath}//div[contains(@class, 'right-menu')]//p[@title='${menuItem}']`).click();
|
|
216
|
+
let moveXpath = `//div[@class="nav-title"]`
|
|
217
|
+
await that.browser.moveMouseTo(moveXpath);
|
|
218
|
+
await that.blockComponent(xpath).waitUntilBeNotVisible();
|
|
219
|
+
await that.loading();
|
|
220
|
+
await that.loading();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
return new MenuComponent(that.browser)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
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
|
+
|