@winning-test/component 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CustomSequencer.js +30 -0
- package/infusion60/component/BlockComponent.js +224 -0
- package/infusion60/component/ButtonComponent.js +23 -0
- package/infusion60/component/CheckboxComponent.js +46 -0
- package/infusion60/component/Component.js +78 -0
- package/infusion60/component/DialogComponent.js +23 -0
- package/infusion60/component/InputComponent.js +31 -0
- package/infusion60/component/LeftMenuComponent.js +38 -0
- package/infusion60/component/ListComponent.js +53 -0
- package/infusion60/component/MessageComponent.js +23 -0
- package/infusion60/component/SelectComponent.js +76 -0
- package/infusion60/component/SwitchComponent.js +47 -0
- package/infusion60/component/TableComponent.js +119 -0
- package/infusion60/component/TextComponent.js +23 -0
- package/infusion60/component/TopMenuComponent.js +32 -0
- package/infusion60/page/Page.js +170 -0
- package/infusion60/test/component.test.js +65 -0
- package/infusion60/test/component.test.json +12 -0
- package/jest.config.js +7 -0
- package/package.json +23 -0
- package/rhm5.6/component/BlockComponent.js +187 -0
- package/rhm5.6/component/ButtonComponent.js +23 -0
- package/rhm5.6/component/CheckboxComponent.js +53 -0
- package/rhm5.6/component/Component.js +95 -0
- package/rhm5.6/component/DialogComponent.js +23 -0
- package/rhm5.6/component/InputComponent.js +31 -0
- package/rhm5.6/component/LeftMenuComponent.js +35 -0
- package/rhm5.6/component/RadioComponent.js +35 -0
- package/rhm5.6/component/SelectComponent.js +45 -0
- package/rhm5.6/component/TableComponent.js +90 -0
- package/rhm5.6/component/TextComponent.js +23 -0
- package/rhm5.6/component/TopMenuComponent.js +34 -0
- package/rhm5.6/page/Page.js +143 -0
- package/rhm5.6/test/component.test.js +61 -0
- package/rhm5.6/test/component.test.json +16 -0
- package/winex60/component/BlockComponent.js +241 -0
- package/winex60/component/ButtonComponent.js +23 -0
- package/winex60/component/CascaderComponent.js +51 -0
- package/winex60/component/CheckboxComponent.js +46 -0
- package/winex60/component/Component.js +78 -0
- package/winex60/component/DialogComponent.js +234 -0
- package/winex60/component/InputComponent.js +31 -0
- package/winex60/component/LeftMenuComponent.js +78 -0
- package/winex60/component/ListComponent.js +52 -0
- package/winex60/component/MessageComponent.js +57 -0
- package/winex60/component/RadioComponent.js +41 -0
- package/winex60/component/SelectComponent.js +73 -0
- package/winex60/component/SwitchComponent.js +45 -0
- package/winex60/component/TableComponent.js +107 -0
- package/winex60/component/TextComponent.js +23 -0
- package/winex60/page/Page.js +158 -0
- package/winex60/test/component.test.js +36 -0
- package/winex60/test/select.test.js +26 -0
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
_createXpath() {
|
|
16
|
+
return "//table"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 获取表格数据
|
|
21
|
+
* @returns 表格数据
|
|
22
|
+
*/
|
|
23
|
+
async getTableData() {
|
|
24
|
+
let ret = [];
|
|
25
|
+
let xpath = `(${this.getXpath()}//tbody)[1]/tr[1]`;
|
|
26
|
+
await (await this.browser.findElement(xpath)).waitUntilBeVisible();
|
|
27
|
+
await this.browser.sleep(TableComponent.delayTime);
|
|
28
|
+
xpath = `(${this.getXpath()}//thead)[1]/tr/th`;
|
|
29
|
+
let titles = await this.browser.findElements(xpath);
|
|
30
|
+
for (let i = 0; i < titles.length; i++) {
|
|
31
|
+
titles[i] = await titles[i].getText(true);
|
|
32
|
+
}
|
|
33
|
+
xpath = `(${this.getXpath()}//tbody)[1]/tr`;
|
|
34
|
+
let trs = await this.browser.findElements(xpath);
|
|
35
|
+
for (let i = 0; i < trs.length; i++) {
|
|
36
|
+
xpath = `(${this.getXpath()}//tbody)[1]/tr[${i + 1}]/td`;
|
|
37
|
+
let tds = await this.browser.findElements(xpath);
|
|
38
|
+
let row = {};
|
|
39
|
+
for (let j = 0; j < tds.length; j++) {
|
|
40
|
+
let title = titles[j]
|
|
41
|
+
if (title) {
|
|
42
|
+
let text = (await tds[j].getText(true)).replaceAll("\n", " ");
|
|
43
|
+
row[title] = text;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
ret.push(row);
|
|
47
|
+
}
|
|
48
|
+
return ret;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 选择所有行
|
|
53
|
+
*/
|
|
54
|
+
async selectAll() {
|
|
55
|
+
let xpath = `(${this.getXpath()}//thead)[1]/tr[1]/th[1]//input[@type='checkbox']`;
|
|
56
|
+
if (!(await (await this.browser.findElement(xpath)).isSelected())) {
|
|
57
|
+
await (await this.browser.findElement(xpath)).click();
|
|
58
|
+
await this.browser.sleep(TableComponent.delayTime);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 取消选择所有行
|
|
64
|
+
*/
|
|
65
|
+
async unselectAll() {
|
|
66
|
+
let xpath = `(${this.getXpath()}//thead)[1]/tr[1]/th[1]//input[@type='checkbox']`;
|
|
67
|
+
if (await (await this.browser.findElement(xpath)).isSelected()) {
|
|
68
|
+
await (await this.browser.findElement(xpath)).click();
|
|
69
|
+
await this.browser.sleep(TableComponent.delayTime);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 选择行
|
|
75
|
+
* @param {Number} rowNumber 行号
|
|
76
|
+
*/
|
|
77
|
+
async select(rowNumber) {
|
|
78
|
+
let xpath = `(${this.getXpath()}//tbody)[1]/tr[${rowNumber}]/td[1]//input[@type='checkbox']`;
|
|
79
|
+
if (!(await (await this.browser.findElement(xpath)).isSelected())) {
|
|
80
|
+
await (await this.browser.findElement(xpath)).click();
|
|
81
|
+
await this.browser.sleep(TableComponent.delayTime);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 取消选择行
|
|
87
|
+
* @param {Number} rowNumber 行号
|
|
88
|
+
*/
|
|
89
|
+
async unselect(rowNumber) {
|
|
90
|
+
let xpath = `(${this.getXpath()}//tbody)[1]/tr[${rowNumber}]/td[1]//input[@type='checkbox']`;
|
|
91
|
+
if (await (await this.browser.findElement(xpath)).isSelected()) {
|
|
92
|
+
await (await this.browser.findElement(xpath)).click();
|
|
93
|
+
await this.browser.sleep(TableComponent.delayTime);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 获取块组件
|
|
100
|
+
* @param {Number} rowNumber 行号
|
|
101
|
+
* @param {Number} columnNumber 列号
|
|
102
|
+
* @returns 块组件
|
|
103
|
+
*/
|
|
104
|
+
blockComponent(rowNumber, columnNumber) {
|
|
105
|
+
let that = this;
|
|
106
|
+
class _BlockComponent extends require("./BlockComponent") {
|
|
107
|
+
_createRootXpath() {
|
|
108
|
+
return "";
|
|
109
|
+
}
|
|
110
|
+
_createXpath() {
|
|
111
|
+
return `(${that.getXpath()}//tbody)[1]/tr[${rowNumber}]/td[${columnNumber}]`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return new _BlockComponent(this.browser, null, null);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
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,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 顶部菜单组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class TopMenuComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 顶部菜单组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
*/
|
|
11
|
+
constructor(browser) {
|
|
12
|
+
super(browser);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_createXpath() {
|
|
16
|
+
return "//*[contains(@class,'w-menu is-horizontal')]";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 选择菜单
|
|
21
|
+
* @param {String} menuItem 菜单项
|
|
22
|
+
*/
|
|
23
|
+
async select(menuItem) {
|
|
24
|
+
let xpath = `${this.getXpath()}//*[normalize-space(text())='${menuItem}']/ancestor::*[contains(@class,'w-menu-item')]`;
|
|
25
|
+
await (await this.browser.findElement(xpath)).click();
|
|
26
|
+
await this.browser.sleep(TopMenuComponent.delayTime);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = TopMenuComponent;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const BlockComponent = require("../component/BlockComponent");
|
|
2
|
+
const ButtonComponent = require("../component/ButtonComponent");
|
|
3
|
+
const CheckboxComponent = require("../component/CheckboxComponent");
|
|
4
|
+
const DialogComponent = require("../component/DialogComponent");
|
|
5
|
+
const InputComponent = require("../component/InputComponent");
|
|
6
|
+
const LeftMenuComponent = require("../component/LeftMenuComponent");
|
|
7
|
+
const ListComponent = require("../component/ListComponent");
|
|
8
|
+
const SelectComponent = require("../component/SelectComponent");
|
|
9
|
+
const SwitchComponent = require("../component/SwitchComponent");
|
|
10
|
+
const TopMenuComponent = require("../component/TopMenuComponent");
|
|
11
|
+
const TableComponent = require("../component/TableComponent");
|
|
12
|
+
const TextComponent = require("../component/TextComponent");
|
|
13
|
+
const MessageComponent = require("../component/MessageComponent");
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 页面类
|
|
17
|
+
*/
|
|
18
|
+
class Page extends require("@winning-test/autotest-webui").Page {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 页面类
|
|
22
|
+
* @param {Browser} browser 浏览器
|
|
23
|
+
*/
|
|
24
|
+
constructor(browser) {
|
|
25
|
+
super(browser);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 获取块组件
|
|
30
|
+
* @param {String} id id
|
|
31
|
+
* @param {String} xpath xpath
|
|
32
|
+
* @returns 块组件
|
|
33
|
+
*/
|
|
34
|
+
blockComponent(id, xpath) {
|
|
35
|
+
return new BlockComponent(this.browser, id, 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
|
+
topMenuComponent() {
|
|
134
|
+
return new TopMenuComponent(this.browser);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 获取表格组件
|
|
139
|
+
* @returns 表格组件
|
|
140
|
+
*/
|
|
141
|
+
tableComponent() {
|
|
142
|
+
return new TableComponent(this.browser);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 获取文本组件
|
|
147
|
+
* @param {String} text 文本
|
|
148
|
+
* @returns 文本组件
|
|
149
|
+
*/
|
|
150
|
+
textComponent(text) {
|
|
151
|
+
return new TextComponent(this.browser, text);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 等待加载
|
|
156
|
+
*/
|
|
157
|
+
async loading() {
|
|
158
|
+
try {
|
|
159
|
+
const xpath = "//*[@class='w-loading-mask' and (not (ancestor-or-self::*[contains(@style,'display: none')]))]";
|
|
160
|
+
if (await this.browser.isDisplayed(xpath, 200)) {
|
|
161
|
+
await this.browser.waitUntilElementBeNotVisible(xpath);
|
|
162
|
+
}
|
|
163
|
+
} catch (error) {
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
module.exports = Page;
|
|
@@ -0,0 +1,65 @@
|
|
|
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.login);
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test("input/button", async () => {
|
|
12
|
+
const page = new Page(browser);
|
|
13
|
+
await page.inputComponent("请输入您的工号").input(config.user.admin.工号);
|
|
14
|
+
await page.inputComponent("请输入您的密码").input(config.user.admin.密码);
|
|
15
|
+
await page.buttonComponent("登 录").click();
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test("topMenu/leftMenu/switch/checkbox", async () => {
|
|
19
|
+
const page = new Page(browser);
|
|
20
|
+
await page.topMenuComponent().select("配置");
|
|
21
|
+
await page.leftMenuComponent().select("水印配置");
|
|
22
|
+
await page.switchComponent("方案状态").off();
|
|
23
|
+
await page.loading();
|
|
24
|
+
await page.checkboxComponent("用户姓名").unselect();
|
|
25
|
+
await page.loading();
|
|
26
|
+
await page.switchComponent("方案状态").on();
|
|
27
|
+
await page.loading();
|
|
28
|
+
await page.checkboxComponent("用户姓名").select();
|
|
29
|
+
await page.loading();
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test("table", async () => {
|
|
33
|
+
const page = new Page(browser);
|
|
34
|
+
await page.topMenuComponent().select("输液/治疗");
|
|
35
|
+
let tableData = await page.tableComponent().getTableData();
|
|
36
|
+
console.log(tableData);
|
|
37
|
+
await page.tableComponent().selectAll();
|
|
38
|
+
await page.tableComponent().unselectAll();
|
|
39
|
+
await page.tableComponent().select(1);
|
|
40
|
+
await page.tableComponent().unselect(1);
|
|
41
|
+
await page.tableComponent().blockComponent(1,2).click();
|
|
42
|
+
await page.loading();
|
|
43
|
+
tableData = await page.tableComponent().getTableData();
|
|
44
|
+
console.log(tableData);
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test("dialog/select/list", async () => {
|
|
48
|
+
const page = new Page(browser);
|
|
49
|
+
await page.topMenuComponent().select("配置");
|
|
50
|
+
await page.leftMenuComponent().select("皮试配置");
|
|
51
|
+
await page.buttonComponent("添加皮试项目").click();
|
|
52
|
+
await page.dialogComponent("皮试药品编辑").selectComponent(null,"药品名称").select("[甲]$奥美拉唑胶囊(7#,1)","[甲]利多卡因针");
|
|
53
|
+
await page.dialogComponent("皮试药品编辑").buttonComponent("取消").click();
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test("message/text", async () => {
|
|
57
|
+
const page = new Page(browser);
|
|
58
|
+
await page.topMenuComponent().select("配置");
|
|
59
|
+
await page.leftMenuComponent().select("皮试配置");
|
|
60
|
+
await page.leftMenuComponent().select("输液室配置");
|
|
61
|
+
await page.textComponent("保存").click();
|
|
62
|
+
await page.dialogComponent("提示").buttonComponent("确定").click();
|
|
63
|
+
await page.messageComponent("保存成功").waitUntilBeVisible();
|
|
64
|
+
|
|
65
|
+
})
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@winning-test/component",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "http://tfs2018-web.winning.com.cn:8080/tfs/WN_HIS/TestDept/_git/component"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@winning-test/autotest-webui": "^0.1.33"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/jest": "^29.5.1",
|
|
20
|
+
"chromedriver": "^113.0.0",
|
|
21
|
+
"jest": "^29.5.0"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
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} label 标签
|
|
54
|
+
* @returns 复选框组件
|
|
55
|
+
*/
|
|
56
|
+
checkboxComponent(label) {
|
|
57
|
+
let that = this;
|
|
58
|
+
class CheckboxComponent extends require("./CheckboxComponent") {
|
|
59
|
+
_createRootXpath() {
|
|
60
|
+
return that.getXpath();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return new CheckboxComponent(this.browser, label);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 获取对话框组件
|
|
68
|
+
* @param {String} title 标题
|
|
69
|
+
* @returns 对话框组件
|
|
70
|
+
*/
|
|
71
|
+
dialogComponent(title) {
|
|
72
|
+
let that = this;
|
|
73
|
+
class DialogComponent extends require("./DialogComponent") {
|
|
74
|
+
_createRootXpath() {
|
|
75
|
+
return that.getXpath();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return new DialogComponent(this.browser, title);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 获取输入框组件
|
|
83
|
+
* @param {String} label 标签
|
|
84
|
+
* @param {String} id id
|
|
85
|
+
* @returns 输入框组件
|
|
86
|
+
*/
|
|
87
|
+
inputComponent(label, id) {
|
|
88
|
+
let that = this;
|
|
89
|
+
class InputComponent extends require("./InputComponent") {
|
|
90
|
+
_createRootXpath() {
|
|
91
|
+
return that.getXpath();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return new InputComponent(this.browser, label, id);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 获取左侧菜单组件
|
|
99
|
+
* @returns 左侧菜单组件
|
|
100
|
+
*/
|
|
101
|
+
leftMenuComponent() {
|
|
102
|
+
let that = this;
|
|
103
|
+
class LeftMenuComponent extends require("./LeftMenuComponent") {
|
|
104
|
+
_createRootXpath() {
|
|
105
|
+
return that.getXpath();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return new LeftMenuComponent(this.browser);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 获取单选框组件
|
|
113
|
+
* @param {Stirng} label 标签
|
|
114
|
+
* @returns 单选框组件
|
|
115
|
+
*/
|
|
116
|
+
radioComponent(label) {
|
|
117
|
+
let that = this;
|
|
118
|
+
class RadioComponent extends require("./RadioComponent") {
|
|
119
|
+
_createRootXpath() {
|
|
120
|
+
return that.getXpath();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return new RadioComponent(this.browser, label);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 获取选择器组件
|
|
128
|
+
* @param {String} label 标签
|
|
129
|
+
* @param {String} id id
|
|
130
|
+
* @returns 选择器组件
|
|
131
|
+
*/
|
|
132
|
+
selectComponent(label, id) {
|
|
133
|
+
let that = this;
|
|
134
|
+
class SelectComponent extends require("./SelectComponent") {
|
|
135
|
+
_createRootXpath() {
|
|
136
|
+
return that.getXpath();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return new SelectComponent(this.browser, label, id);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 获取表格组件
|
|
144
|
+
* @returns 表格组件
|
|
145
|
+
*/
|
|
146
|
+
tableComponent() {
|
|
147
|
+
let that = this;
|
|
148
|
+
class TableComponent extends require("./TableComponent") {
|
|
149
|
+
_createRootXpath() {
|
|
150
|
+
return that.getXpath();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return new TableComponent(this.browser);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* 获取文本组件
|
|
158
|
+
* @param {String} text 文本
|
|
159
|
+
* @returns 文本组件
|
|
160
|
+
*/
|
|
161
|
+
textComponent(text) {
|
|
162
|
+
let that = this;
|
|
163
|
+
class TextComponent extends require("./TextComponent") {
|
|
164
|
+
_createRootXpath() {
|
|
165
|
+
return that.getXpath();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return new TextComponent(this.browser, text);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 获取顶部菜单组件
|
|
173
|
+
* @returns 顶部菜单组件
|
|
174
|
+
*/
|
|
175
|
+
topMenuComponent() {
|
|
176
|
+
let that = this;
|
|
177
|
+
class TopMenuComponent extends require("./TopMenuComponent") {
|
|
178
|
+
_createRootXpath() {
|
|
179
|
+
return that.getXpath();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return new TopMenuComponent(this.browser);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
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::a`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = ButtonComponent;
|