@winning-test/component 0.0.72 → 0.0.75

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