@winning-test/component 0.0.17 → 0.0.18
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/edis5.6/component/BlockComponent.js +217 -0
- package/edis5.6/component/ButtonComponent.js +23 -0
- package/edis5.6/component/CheckboxComponent.js +46 -0
- package/edis5.6/component/Component.js +84 -0
- package/edis5.6/component/DialogComponent.js +23 -0
- package/edis5.6/component/InputComponent.js +31 -0
- package/edis5.6/component/ListComponent.js +53 -0
- package/edis5.6/component/MessageComponent.js +23 -0
- package/edis5.6/component/RadioComponent.js +36 -0
- package/edis5.6/component/SelectComponent.js +72 -0
- package/edis5.6/component/SwitchComponent.js +47 -0
- package/edis5.6/component/TableComponent.js +72 -0
- package/edis5.6/component/TextComponent.js +23 -0
- package/edis5.6/component/TopMenuComponent.js +32 -0
- package/edis5.6/page/Page.js +170 -0
- package/edis5.6/test/component.test.js +62 -0
- package/edis5.6/test/component.test.json +9 -0
- package/package.json +2 -2
- package/rhm5.6/page/Page.js +8 -4
|
@@ -0,0 +1,217 @@
|
|
|
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} placeholder 背景文字
|
|
84
|
+
* @param {String} label 标签
|
|
85
|
+
* @returns 输入框组件
|
|
86
|
+
*/
|
|
87
|
+
inputComponent(placeholder, label) {
|
|
88
|
+
let that = this;
|
|
89
|
+
class InputComponent extends require("./InputComponent") {
|
|
90
|
+
_createRootXpath() {
|
|
91
|
+
return that.getXpath();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return new InputComponent(this.browser, placeholder, label);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 获取列表组件
|
|
99
|
+
* @returns 列表组件
|
|
100
|
+
*/
|
|
101
|
+
listComponent() {
|
|
102
|
+
let that = this;
|
|
103
|
+
class ListComponent extends require("./ListComponent") {
|
|
104
|
+
_createRootXpath() {
|
|
105
|
+
return that.getXpath();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return new ListComponent(this.browser);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 获取消息组件
|
|
113
|
+
* @param {Stirng} text 文本
|
|
114
|
+
* @returns 消息组件
|
|
115
|
+
*/
|
|
116
|
+
messageComponent(text) {
|
|
117
|
+
let that = this;
|
|
118
|
+
class MessageComponent extends require("./MessageComponent") {
|
|
119
|
+
_createRootXpath() {
|
|
120
|
+
return that.getXpath();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return new MessageComponent(this.browser, text);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 获取单选框组件
|
|
128
|
+
* @param {Stirng} label 标签
|
|
129
|
+
* @returns 单选框组件
|
|
130
|
+
*/
|
|
131
|
+
radioComponent(label) {
|
|
132
|
+
let that = this;
|
|
133
|
+
class RadioComponent extends require("./RadioComponent") {
|
|
134
|
+
_createRootXpath() {
|
|
135
|
+
return that.getXpath();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return new RadioComponent(this.browser, label);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 获取选择器组件
|
|
143
|
+
* @param {String} placeholder 背景文字
|
|
144
|
+
* @param {String} label 标签
|
|
145
|
+
* @returns 选择器组件
|
|
146
|
+
*/
|
|
147
|
+
selectComponent(placeholder, label) {
|
|
148
|
+
let that = this;
|
|
149
|
+
class SelectComponent extends require("./SelectComponent") {
|
|
150
|
+
_createRootXpath() {
|
|
151
|
+
return that.getXpath();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return new SelectComponent(this.browser, placeholder, label);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 获取开关组件
|
|
159
|
+
* @param {String} label 标签
|
|
160
|
+
* @returns 开关组件
|
|
161
|
+
*/
|
|
162
|
+
switchComponent(label) {
|
|
163
|
+
let that = this;
|
|
164
|
+
class SwitchComponent extends require("./SwitchComponent") {
|
|
165
|
+
_createRootXpath() {
|
|
166
|
+
return that.getXpath();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return new SwitchComponent(this.browser, label);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 获取表格组件
|
|
174
|
+
* @returns 表格组件
|
|
175
|
+
*/
|
|
176
|
+
tableComponent() {
|
|
177
|
+
let that = this;
|
|
178
|
+
class TableComponent extends require("./TableComponent") {
|
|
179
|
+
_createRootXpath() {
|
|
180
|
+
return that.getXpath();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return new TableComponent(this.browser);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 获取文本组件
|
|
188
|
+
* @param {String} text 文本
|
|
189
|
+
* @returns 文本组件
|
|
190
|
+
*/
|
|
191
|
+
textComponent(text) {
|
|
192
|
+
let that = this;
|
|
193
|
+
class TextComponent extends require("./TextComponent") {
|
|
194
|
+
_createRootXpath() {
|
|
195
|
+
return that.getXpath();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return new TextComponent(this.browser, text);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 获取顶部菜单组件
|
|
203
|
+
* @returns 顶部菜单组件
|
|
204
|
+
*/
|
|
205
|
+
topMenuComponent() {
|
|
206
|
+
let that = this;
|
|
207
|
+
class TopMenuComponent extends require("./TopMenuComponent") {
|
|
208
|
+
_createRootXpath() {
|
|
209
|
+
return that.getXpath();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return new TopMenuComponent(this.browser);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
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::button`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = ButtonComponent;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
if (this.label) {
|
|
19
|
+
return `//*[normalize-space(text())='${this.label}']/..//input[@type='checkbox']`;
|
|
20
|
+
}
|
|
21
|
+
return "//input[@type='checkbox']";
|
|
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
|
+
await this.browser.sleep(CheckboxComponent.delayTime);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 取消选择
|
|
36
|
+
*/
|
|
37
|
+
async unselect() {
|
|
38
|
+
if (await (await this.browser.findElement(this.getXpath())).isSelected()) {
|
|
39
|
+
await (await this.browser.findElement(this.getXpath())).click();
|
|
40
|
+
await this.browser.sleep(CheckboxComponent.delayTime);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = CheckboxComponent;
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
}
|
|
20
|
+
|
|
21
|
+
async click() {
|
|
22
|
+
await super.click();
|
|
23
|
+
await this.browser.sleep(Component.delayTime);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async doubleClick() {
|
|
27
|
+
await super.doubleClick();
|
|
28
|
+
await this.browser.sleep(Component.delayTime);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async input(...agrs) {
|
|
32
|
+
await super.input(...agrs);
|
|
33
|
+
await this.browser.sleep(Component.delayTime);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async clear() {
|
|
37
|
+
await super.clear();
|
|
38
|
+
await this.browser.sleep(Component.delayTime);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async getText() {
|
|
42
|
+
await this.browser.sleep(Component.delayTime);
|
|
43
|
+
return await super.getText();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async getValue() {
|
|
47
|
+
await this.browser.sleep(Component.delayTime);
|
|
48
|
+
return await super.getValue();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async getAttribute(attributeName) {
|
|
52
|
+
await this.browser.sleep(Component.delayTime);
|
|
53
|
+
return await super.getAttribute(attributeName);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async waitUntilBeDisabled() {
|
|
57
|
+
await super.waitUntilBeDisabled();
|
|
58
|
+
await this.browser.sleep(Component.delayTime);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async waitUntilBeEnabled() {
|
|
62
|
+
await super.waitUntilBeEnabled();
|
|
63
|
+
await this.browser.sleep(Component.delayTime);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async waitUntilBeNotVisible() {
|
|
67
|
+
await super.waitUntilBeNotVisible();
|
|
68
|
+
await this.browser.sleep(Component.delayTime);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async waitUntilBeVisible() {
|
|
72
|
+
await super.waitUntilBeVisible();
|
|
73
|
+
await this.browser.sleep(Component.delayTime);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 移动鼠标到组件
|
|
78
|
+
*/
|
|
79
|
+
async moveMouseTo() {
|
|
80
|
+
await this.browser.moveMouseTo(this.getXpath());
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
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);
|
|
14
|
+
this.title = title;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_createXpath() {
|
|
18
|
+
return `//*[contains(normalize-space(text()),'${this.title}')]/ancestor::*[@role='dialog']`;
|
|
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} placeholder 背景文字
|
|
11
|
+
* @param {String} label 标签
|
|
12
|
+
*/
|
|
13
|
+
constructor(browser, placeholder, label) {
|
|
14
|
+
super(browser);
|
|
15
|
+
this.placeholder = placeholder;
|
|
16
|
+
this.label = label;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_createXpath() {
|
|
20
|
+
if (this.placeholder) {
|
|
21
|
+
return `//input[@placeholder='${this.placeholder}']`;
|
|
22
|
+
}
|
|
23
|
+
if (this.label) {
|
|
24
|
+
return `//*[normalize-space(text())='${this.label}']/..//input`;
|
|
25
|
+
}
|
|
26
|
+
return "//input[@type='text']"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = InputComponent;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 列表组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class ListComponent extends require("./Component") {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 列表组件
|
|
9
|
+
* @param {Browser} browser 浏览器
|
|
10
|
+
*/
|
|
11
|
+
constructor(browser) {
|
|
12
|
+
super(browser);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_createXpath() {
|
|
16
|
+
return `//ul`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 选择列表
|
|
21
|
+
* @param {...String} items 列表项
|
|
22
|
+
*/
|
|
23
|
+
async select(...items) {
|
|
24
|
+
let xpath = `${this.getXpath()}`;
|
|
25
|
+
await (await this.browser.findElement(xpath)).waitUntilBeVisible();
|
|
26
|
+
for (let i = 0; i < items.length; i++) {
|
|
27
|
+
let item = items[i];
|
|
28
|
+
xpath = `${this.getXpath()}//*[normalize-space(text())='${item}']/ancestor-or-self::li`;
|
|
29
|
+
await (await this.browser.findElement(xpath)).waitUntilBeVisible();
|
|
30
|
+
await (await this.browser.findElement(xpath)).scrollIntoView();
|
|
31
|
+
await (await this.browser.findElement(xpath)).click();
|
|
32
|
+
await this.browser.sleep(ListComponent.delayTime);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 获取列表项
|
|
38
|
+
* @returns 列表项
|
|
39
|
+
*/
|
|
40
|
+
async getListItems() {
|
|
41
|
+
let ret = [];
|
|
42
|
+
let xpath = `${this.getXpath()}//li`;
|
|
43
|
+
let elements = await this.browser.findElements(xpath);
|
|
44
|
+
for (let i = 0; i < elements.length; i++) {
|
|
45
|
+
let element = elements[i];
|
|
46
|
+
ret.push(await element.getText(true));
|
|
47
|
+
}
|
|
48
|
+
return ret;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = ListComponent;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 消息组件类
|
|
3
|
+
* @作者 MaoJJ
|
|
4
|
+
*/
|
|
5
|
+
class MeaasgeComponent 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 `//*[contains(text(),'${this.text}')]/ancestor::*[contains(@class,'el-message ')]`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = MeaasgeComponent;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
await this.browser.sleep(RadioComponent.delayTime);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = RadioComponent;
|
|
@@ -0,0 +1,72 @@
|
|
|
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) {
|
|
14
|
+
super(browser);
|
|
15
|
+
this.placeholder = placeholder;
|
|
16
|
+
this.label = label;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_createXpath() {
|
|
20
|
+
if (this.placeholder) {
|
|
21
|
+
return `//input[@placeholder='${this.placeholder}']`;
|
|
22
|
+
}
|
|
23
|
+
if (this.label) {
|
|
24
|
+
return `//*[normalize-space(text())='${this.label}']/..//input`;
|
|
25
|
+
}
|
|
26
|
+
return "//input[@type='text']";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 选择选项
|
|
31
|
+
* @param {...String} items 选项
|
|
32
|
+
*/
|
|
33
|
+
async select(...items) {
|
|
34
|
+
let count = 5;
|
|
35
|
+
while (count > 0) {
|
|
36
|
+
try {
|
|
37
|
+
await this._select(...items);
|
|
38
|
+
if (items.length > 1){ // 多选不检查value
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
const value = await this.getValue();
|
|
42
|
+
if (!(value && items.join().indexOf(value) !== -1)) {
|
|
43
|
+
throw new Error(`选择${items}失败`);
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (count > 1) {
|
|
48
|
+
count--;
|
|
49
|
+
await this.browser.sleep(100);
|
|
50
|
+
} else {
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
await this.browser.sleep(SelectComponent.delayTime);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async _select(...items) {
|
|
59
|
+
const ListComponent = require("./ListComponent");
|
|
60
|
+
let xpath = this.getXpath();
|
|
61
|
+
await (await this.browser.findElement(xpath)).click();
|
|
62
|
+
let listComponent = new ListComponent(this.browser);
|
|
63
|
+
await listComponent.select(...items);
|
|
64
|
+
if (items.length > 1) {
|
|
65
|
+
xpath = this.getXpath();
|
|
66
|
+
await (await this.browser.findElement(xpath)).click();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = SelectComponent;
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
return `//*[normalize-space(text())='${this.label}']//input[@type='checkbox']`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 打开
|
|
23
|
+
*/
|
|
24
|
+
async on() {
|
|
25
|
+
let xpath = this.getXpath();
|
|
26
|
+
let checked = Boolean(await (await this.browser.findElement(xpath)).getAttribute("checked"));
|
|
27
|
+
if (!checked) {
|
|
28
|
+
await (await this.browser.findElement(xpath)).click();
|
|
29
|
+
await this.browser.sleep(SwitchComponent.delayTime);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 关闭
|
|
35
|
+
*/
|
|
36
|
+
async off() {
|
|
37
|
+
let xpath = this.getXpath();
|
|
38
|
+
let checked = Boolean(await (await this.browser.findElement(xpath)).getAttribute("checked"));
|
|
39
|
+
if (checked) {
|
|
40
|
+
await (await this.browser.findElement(xpath)).click();
|
|
41
|
+
await this.browser.sleep(SwitchComponent.delayTime);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = SwitchComponent;
|
|
@@ -0,0 +1,72 @@
|
|
|
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 "//*[contains(@class,'el-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
|
+
* @param {Number} rowNumber 行号
|
|
54
|
+
* @param {Number} columnNumber 列号
|
|
55
|
+
* @returns 块组件
|
|
56
|
+
*/
|
|
57
|
+
blockComponent(rowNumber, columnNumber) {
|
|
58
|
+
let that = this;
|
|
59
|
+
class _BlockComponent extends require("./BlockComponent") {
|
|
60
|
+
_createRootXpath() {
|
|
61
|
+
return "";
|
|
62
|
+
}
|
|
63
|
+
_createXpath() {
|
|
64
|
+
return `(${that.getXpath()}//tbody)[1]/tr[${rowNumber}]/td[${columnNumber}]`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return new _BlockComponent(this.browser, null, null);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
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,'head-content')]";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 选择菜单
|
|
21
|
+
* @param {String} menuItem 菜单项
|
|
22
|
+
*/
|
|
23
|
+
async select(menuItem) {
|
|
24
|
+
let xpath = `${this.getXpath()}//*[normalize-space(text())='${menuItem}']`;
|
|
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 ListComponent = require("../component/ListComponent");
|
|
7
|
+
const MessageComponent = require("../component/MessageComponent");
|
|
8
|
+
const RadioComponent = require("../component/RadioComponent");
|
|
9
|
+
const SelectComponent = require("../component/SelectComponent");
|
|
10
|
+
const SwitchComponent = require("../component/SwitchComponent");
|
|
11
|
+
const TopMenuComponent = require("../component/TopMenuComponent");
|
|
12
|
+
const TableComponent = require("../component/TableComponent");
|
|
13
|
+
const TextComponent = require("../component/TextComponent");
|
|
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} xpath xpath
|
|
31
|
+
* @returns 块组件
|
|
32
|
+
*/
|
|
33
|
+
blockComponent(xpath) {
|
|
34
|
+
return new BlockComponent(this.browser, xpath);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 获取按钮组件
|
|
39
|
+
* @param {String} text 文本
|
|
40
|
+
* @returns 按钮组件
|
|
41
|
+
*/
|
|
42
|
+
buttonComponent(text) {
|
|
43
|
+
return new ButtonComponent(this.browser, text);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 获取级联选择器组件
|
|
48
|
+
* @param {String} placeholder 背景文字
|
|
49
|
+
* @param {String} label 标签
|
|
50
|
+
* @returns 级联选择器组件
|
|
51
|
+
*/
|
|
52
|
+
cascaderComponent(placeholder, label) {
|
|
53
|
+
return new CascaderComponent(this.browser, placeholder, label);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 获取复选框组件
|
|
58
|
+
* @param {String} label 标签
|
|
59
|
+
* @returns 复选框组件
|
|
60
|
+
*/
|
|
61
|
+
checkboxComponent(label) {
|
|
62
|
+
return new CheckboxComponent(this.browser, label);
|
|
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
|
+
* @returns 列表组件
|
|
87
|
+
*/
|
|
88
|
+
listComponent() {
|
|
89
|
+
return new ListComponent(this.browser);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 获取消息组件
|
|
94
|
+
* @param {Stirng} text 文本
|
|
95
|
+
* @returns 消息组件
|
|
96
|
+
*/
|
|
97
|
+
messageComponent(text) {
|
|
98
|
+
return new MessageComponent(this.browser, text);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 获取单选框组件
|
|
103
|
+
* @param {Stirng} label 标签
|
|
104
|
+
* @returns 单选框组件
|
|
105
|
+
*/
|
|
106
|
+
radioComponent(label) {
|
|
107
|
+
return new RadioComponent(this.browser, label);
|
|
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 = "//*[contains(@class,'el-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,62 @@
|
|
|
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
|
+
|
|
12
|
+
test("登录", async () => {
|
|
13
|
+
const page = new Page(browser);
|
|
14
|
+
await page.inputComponent("账户").input(config.user.用户名);
|
|
15
|
+
await page.inputComponent("请输入密码").input(config.user.密码);
|
|
16
|
+
await page.buttonComponent("登录").click();
|
|
17
|
+
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test.skip("input/button/block/text/radio/checkbox", async () => {
|
|
21
|
+
const page = new Page(browser);
|
|
22
|
+
await page.textComponent("急诊医学管理软件").click();
|
|
23
|
+
await page.textComponent("预检系统").click();
|
|
24
|
+
await page.blockComponent("//*[@class='header__content']").textComponent("三无").click();
|
|
25
|
+
await page.textComponent("一键启动绿色通道").waitUntilBeVisible();
|
|
26
|
+
await page.blockComponent("//*[@class='header__content']").textComponent("建档").click();
|
|
27
|
+
await page.loading();
|
|
28
|
+
await page.messageComponent("His建档成功").waitUntilBeVisible();
|
|
29
|
+
await page.radioComponent("儿科").select();
|
|
30
|
+
await page.radioComponent("成人").select();
|
|
31
|
+
await page.checkboxComponent("测不出").select();
|
|
32
|
+
await page.checkboxComponent("测不出").unselect();
|
|
33
|
+
await page.inputComponent(null, "体温:").input("37");
|
|
34
|
+
await page.inputComponent(null, "脉搏:").input("100");
|
|
35
|
+
await page.inputComponent(null, "呼吸:").input("100");
|
|
36
|
+
await page.inputComponent(null, "血压:").input("111");
|
|
37
|
+
await page.inputComponent(null, "血压:").input("333");
|
|
38
|
+
await page.inputComponent(null, "血氧:").input("100");
|
|
39
|
+
await page.buttonComponent("提 交").click();
|
|
40
|
+
await page.loading();
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test.skip("topMenu/table", async () => {
|
|
44
|
+
const page = new Page(browser);
|
|
45
|
+
await page.textComponent("急诊医学管理软件").click();
|
|
46
|
+
await page.textComponent("预检系统").click();
|
|
47
|
+
await page.topMenuComponent().select("患者管理");
|
|
48
|
+
const tableData = await page.tableComponent().getTableData();
|
|
49
|
+
console.log(tableData);
|
|
50
|
+
await page.tableComponent().blockComponent(3,2).click();
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test("dialog/select/list", async () => {
|
|
54
|
+
const page = new Page(browser);
|
|
55
|
+
await page.textComponent("急诊医学管理软件").click();
|
|
56
|
+
await page.textComponent("护士站点").click();
|
|
57
|
+
await page.topMenuComponent().select("患者管理");
|
|
58
|
+
await page.loading();
|
|
59
|
+
await page.blockComponent("(//*[contains(@class,'bed ')])[1]").moveMouseTo();
|
|
60
|
+
await page.blockComponent("(//*[contains(@class,'bed ')])[1]").textComponent("编辑").click();
|
|
61
|
+
await page.dialogComponent("编辑").selectComponent(null, "护理组长").select("张护士");
|
|
62
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@winning-test/component",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@winning-test/autotest-webui": "^0.1.
|
|
16
|
+
"@winning-test/autotest-webui": "^0.1.38"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/jest": "^29.5.1",
|
package/rhm5.6/page/Page.js
CHANGED
|
@@ -134,10 +134,14 @@ class Page extends require("@winning-test/autotest-webui").Page {
|
|
|
134
134
|
* @param {Boolean} isSwitchToLeft 是否切换到左侧iframe
|
|
135
135
|
*/
|
|
136
136
|
async switchToActiveFrame(isSwitchToLeft = true) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
try {
|
|
138
|
+
await this.browser.switchToFrame();
|
|
139
|
+
await this.browser.switchToFrame("//iframe[@class='iframe-content active']");
|
|
140
|
+
if (isSwitchToLeft) {
|
|
141
|
+
await this.browser.switchToFrame("//iframe[@id='prmIframe']");
|
|
142
|
+
}
|
|
143
|
+
} catch (error) {
|
|
144
|
+
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
|