@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,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
|
+
return `//input[@type='checkbox' and @label='${this.label}']/ancestor-or-self::*[@class='radiogroup']/parent::*`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 选择
|
|
23
|
+
* @param {...String} items 选项
|
|
24
|
+
*/
|
|
25
|
+
async select(...items) {
|
|
26
|
+
for (let i = 0; i < items.length; i++) {
|
|
27
|
+
const item = items[i];
|
|
28
|
+
const xpath = `${this.getXpath()}//*[text()='${item}']/ancestor-or-self::*[@class='radiogroup']//input[@type='checkbox']`;
|
|
29
|
+
if (!(await (await this.browser.findElement(xpath)).isSelected())) {
|
|
30
|
+
await (await this.browser.findElement(xpath)).click();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
await this.browser.sleep(CheckboxComponent.delayTime);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 取消选择
|
|
38
|
+
* @param {...String} items 选项
|
|
39
|
+
*/
|
|
40
|
+
async unselect(...items) {
|
|
41
|
+
for (let i = 0; i < items.length; i++) {
|
|
42
|
+
const item = items[i];
|
|
43
|
+
const xpath = `${this.getXpath()}//*[text()='${item}']/ancestor-or-self::*[@class='radiogroup']//input[@type='checkbox']`;
|
|
44
|
+
if (await (await this.browser.findElement(xpath)).isSelected()) {
|
|
45
|
+
await (await this.browser.findElement(xpath)).click();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
await this.browser.sleep(CheckboxComponent.delayTime);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = CheckboxComponent;
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
return `${super.getXpath()}[not (contains(@class,'hide'))]`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async click() {
|
|
23
|
+
await super.click();
|
|
24
|
+
await this.browser.sleep(Component.delayTime);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async doubleClick() {
|
|
28
|
+
await super.doubleClick();
|
|
29
|
+
await this.browser.sleep(Component.delayTime);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async input(...agrs) {
|
|
33
|
+
await super.input(...agrs);
|
|
34
|
+
await this.browser.sleep(Component.delayTime);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 慢吞吞输入
|
|
39
|
+
* @param {...String} agrs 输入值
|
|
40
|
+
*/
|
|
41
|
+
async inputSlowly(...agrs) {
|
|
42
|
+
for (let i = 0; i < agrs.length; i++) {
|
|
43
|
+
const agr = agrs[i];
|
|
44
|
+
for (let j = 0; j < agr.length; j++) {
|
|
45
|
+
const chr = agr[j];
|
|
46
|
+
await super.input(chr);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
await this.browser.sleep(Component.delayTime);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async clear() {
|
|
54
|
+
await super.clear();
|
|
55
|
+
await this.browser.sleep(Component.delayTime);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async getText() {
|
|
59
|
+
await this.browser.sleep(Component.delayTime);
|
|
60
|
+
return await super.getText();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async getValue() {
|
|
64
|
+
await this.browser.sleep(Component.delayTime);
|
|
65
|
+
return await super.getValue();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
async getAttribute(attributeName) {
|
|
70
|
+
await this.browser.sleep(Component.delayTime);
|
|
71
|
+
return await super.getAttribute(attributeName);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async waitUntilBeDisabled() {
|
|
75
|
+
await super.waitUntilBeDisabled();
|
|
76
|
+
await this.browser.sleep(Component.delayTime);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async waitUntilBeEnabled() {
|
|
80
|
+
await super.waitUntilBeEnabled();
|
|
81
|
+
await this.browser.sleep(Component.delayTime);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async waitUntilBeNotVisible() {
|
|
85
|
+
await super.waitUntilBeNotVisible();
|
|
86
|
+
await this.browser.sleep(Component.delayTime);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async waitUntilBeVisible() {
|
|
90
|
+
await super.waitUntilBeVisible();
|
|
91
|
+
await this.browser.sleep(Component.delayTime);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module.exports = Component;
|
|
@@ -0,0 +1,23 @@
|
|
|
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);
|
|
14
|
+
this.title = title;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_createXpath() {
|
|
18
|
+
return `//*[contains(text(),'${this.title}')]/ancestor::*[@type='dialog' or @type='page']`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
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} label 标签
|
|
11
|
+
* @param {String} id id
|
|
12
|
+
*/
|
|
13
|
+
constructor(browser, label, id) {
|
|
14
|
+
super(browser);
|
|
15
|
+
this.label = label;
|
|
16
|
+
this.id = id;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_createXpath() {
|
|
20
|
+
if (this.label) {
|
|
21
|
+
return `//input[@label='${this.label}']`;
|
|
22
|
+
}
|
|
23
|
+
if (this.id) {
|
|
24
|
+
return `//input[@id='${this.id}']`;
|
|
25
|
+
}
|
|
26
|
+
return "//input[@type='text']";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = InputComponent;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 左侧菜单组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
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 "//*[@id='openTree']";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 选择菜单
|
|
21
|
+
* @param {String} menuItem菜单项
|
|
22
|
+
*/
|
|
23
|
+
async select(menuItem) {
|
|
24
|
+
await this.browser.switchToFrame();
|
|
25
|
+
await this.browser.switchToFrame("//iframe[@class='iframe-content active']");
|
|
26
|
+
let xpath = `${this.getXpath()}//*[normalize-space(text())='${menuItem}']`;
|
|
27
|
+
await (await this.browser.findElement(xpath)).click();
|
|
28
|
+
await this.browser.sleep(LeftMenuComponent.delayTime);
|
|
29
|
+
await this.browser.switchToFrame("//iframe[@id='prmIframe']");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = LeftMenuComponent;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 `//input[@type='radio' and @label='${this.label}']/ancestor-or-self::*[@class='radiogroup']/parent::*`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 选择
|
|
23
|
+
* @param {...String} items 选项
|
|
24
|
+
*/
|
|
25
|
+
async select(item) {
|
|
26
|
+
const xpath = `${this.getXpath()}//*[text()='${item}']/ancestor-or-self::*[@class='radiogroup']//input[@type='radio']`;
|
|
27
|
+
if (!(await (await this.browser.findElement(xpath)).isSelected())) {
|
|
28
|
+
await (await this.browser.findElement(xpath)).click();
|
|
29
|
+
}
|
|
30
|
+
await this.browser.sleep(RadioComponent.delayTime);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = RadioComponent;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 选择器组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class SelectComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 选择器组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
* @param {String} label 标签
|
|
11
|
+
* @param {String} id id
|
|
12
|
+
*/
|
|
13
|
+
constructor(browser, label, id) {
|
|
14
|
+
super(browser);
|
|
15
|
+
this.label = label;
|
|
16
|
+
this.id = id;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_createXpath() {
|
|
20
|
+
if (this.label) {
|
|
21
|
+
return `//select[@label='${this.label}']`;
|
|
22
|
+
}
|
|
23
|
+
if (this.id) {
|
|
24
|
+
return `//select[@id='${this.id}']`;
|
|
25
|
+
}
|
|
26
|
+
return "//select"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 选择选项
|
|
31
|
+
* @param {...String} items 选项
|
|
32
|
+
*/
|
|
33
|
+
async select(...items) {
|
|
34
|
+
let xpath = this.getXpath()
|
|
35
|
+
await (await this.browser.findElement(xpath)).click();
|
|
36
|
+
for (let i = 0; i < items.length; i++) {
|
|
37
|
+
xpath = `${this.getXpath()}//option[text()='${items[i]}']`;
|
|
38
|
+
await (await this.browser.findElement(xpath)).click();
|
|
39
|
+
}
|
|
40
|
+
await this.browser.sleep(SelectComponent.delayTime);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = SelectComponent;
|
|
@@ -0,0 +1,90 @@
|
|
|
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 "";
|
|
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
|
+
await (await this.browser.findElement(xpath)).waitUntilBeVisible();
|
|
39
|
+
await this.browser.sleep(TableComponent.delayTime);
|
|
40
|
+
// 处理表头
|
|
41
|
+
if (!this._createHeaderXapth()) {
|
|
42
|
+
return ret;
|
|
43
|
+
}
|
|
44
|
+
xpath = `${this.getXpath()}${this._createHeaderXapth()}//tr[1]/td`;
|
|
45
|
+
let titles = await this.browser.findElements(xpath);
|
|
46
|
+
for (let i = 0; i < titles.length; i++) {
|
|
47
|
+
titles[i] = await titles[i].getText(true);
|
|
48
|
+
}
|
|
49
|
+
// 处理表体
|
|
50
|
+
xpath = `${this.getXpath()}${this._createBodyXapth()}//tr`;
|
|
51
|
+
let trs = await this.browser.findElements(xpath);
|
|
52
|
+
for (let i = 0; i < trs.length; i++) {
|
|
53
|
+
xpath = `${this.getXpath()}${this._createBodyXapth()}//tr[${i + 1}]/td`;
|
|
54
|
+
let tds = await this.browser.findElements(xpath);
|
|
55
|
+
let row = {};
|
|
56
|
+
for (let j = 0; j < tds.length; j++) {
|
|
57
|
+
let title = titles[j]
|
|
58
|
+
if (title) {
|
|
59
|
+
let text = (await tds[j].getText(true)).replaceAll("\n", " ");
|
|
60
|
+
row[title] = text;
|
|
61
|
+
}
|
|
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
|
+
return `${that.getXpath()}${that._createBodyXapth()}//tr[${rowNumber}]/td[${columnNumber}]`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return new _BlockComponent(this.browser, null);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
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,34 @@
|
|
|
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 "//*[@id='topBlue']";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 选择菜单
|
|
21
|
+
* @param {String} menuItem 菜单项
|
|
22
|
+
*/
|
|
23
|
+
async select(menuItem) {
|
|
24
|
+
await this.browser.switchToFrame();
|
|
25
|
+
let xpath = `${this.getXpath()}//*[normalize-space(text())='${menuItem}']`;
|
|
26
|
+
await (await this.browser.findElement(xpath)).click();
|
|
27
|
+
await this.browser.sleep(TopMenuComponent.delayTime);
|
|
28
|
+
await this.browser.switchToFrame("//iframe[@class='iframe-content active']");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = TopMenuComponent;
|
|
@@ -0,0 +1,143 @@
|
|
|
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 RadioComponent = require("../component/RadioComponent");
|
|
8
|
+
const SelectComponent = require("../component/SelectComponent");
|
|
9
|
+
const TableComponent = require("../component/TableComponent");
|
|
10
|
+
const TextComponent = require("../component/TextComponent");
|
|
11
|
+
const TopMenuComponent = require("../component/TopMenuComponent");
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 页面类
|
|
16
|
+
*/
|
|
17
|
+
class Page extends require("@winning-test/autotest-webui").Page {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 页面类
|
|
21
|
+
* @param {Browser} browser 浏览器
|
|
22
|
+
*/
|
|
23
|
+
constructor(browser) {
|
|
24
|
+
super(browser);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 获取块组件
|
|
29
|
+
* @param {String} xpath xpath
|
|
30
|
+
* @returns 块组件
|
|
31
|
+
*/
|
|
32
|
+
blockComponent(xpath) {
|
|
33
|
+
return new BlockComponent(this.browser, xpath);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 获取按钮组件
|
|
38
|
+
* @param {String} text 文本
|
|
39
|
+
* @returns 按钮组件
|
|
40
|
+
*/
|
|
41
|
+
buttonComponent(text) {
|
|
42
|
+
return new ButtonComponent(this.browser, text);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 获取复选框组件
|
|
47
|
+
* @param {String} label 标签
|
|
48
|
+
* @returns 复选框组件
|
|
49
|
+
*/
|
|
50
|
+
checkboxComponent(label) {
|
|
51
|
+
return new CheckboxComponent(this.browser, label);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 获取对话框组件
|
|
56
|
+
* @param {String} title 标题
|
|
57
|
+
* @returns 对话框组件
|
|
58
|
+
*/
|
|
59
|
+
dialogComponent(title) {
|
|
60
|
+
return new DialogComponent(this.browser, title);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 获取输入框组件
|
|
65
|
+
* @param {String} label 标签
|
|
66
|
+
* @param {String} id id
|
|
67
|
+
* @returns 输入框组件
|
|
68
|
+
*/
|
|
69
|
+
inputComponent(label, id) {
|
|
70
|
+
return new InputComponent(this.browser, label, id);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 获取左侧菜单组件
|
|
75
|
+
* @returns 左侧菜单组件
|
|
76
|
+
*/
|
|
77
|
+
leftMenuComponent() {
|
|
78
|
+
return new LeftMenuComponent(this.browser);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 获取单选框组件
|
|
83
|
+
* @param {String} label 标签
|
|
84
|
+
* @returns 单选框组件
|
|
85
|
+
*/
|
|
86
|
+
radioComponent(label) {
|
|
87
|
+
return new RadioComponent(this.browser, label)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 获取选择器组件
|
|
92
|
+
* @param {String} label 标签
|
|
93
|
+
* @param {String} id id
|
|
94
|
+
* @returns 选择器组件
|
|
95
|
+
*/
|
|
96
|
+
selectComponent(label, id) {
|
|
97
|
+
return new SelectComponent(this.browser, label, id);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 获取表格组件
|
|
102
|
+
* @returns 表格组件
|
|
103
|
+
*/
|
|
104
|
+
tableComponent() {
|
|
105
|
+
return new TableComponent(this.browser);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 获取文本组件
|
|
110
|
+
* @param {String} text 文本
|
|
111
|
+
* @returns 文本组件
|
|
112
|
+
*/
|
|
113
|
+
textComponent(text) {
|
|
114
|
+
return new TextComponent(this.browser, text);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 获取顶部菜单组件
|
|
119
|
+
* @returns 顶部菜单组件
|
|
120
|
+
*/
|
|
121
|
+
topMenuComponent() {
|
|
122
|
+
return new TopMenuComponent(this.browser);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 切换到默认iframe
|
|
127
|
+
*/
|
|
128
|
+
async switchToDefultFrame() {
|
|
129
|
+
await this.browser.switchToFrame();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 切换到活动iframe
|
|
134
|
+
*/
|
|
135
|
+
async switchToActiveFrame() {
|
|
136
|
+
await this.browser.switchToFrame();
|
|
137
|
+
await this.browser.switchToFrame("//iframe[@class='iframe-content active']");
|
|
138
|
+
await this.browser.switchToFrame("//iframe[@id='prmIframe']");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports = Page;
|
|
@@ -0,0 +1,61 @@
|
|
|
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.maAnShan.url);
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test("input/blockComponent", async () => {
|
|
12
|
+
const page = new Page(browser);
|
|
13
|
+
await page.inputComponent(null, "username").input(config.maAnShan.admin.账号);
|
|
14
|
+
await page.inputComponent(null, "password").input(config.maAnShan.admin.密码);
|
|
15
|
+
await page.blockComponent("//*[@class='signIn']").click();
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test("topMenu/leftMenu/table", async () => {
|
|
19
|
+
const page = new Page(browser);
|
|
20
|
+
await page.topMenuComponent().select("个人档案");
|
|
21
|
+
await page.leftMenuComponent().select("简档列表");
|
|
22
|
+
await page.leftMenuComponent().select("基本信息列表");
|
|
23
|
+
class TableComponent extends require("../component/TableComponent") {
|
|
24
|
+
_createXpath() {
|
|
25
|
+
return "//*[@class='datagrid-view2']";
|
|
26
|
+
}
|
|
27
|
+
_createHeaderXapth() {
|
|
28
|
+
return "//*[@class='datagrid-header']";
|
|
29
|
+
}
|
|
30
|
+
_createBodyXapth() {
|
|
31
|
+
return "//*[@class='datagrid-body']";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
await page.textComponent("个人档案编号").waitUntilBeVisible();
|
|
35
|
+
const tableData = await new TableComponent(browser).getTableData();
|
|
36
|
+
console.log(tableData);
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test("button/input/select/radio/checkbox/text/dialog", async () => {
|
|
40
|
+
const page = new Page(browser);
|
|
41
|
+
await page.blockComponent("//*[@class='button']").buttonComponent("新增").click();
|
|
42
|
+
await page.switchToActiveFrame();
|
|
43
|
+
await page.inputComponent("姓名").input("毛建杰");
|
|
44
|
+
await page.selectComponent("性别").select("男");
|
|
45
|
+
await page.inputComponent("出生日期").inputSlowly("1984-12-29",Key.ENTER);
|
|
46
|
+
await page.radioComponent("药物过敏史").select("有");
|
|
47
|
+
await page.checkboxComponent("过敏史").select("青霉素","磺胺","链霉素","其他");
|
|
48
|
+
await page.checkboxComponent("过敏史").unselect("其他");
|
|
49
|
+
await page.radioComponent("有无疾病史").select("有");
|
|
50
|
+
await page.blockComponent("//td[1][text()='疾病名称']/ancestor::*[contains(@class,'diy-xy-box')]").tableComponent().blockComponent(1,4).textComponent("新增").click();
|
|
51
|
+
await page.blockComponent("//td[1][text()='疾病名称']/ancestor::*[contains(@class,'diy-xy-box')]").tableComponent().blockComponent(2,1).selectComponent().select("高血压");
|
|
52
|
+
await page.blockComponent("//td[1][text()='疾病名称']/ancestor::*[contains(@class,'diy-xy-box')]").tableComponent().blockComponent(2,2).inputComponent().inputSlowly("2022-11-11",Key.ENTER)
|
|
53
|
+
await page.blockComponent("//td[1][text()='疾病名称']/ancestor::*[contains(@class,'diy-xy-box')]").tableComponent().blockComponent(2,3).inputComponent().input("死亡");
|
|
54
|
+
await page.blockComponent("//td[1][text()='疾病名称']/ancestor::*[contains(@class,'diy-xy-box')]").tableComponent().blockComponent(1,4).textComponent("新增").click();
|
|
55
|
+
await page.blockComponent("//td[1][text()='疾病名称']/ancestor::*[contains(@class,'diy-xy-box')]").tableComponent().blockComponent(3,1).selectComponent().select("肝炎");
|
|
56
|
+
await page.blockComponent("//td[1][text()='疾病名称']/ancestor::*[contains(@class,'diy-xy-box')]").tableComponent().blockComponent(3,2).inputComponent().inputSlowly("2022-11-11",Key.ENTER)
|
|
57
|
+
await page.blockComponent("//td[1][text()='疾病名称']/ancestor::*[contains(@class,'diy-xy-box')]").tableComponent().blockComponent(3,3).inputComponent().input("死亡");
|
|
58
|
+
await page.buttonComponent("取 消").click();
|
|
59
|
+
await page.switchToDefultFrame();
|
|
60
|
+
await page.dialogComponent("信息").buttonComponent("确定").click();
|
|
61
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nation": {
|
|
3
|
+
"url": "http://172.18.1.67:8081/rhm-configure/page/login/signIn.html",
|
|
4
|
+
"admin": {
|
|
5
|
+
"账号": "xibei",
|
|
6
|
+
"密码": "123456"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"maAnShan": {
|
|
10
|
+
"url": "http://172.18.1.13:7000/rhm-configure/page/login/signIn.html",
|
|
11
|
+
"admin": {
|
|
12
|
+
"账号": "大观",
|
|
13
|
+
"密码": "123456"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|