@winning-test/component 0.0.57 → 0.0.58
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@winning-test/component",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.58",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "",
|
|
6
6
|
"scripts": {
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/jest": "^29.5.
|
|
17
|
-
"@winning-test/autotest-webui": "^0.1.
|
|
18
|
-
"chromedriver": "^114.0.
|
|
19
|
-
"jest": "^29.
|
|
16
|
+
"@types/jest": "^29.5.3",
|
|
17
|
+
"@winning-test/autotest-webui": "^0.1.48",
|
|
18
|
+
"chromedriver": "^114.0.3",
|
|
19
|
+
"jest": "^29.6.1"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -7,38 +7,30 @@ class BlockComponent extends require("./Component") {
|
|
|
7
7
|
/**
|
|
8
8
|
* 块组件
|
|
9
9
|
* @param {Browser} browser 浏览器
|
|
10
|
-
* @param {String} id id
|
|
11
10
|
* @param {String} xpath xpath
|
|
12
11
|
*/
|
|
13
|
-
constructor(browser,
|
|
12
|
+
constructor(browser, xpath) {
|
|
14
13
|
super(browser);
|
|
15
|
-
this.id = id;
|
|
16
14
|
this.xpath = xpath;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
_createXpath() {
|
|
20
|
-
|
|
21
|
-
return `//*[@id='${this.id}']`
|
|
22
|
-
}
|
|
23
|
-
if (this.xpath) {
|
|
24
|
-
return this.xpath;
|
|
25
|
-
}
|
|
18
|
+
return this.xpath;
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
/**
|
|
29
22
|
* 获取块组件
|
|
30
|
-
* @param {String} id id
|
|
31
23
|
* @param {String} xpath xpath
|
|
32
24
|
* @returns 块组件
|
|
33
25
|
*/
|
|
34
|
-
blockComponent(
|
|
26
|
+
blockComponent(xpath) {
|
|
35
27
|
let that = this;
|
|
36
28
|
class _BlockComponent extends BlockComponent {
|
|
37
29
|
_createRootXpath() {
|
|
38
30
|
return that.getXpath();
|
|
39
31
|
}
|
|
40
32
|
}
|
|
41
|
-
return new _BlockComponent(this.browser,
|
|
33
|
+
return new _BlockComponent(this.browser, xpath);
|
|
42
34
|
}
|
|
43
35
|
|
|
44
36
|
/**
|
|
@@ -12,8 +12,20 @@ class TableComponent extends require("./Component") {
|
|
|
12
12
|
super(browser);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
_createRootXpath() {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
_createXpath() {
|
|
16
|
-
return "//table"
|
|
20
|
+
return "//table";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_createHeaderXapth() {
|
|
24
|
+
return "//thead";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_createBodyXapth() {
|
|
28
|
+
return "//tbody";
|
|
17
29
|
}
|
|
18
30
|
|
|
19
31
|
/**
|
|
@@ -22,17 +34,23 @@ class TableComponent extends require("./Component") {
|
|
|
22
34
|
*/
|
|
23
35
|
async getTableData() {
|
|
24
36
|
let ret = [];
|
|
25
|
-
let xpath = `(${this.getXpath()}//
|
|
26
|
-
await this.browser.
|
|
27
|
-
|
|
37
|
+
let xpath = `(${this.getXpath()}${this._createBodyXapth()}//tr)[1]`;
|
|
38
|
+
await this.browser.waitUntilElementBeVisible(xpath);
|
|
39
|
+
await this.browser.sleep(TableComponent.delayTime);
|
|
40
|
+
// 处理表头
|
|
41
|
+
if (!this._createHeaderXapth()) {
|
|
42
|
+
return ret;
|
|
43
|
+
}
|
|
44
|
+
xpath = `(${this.getXpath()}${this._createHeaderXapth()}//tr)[1]/th`;
|
|
28
45
|
let titles = await this.browser.findElements(xpath);
|
|
29
46
|
for (let i = 0; i < titles.length; i++) {
|
|
30
|
-
titles[i] = (await titles[i].getText(true)).trim()
|
|
47
|
+
titles[i] = (await titles[i].getText(true)).trim() || `#${String(i).padStart(3, "0")}`;
|
|
31
48
|
}
|
|
32
|
-
|
|
49
|
+
// 处理表体
|
|
50
|
+
xpath = `${this.getXpath()}${this._createBodyXapth()}//tr`;
|
|
33
51
|
let trs = await this.browser.findElements(xpath);
|
|
34
52
|
for (let i = 0; i < trs.length; i++) {
|
|
35
|
-
xpath = `(${this.getXpath()}//
|
|
53
|
+
xpath = `(${this.getXpath()}${this._createBodyXapth()}//tr)[${i + 1}]/td`;
|
|
36
54
|
let tds = await this.browser.findElements(xpath);
|
|
37
55
|
let row = {};
|
|
38
56
|
for (let j = 0; j < tds.length; j++) {
|
|
@@ -47,41 +65,6 @@ class TableComponent extends require("./Component") {
|
|
|
47
65
|
return ret;
|
|
48
66
|
}
|
|
49
67
|
|
|
50
|
-
/**
|
|
51
|
-
* 双击行
|
|
52
|
-
* @param {Number} rowNumber 行号
|
|
53
|
-
*/
|
|
54
|
-
async doubleClickRow(rowNumber) {
|
|
55
|
-
let xpath = `(${this.getXpath()}//tbody)[1]/tr[${rowNumber}]`;
|
|
56
|
-
await (await this.browser.findElement(xpath)).doubleClick();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 单击行
|
|
61
|
-
* @param {Number} rowNumber 行号
|
|
62
|
-
*/
|
|
63
|
-
async clickRow(rowNumber) {
|
|
64
|
-
let xpath = `(${this.getXpath()}//tbody)[1]/tr[${rowNumber}]`;
|
|
65
|
-
await (await this.browser.findElement(xpath)).click();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 选择所有行
|
|
70
|
-
*/
|
|
71
|
-
async selectAllRow() {
|
|
72
|
-
let xpath = `(${this.getXpath()}//thead)[1]/tr[1]/th[1]//input[@type='checkbox']`;
|
|
73
|
-
await (await this.browser.findElement(xpath)).click();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 选择行
|
|
78
|
-
* @param {Number} rowNumber 行号
|
|
79
|
-
*/
|
|
80
|
-
async selectRow(rowNumber) {
|
|
81
|
-
let xpath = `(${this.getXpath()}//tbody)[1]/tr[${rowNumber}]/td[1]//input[@type='checkbox']`;
|
|
82
|
-
await (await this.browser.findElement(xpath)).click();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
68
|
|
|
86
69
|
/**
|
|
87
70
|
* 获取块组件
|
|
@@ -96,12 +79,16 @@ class TableComponent extends require("./Component") {
|
|
|
96
79
|
return "";
|
|
97
80
|
}
|
|
98
81
|
_createXpath() {
|
|
99
|
-
|
|
82
|
+
if (columnNumber) {
|
|
83
|
+
return `(${that.getXpath()}${that._createBodyXapth()}//tr)[${rowNumber}]/td[${columnNumber}]`;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
return `(${that.getXpath()}${that._createBodyXapth()}//tr)[${rowNumber}]`;
|
|
87
|
+
}
|
|
100
88
|
}
|
|
101
89
|
}
|
|
102
|
-
return new _BlockComponent(this.browser, null
|
|
90
|
+
return new _BlockComponent(this.browser, null);
|
|
103
91
|
}
|
|
104
|
-
|
|
105
92
|
}
|
|
106
93
|
|
|
107
94
|
module.exports = TableComponent;
|
package/winex60/page/Page.js
CHANGED
|
@@ -28,12 +28,11 @@ class Page extends require("@winning-test/autotest-webui").Page {
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* 获取块组件
|
|
31
|
-
* @param {String} id id
|
|
32
31
|
* @param {String} xpath xpath
|
|
33
32
|
* @returns 块组件
|
|
34
33
|
*/
|
|
35
|
-
blockComponent(
|
|
36
|
-
return new BlockComponent(this.browser,
|
|
34
|
+
blockComponent(xpath) {
|
|
35
|
+
return new BlockComponent(this.browser, xpath);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
/**
|
|
@@ -10,46 +10,17 @@ beforeAll(async () => {
|
|
|
10
10
|
|
|
11
11
|
test("input/button/text", async () => {
|
|
12
12
|
const page = new Page(browser);
|
|
13
|
-
await page.inputComponent("在此键入您的工号/账号").input(config.user.
|
|
14
|
-
await page.inputComponent("请输入您的密码").input(config.user.
|
|
13
|
+
await page.inputComponent("在此键入您的工号/账号").input(config.user.doctor.用户名);
|
|
14
|
+
await page.inputComponent("请输入您的密码").input(config.user.doctor.密码);
|
|
15
|
+
await page.selectComponent("在此选择院区").select(config.user.doctor.院区);
|
|
16
|
+
await page.selectComponent("请选择系统").select(config.user.doctor.系统)
|
|
15
17
|
await page.buttonComponent("登录").click();
|
|
16
18
|
})
|
|
17
19
|
|
|
18
|
-
test
|
|
20
|
+
test("table", async () => {
|
|
19
21
|
const page = new Page(browser);
|
|
20
|
-
await page.blockComponent(
|
|
21
|
-
await page.textComponent("门诊医生站").click();
|
|
22
|
-
await page.dialogComponent("就诊科目").waitUntilBeVisible();
|
|
23
|
-
await page.dialogComponent("就诊科目").checkboxComponent("全选").select();
|
|
24
|
-
await page.dialogComponent("就诊科目").checkboxComponent("全选").unselect();
|
|
25
|
-
await page.dialogComponent("就诊科目").checkboxComponent("内科").select();
|
|
26
|
-
await page.dialogComponent("就诊科目").buttonComponent("确定").click();
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
test.skip("blockComponent/table/select/list", async () => {
|
|
30
|
-
const page = new Page(browser);
|
|
31
|
-
await page.textComponent("患者列表").click();
|
|
32
|
-
await page.blockComponent("header-search").waitUntilBeVisible();
|
|
33
|
-
const tableData = await page.blockComponent("header-search").tableComponent().getTableData();
|
|
22
|
+
const tableData = await page.blockComponent("//*[@class='table-box']").tableComponent().getTableData();
|
|
34
23
|
console.log(tableData);
|
|
35
|
-
await page.blockComponent("
|
|
24
|
+
await page.blockComponent("//*[@class='table-box']").tableComponent().blockComponent(2).doubleClick();
|
|
36
25
|
})
|
|
37
26
|
|
|
38
|
-
test.skip("switch", async () => {
|
|
39
|
-
const page = new Page(browser);
|
|
40
|
-
await page.blockComponent(null, "//*[@class='application-name']").click();
|
|
41
|
-
await page.textComponent("配置管理").click();
|
|
42
|
-
await page.blockComponent(null,"//*[@class='left-menu']").waitUntilBeVisible();
|
|
43
|
-
await page.blockComponent(null,"//*[@class='left-menu']").moveMouseTo();
|
|
44
|
-
await page.blockComponent(null,"//*[@class='left-menu']").textComponent("主数据").isDisplayed(3000)
|
|
45
|
-
await page.blockComponent(null,"//*[@class='left-menu']").textComponent("主数据").click();
|
|
46
|
-
await page.blockComponent(null,"//*[@class='left-menu']").textComponent("资源").isDisplayed(3000)
|
|
47
|
-
await page.blockComponent(null,"//*[@class='left-menu']").textComponent("资源").click();
|
|
48
|
-
await page.blockComponent(null,"//*[@class='left-menu']").textComponent("员工").isDisplayed(3000);
|
|
49
|
-
await page.blockComponent(null,"//*[@class='left-menu']").textComponent("员工").click();
|
|
50
|
-
await page.switchToFrame();
|
|
51
|
-
await page.buttonComponent("新建员工").click();
|
|
52
|
-
await page.switchComponent("员工状态").scrollIntoView();
|
|
53
|
-
await page.switchComponent("员工状态").off();
|
|
54
|
-
await page.switchComponent("员工状态").on();
|
|
55
|
-
})
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"url": "http://
|
|
2
|
+
"url": "http://101.34.221.139:85/portal/#/login",
|
|
3
3
|
"user": {
|
|
4
4
|
"admin": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"用户名": "6618",
|
|
6
|
+
"密码": "456"
|
|
7
7
|
},
|
|
8
8
|
"doctor": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"用户名": "6618",
|
|
10
|
+
"密码": "456",
|
|
11
|
+
"院区": "铜陵五院(RC1)",
|
|
12
|
+
"系统": "门诊医生站"
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
15
|
}
|