@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.
Files changed (53) hide show
  1. package/CustomSequencer.js +30 -0
  2. package/infusion60/component/BlockComponent.js +224 -0
  3. package/infusion60/component/ButtonComponent.js +23 -0
  4. package/infusion60/component/CheckboxComponent.js +46 -0
  5. package/infusion60/component/Component.js +78 -0
  6. package/infusion60/component/DialogComponent.js +23 -0
  7. package/infusion60/component/InputComponent.js +31 -0
  8. package/infusion60/component/LeftMenuComponent.js +38 -0
  9. package/infusion60/component/ListComponent.js +53 -0
  10. package/infusion60/component/MessageComponent.js +23 -0
  11. package/infusion60/component/SelectComponent.js +76 -0
  12. package/infusion60/component/SwitchComponent.js +47 -0
  13. package/infusion60/component/TableComponent.js +119 -0
  14. package/infusion60/component/TextComponent.js +23 -0
  15. package/infusion60/component/TopMenuComponent.js +32 -0
  16. package/infusion60/page/Page.js +170 -0
  17. package/infusion60/test/component.test.js +65 -0
  18. package/infusion60/test/component.test.json +12 -0
  19. package/jest.config.js +7 -0
  20. package/package.json +23 -0
  21. package/rhm5.6/component/BlockComponent.js +187 -0
  22. package/rhm5.6/component/ButtonComponent.js +23 -0
  23. package/rhm5.6/component/CheckboxComponent.js +53 -0
  24. package/rhm5.6/component/Component.js +95 -0
  25. package/rhm5.6/component/DialogComponent.js +23 -0
  26. package/rhm5.6/component/InputComponent.js +31 -0
  27. package/rhm5.6/component/LeftMenuComponent.js +35 -0
  28. package/rhm5.6/component/RadioComponent.js +35 -0
  29. package/rhm5.6/component/SelectComponent.js +45 -0
  30. package/rhm5.6/component/TableComponent.js +90 -0
  31. package/rhm5.6/component/TextComponent.js +23 -0
  32. package/rhm5.6/component/TopMenuComponent.js +34 -0
  33. package/rhm5.6/page/Page.js +143 -0
  34. package/rhm5.6/test/component.test.js +61 -0
  35. package/rhm5.6/test/component.test.json +16 -0
  36. package/winex60/component/BlockComponent.js +241 -0
  37. package/winex60/component/ButtonComponent.js +23 -0
  38. package/winex60/component/CascaderComponent.js +51 -0
  39. package/winex60/component/CheckboxComponent.js +46 -0
  40. package/winex60/component/Component.js +78 -0
  41. package/winex60/component/DialogComponent.js +234 -0
  42. package/winex60/component/InputComponent.js +31 -0
  43. package/winex60/component/LeftMenuComponent.js +78 -0
  44. package/winex60/component/ListComponent.js +52 -0
  45. package/winex60/component/MessageComponent.js +57 -0
  46. package/winex60/component/RadioComponent.js +41 -0
  47. package/winex60/component/SelectComponent.js +73 -0
  48. package/winex60/component/SwitchComponent.js +45 -0
  49. package/winex60/component/TableComponent.js +107 -0
  50. package/winex60/component/TextComponent.js +23 -0
  51. package/winex60/page/Page.js +158 -0
  52. package/winex60/test/component.test.js +36 -0
  53. package/winex60/test/select.test.js +26 -0
@@ -0,0 +1,241 @@
1
+ /**
2
+ * 块组件类
3
+ * @作者 MaoJJ
4
+ */
5
+ class BlockComponent extends require("./Component") {
6
+
7
+ /**
8
+ * 块组件
9
+ * @param {Browser} browser 浏览器
10
+ * @param {String} id id
11
+ * @param {String} xpath xpath
12
+ */
13
+ constructor(browser, id, xpath) {
14
+ super(browser);
15
+ this.id = id;
16
+ this.xpath = xpath;
17
+ }
18
+
19
+ _createXpath() {
20
+ if (this.id) {
21
+ return `//*[@id='${this.id}']`
22
+ }
23
+ if (this.xpath) {
24
+ return this.xpath;
25
+ }
26
+ }
27
+
28
+ /**
29
+ * 获取块组件
30
+ * @param {String} id id
31
+ * @param {String} xpath xpath
32
+ * @returns 块组件
33
+ */
34
+ blockComponent(id, xpath) {
35
+ let that = this;
36
+ class _BlockComponent extends BlockComponent {
37
+ _createRootXpath() {
38
+ return that.getXpath();
39
+ }
40
+ }
41
+ return new _BlockComponent(this.browser, id, xpath);
42
+ }
43
+
44
+ /**
45
+ * 获取按钮组件
46
+ * @param {String} text 文本
47
+ * @returns 按钮组件
48
+ */
49
+ buttonComponent(text) {
50
+ let that = this;
51
+ class ButtonComponent extends require("./ButtonComponent") {
52
+ _createRootXpath() {
53
+ return that.getXpath();
54
+ }
55
+ }
56
+ return new ButtonComponent(this.browser, text);
57
+ }
58
+
59
+ /**
60
+ * 获取级联选择器组件
61
+ * @param {String} placeholder 背景文字
62
+ * @param {String} label 标签
63
+ * @returns 级联选择器组件
64
+ */
65
+ cascaderComponent(placeholder, label) {
66
+ let that = this;
67
+ class CascaderComponent extends require("./CascaderComponent") {
68
+ _createRootXpath() {
69
+ return that.getXpath();
70
+ }
71
+ }
72
+ return new CascaderComponent(this.browser, placeholder, label);
73
+ }
74
+
75
+ /**
76
+ * 获取复选框组件
77
+ * @param {String} label 标签
78
+ * @returns 复选框组件
79
+ */
80
+ checkboxComponent(label) {
81
+ let that = this;
82
+ class CheckboxComponent extends require("./CheckboxComponent") {
83
+ _createRootXpath() {
84
+ return that.getXpath();
85
+ }
86
+ }
87
+ return new CheckboxComponent(this.browser, label);
88
+ }
89
+
90
+ /**
91
+ * 获取对话框组件
92
+ * @param {String} title 标题
93
+ * @returns 对话框组件
94
+ */
95
+ dialogComponent(title) {
96
+ let that = this;
97
+ class DialogComponent extends require("./DialogComponent") {
98
+ _createRootXpath() {
99
+ return that.getXpath();
100
+ }
101
+ }
102
+ return new DialogComponent(this.browser, title);
103
+ }
104
+
105
+ /**
106
+ * 获取输入框组件
107
+ * @param {String} placeholder 背景文字
108
+ * @param {String} label 标签
109
+ * @returns 输入框组件
110
+ */
111
+ inputComponent(placeholder, label) {
112
+ let that = this;
113
+ class InputComponent extends require("./InputComponent") {
114
+ _createRootXpath() {
115
+ return that.getXpath();
116
+ }
117
+ }
118
+ return new InputComponent(this.browser, placeholder, label);
119
+ }
120
+
121
+ /**
122
+ * 获取左侧菜单组件
123
+ * @returns 左侧菜单组件
124
+ */
125
+ leftMenuComponent() {
126
+ let that = this;
127
+ class LeftMenuComponent extends require("./LeftMenuComponent") {
128
+ _createRootXpath() {
129
+ return that.getXpath();
130
+ }
131
+ }
132
+ return new LeftMenuComponent(this.browser);
133
+ }
134
+
135
+ /**
136
+ * 获取列表组件
137
+ * @returns 列表组件
138
+ */
139
+ listComponent() {
140
+ let that = this;
141
+ class ListComponent extends require("./ListComponent") {
142
+ _createRootXpath() {
143
+ return that.getXpath();
144
+ }
145
+ }
146
+ return new ListComponent(this.browser);
147
+ }
148
+
149
+ /**
150
+ * 获取消息组件
151
+ * @param {Stirng} text 文本
152
+ * @returns 消息组件
153
+ */
154
+ messageComponent(text) {
155
+ let that = this;
156
+ class MessageComponent extends require("./MessageComponent") {
157
+ _createRootXpath() {
158
+ return that.getXpath();
159
+ }
160
+ }
161
+ return new MessageComponent(this.browser, text);
162
+ }
163
+
164
+ /**
165
+ * 获取单选框组件
166
+ * @param {Stirng} label 标签
167
+ * @returns 单选框组件
168
+ */
169
+ radioComponent(label) {
170
+ let that = this;
171
+ class RadioComponent extends require("./RadioComponent") {
172
+ _createRootXpath() {
173
+ return that.getXpath();
174
+ }
175
+ }
176
+ return new RadioComponent(this.browser, label);
177
+ }
178
+
179
+ /**
180
+ * 获取选择器组件
181
+ * @param {String} placeholder 背景文字
182
+ * @param {String} label 标签
183
+ * @returns 选择器组件
184
+ */
185
+ selectComponent(placeholder, label) {
186
+ let that = this;
187
+ class SelectComponent extends require("./SelectComponent") {
188
+ _createRootXpath() {
189
+ return that.getXpath();
190
+ }
191
+ }
192
+ return new SelectComponent(this.browser, placeholder, label);
193
+ }
194
+
195
+ /**
196
+ * 获取开关组件
197
+ * @param {String} label 标签
198
+ * @returns 开关组件
199
+ */
200
+ switchComponent(label) {
201
+ let that = this;
202
+ class SwitchComponent extends require("./SwitchComponent") {
203
+ _createRootXpath() {
204
+ return that.getXpath();
205
+ }
206
+ }
207
+ return new SwitchComponent(this.browser, label);
208
+ }
209
+
210
+ /**
211
+ * 获取表格组件
212
+ * @returns 表格组件
213
+ */
214
+ tableComponent() {
215
+ let that = this;
216
+ class TableComponent extends require("./TableComponent") {
217
+ _createRootXpath() {
218
+ return that.getXpath();
219
+ }
220
+ }
221
+ return new TableComponent(this.browser);
222
+ }
223
+
224
+ /**
225
+ * 获取文本组件
226
+ * @param {String} text 文本
227
+ * @returns 文本组件
228
+ */
229
+ textComponent(text) {
230
+ let that = this;
231
+ class TextComponent extends require("./TextComponent") {
232
+ _createRootXpath() {
233
+ return that.getXpath();
234
+ }
235
+ }
236
+ return new TextComponent(this.browser, text);
237
+ }
238
+
239
+ }
240
+
241
+ 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,51 @@
1
+ /**
2
+ * 级联选择器组件类
3
+ * @作者 MaoJJ
4
+ */
5
+ class CascaderComponent 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
+ }
27
+
28
+ /**
29
+ * 选择
30
+ * @param {...String} items 选项
31
+ */
32
+ async select(...items) {
33
+ class ListComponent extends require("./ListComponent") {
34
+ _createXpath() {
35
+ return "//*[contains(@class,'el-scrollbar')]//ul"
36
+ }
37
+ }
38
+ let xpath = this.getXpath();
39
+ await (await this.browser.findElement(xpath)).click();
40
+ let listComponent = new ListComponent(this.browser);
41
+ await listComponent.waitUntilBeVisible();
42
+ for (let i = 0; i < items.length; i++) {
43
+ let item = items[i];
44
+ let listComponent = new ListComponent(this.browser);
45
+ await listComponent.select(item);
46
+ }
47
+ }
48
+
49
+ }
50
+
51
+ module.exports = CascaderComponent;
@@ -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}']/ancestor-or-self::label//input[@type='checkbox']`;
20
+ }
21
+ else {
22
+ return "//input[@type='checkbox']";
23
+ }
24
+ }
25
+
26
+ /**
27
+ * 选择
28
+ */
29
+ async select() {
30
+ if (!(await (await this.browser.findElement(this.getXpath())).isSelected())) {
31
+ await (await this.browser.findElement(this.getXpath())).click();
32
+ }
33
+ }
34
+
35
+ /**
36
+ * 取消选择
37
+ */
38
+ async unselect() {
39
+ if (await (await this.browser.findElement(this.getXpath())).isSelected()) {
40
+ await (await this.browser.findElement(this.getXpath())).click();
41
+ }
42
+ }
43
+
44
+ }
45
+
46
+ module.exports = CheckboxComponent;
@@ -0,0 +1,78 @@
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
+
52
+ async getAttribute(attributeName) {
53
+ await this.browser.sleep(Component.delayTime);
54
+ return await super.getAttribute(attributeName);
55
+ }
56
+
57
+ async waitUntilBeDisabled() {
58
+ await super.waitUntilBeDisabled();
59
+ await this.browser.sleep(Component.delayTime);
60
+ }
61
+
62
+ async waitUntilBeEnabled() {
63
+ await super.waitUntilBeEnabled();
64
+ await this.browser.sleep(Component.delayTime);
65
+ }
66
+
67
+ async waitUntilBeNotVisible() {
68
+ await super.waitUntilBeNotVisible();
69
+ await this.browser.sleep(Component.delayTime);
70
+ }
71
+
72
+ async waitUntilBeVisible() {
73
+ await super.waitUntilBeVisible();
74
+ await this.browser.sleep(Component.delayTime);
75
+ }
76
+ }
77
+
78
+ module.exports = Component;
@@ -0,0 +1,234 @@
1
+ /**
2
+ * 对话框组件类
3
+ * @作者 MaoJJ
4
+ */
5
+ class DialogComponent extends require("./Component") {
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
+ * @param {String} id id
24
+ * @param {String} xpath xpath
25
+ * @returns 块组件
26
+ */
27
+ blockComponent(id, xpath) {
28
+ let that = this;
29
+ class BlockComponent extends require("./BlockComponent") {
30
+ _createRootXpath() {
31
+ return that.getXpath();
32
+ }
33
+ }
34
+ return new BlockComponent(this.browser, id, xpath);
35
+ }
36
+
37
+ /**
38
+ * 获取按钮组件
39
+ * @param {String} text 文本
40
+ * @returns 按钮组件
41
+ */
42
+ buttonComponent(text) {
43
+ let that = this;
44
+ class ButtonComponent extends require("./ButtonComponent") {
45
+ _createRootXpath() {
46
+ return that.getXpath();
47
+ }
48
+ }
49
+ return new ButtonComponent(this.browser, text);
50
+ }
51
+
52
+ /**
53
+ * 获取级联选择器组件
54
+ * @param {String} placeholder 背景文字
55
+ * @param {String} label 标签
56
+ * @returns 级联选择器组件
57
+ */
58
+ cascaderComponent(placeholder, label) {
59
+ let that = this;
60
+ class CascaderComponent extends require("./CascaderComponent") {
61
+ _createRootXpath() {
62
+ return that.getXpath();
63
+ }
64
+ }
65
+ return new CascaderComponent(this.browser, placeholder, label);
66
+ }
67
+
68
+ /**
69
+ * 获取复选框组件
70
+ * @param {String} text 文本
71
+ * @returns 复选框组件
72
+ */
73
+ checkboxComponent(text) {
74
+ let that = this;
75
+ class CheckboxComponent extends require("./CheckboxComponent") {
76
+ _createRootXpath() {
77
+ return that.getXpath();
78
+ }
79
+ }
80
+ return new CheckboxComponent(this.browser, text);
81
+ }
82
+
83
+ /**
84
+ * 获取对话框组件
85
+ * @param {String} title 标题
86
+ * @returns 对话框组件
87
+ */
88
+ dialogComponent(title) {
89
+ let that = this;
90
+ class DialogComponent extends require("./DialogComponent") {
91
+ _createRootXpath() {
92
+ return that.getXpath();
93
+ }
94
+ }
95
+ return new DialogComponent(this.browser, title);
96
+ }
97
+
98
+ /**
99
+ * 获取输入框组件
100
+ * @param {String} placeholder 背景文字
101
+ * @param {String} label 标签
102
+ * @returns 输入框组件
103
+ */
104
+ inputComponent(placeholder, label) {
105
+ let that = this;
106
+ class InputComponent extends require("./InputComponent") {
107
+ _createRootXpath() {
108
+ return that.getXpath();
109
+ }
110
+ }
111
+ return new InputComponent(this.browser, placeholder, label);
112
+ }
113
+
114
+ /**
115
+ * 获取左侧菜单组件
116
+ * @returns 左侧菜单组件
117
+ */
118
+ leftMenuComponent() {
119
+ let that = this;
120
+ class LeftMenuComponent extends require("./LeftMenuComponent") {
121
+ _createRootXpath() {
122
+ return that.getXpath();
123
+ }
124
+ }
125
+ return new LeftMenuComponent(this.browser);
126
+ }
127
+
128
+ /**
129
+ * 获取列表组件
130
+ * @returns 列表组件
131
+ */
132
+ listComponent() {
133
+ let that = this;
134
+ class ListComponent extends require("./ListComponent") {
135
+ _createRootXpath() {
136
+ return that.getXpath();
137
+ }
138
+ }
139
+ return new ListComponent(this.browser);
140
+ }
141
+
142
+ /**
143
+ * 获取消息组件
144
+ * @param {Stirng} text 文本
145
+ * @returns 消息组件
146
+ */
147
+ messageComponent(text) {
148
+ let that = this;
149
+ class MessageComponent extends require("./MessageComponent") {
150
+ _createRootXpath() {
151
+ return that.getXpath();
152
+ }
153
+ }
154
+ return new MessageComponent(this.browser, text);
155
+ }
156
+
157
+ /**
158
+ * 获取单选框组件
159
+ * @param {Stirng} label 标签
160
+ * @returns 单选框组件
161
+ */
162
+ radioComponent(label) {
163
+ let that = this;
164
+ class RadioComponent extends require("./RadioComponent") {
165
+ _createRootXpath() {
166
+ return that.getXpath();
167
+ }
168
+ }
169
+ return new RadioComponent(this.browser, label);
170
+ }
171
+
172
+ /**
173
+ * 获取选择器组件
174
+ * @param {String} placeholder 背景文字
175
+ * @param {String} label 标签
176
+ * @returns 选择器组件
177
+ */
178
+ selectComponent(placeholder, label) {
179
+ let that = this;
180
+ class SelectComponent extends require("./SelectComponent") {
181
+ _createRootXpath() {
182
+ return that.getXpath();
183
+ }
184
+ }
185
+ return new SelectComponent(this.browser, placeholder, label);
186
+ }
187
+
188
+ /**
189
+ * 获取开关组件
190
+ * @param {String} label 标签
191
+ * @returns 开关组件
192
+ */
193
+ switchComponent(label) {
194
+ let that = this;
195
+ class SwitchComponent extends require("./SwitchComponent") {
196
+ _createRootXpath() {
197
+ return that.getXpath();
198
+ }
199
+ }
200
+ return new SwitchComponent(this.browser, label);
201
+ }
202
+
203
+ /**
204
+ * 获取表格组件
205
+ * @returns 表格组件
206
+ */
207
+ tableComponent() {
208
+ let that = this;
209
+ class TableComponent extends require("./TableComponent") {
210
+ _createRootXpath() {
211
+ return that.getXpath();
212
+ }
213
+ }
214
+ return new TableComponent(this.browser);
215
+ }
216
+
217
+ /**
218
+ * 获取文本组件
219
+ * @param {String} text 文本
220
+ * @returns 文本组件
221
+ */
222
+ textComponent(text) {
223
+ let that = this;
224
+ class TextComponent extends require("./TextComponent") {
225
+ _createRootXpath() {
226
+ return that.getXpath();
227
+ }
228
+ }
229
+ return new TextComponent(this.browser, text);
230
+ }
231
+
232
+ }
233
+
234
+ 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;