@winning-test/component 0.0.101 → 0.0.103

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 (34) hide show
  1. package/TechBookCenter/component/BlockComponent.js +173 -0
  2. package/TechBookCenter/component/ButtonComponent.js +26 -0
  3. package/TechBookCenter/component/CheckboxComponent.js +46 -0
  4. package/TechBookCenter/component/Component.js +109 -0
  5. package/TechBookCenter/component/DialogComponent.js +26 -0
  6. package/TechBookCenter/component/InputComponent.js +31 -0
  7. package/TechBookCenter/component/MenuComponent.js +36 -0
  8. package/TechBookCenter/component/MessageComponent.js +87 -0
  9. package/TechBookCenter/component/RadioComponent.js +41 -0
  10. package/TechBookCenter/component/SelectComponent.js +43 -0
  11. package/TechBookCenter/component/TableComponent.js +113 -0
  12. package/TechBookCenter/component/TextComponent.js +23 -0
  13. package/TechBookCenter/page/Page.js +172 -0
  14. package/package.json +1 -1
  15. package/rfds5.6/component/BlockComponent.js +248 -0
  16. package/rfds5.6/component/ButtonComponent.js +23 -0
  17. package/rfds5.6/component/CanvasComponent.js +36 -0
  18. package/rfds5.6/component/CheckboxComponent.js +53 -0
  19. package/rfds5.6/component/Component.js +93 -0
  20. package/rfds5.6/component/DialogComponent.js +23 -0
  21. package/rfds5.6/component/InputComponent.js +31 -0
  22. package/rfds5.6/component/ListComponent.js +53 -0
  23. package/rfds5.6/component/ListCompositeComponent.js +93 -0
  24. package/rfds5.6/component/MessageComponent.js +23 -0
  25. package/rfds5.6/component/RadioComponent.js +44 -0
  26. package/rfds5.6/component/SelectComponent.js +77 -0
  27. package/rfds5.6/component/SelectCompositeComponent.js +47 -0
  28. package/rfds5.6/component/SwitchComponent.js +50 -0
  29. package/rfds5.6/component/TableComponent.js +113 -0
  30. package/rfds5.6/component/TextComponent.js +23 -0
  31. package/rfds5.6/component/TextareaComponent.js +27 -0
  32. package/rfds5.6/page/Page.js +238 -0
  33. package/rfds5.6/test/component.test.js +64 -0
  34. package/rfds5.6/test/component.test.json +13 -0
@@ -0,0 +1,173 @@
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} label 标签
84
+ * @param {String} placeholder 背景文字
85
+ * @returns 输入框组件
86
+ */
87
+ inputComponent(label, placeholder) {
88
+ let that = this;
89
+ class InputComponent extends require("./InputComponent") {
90
+ _createRootXpath() {
91
+ return that.getXpath();
92
+ }
93
+ }
94
+ return new InputComponent(this.browser, label, placeholder);
95
+ }
96
+
97
+ /**
98
+ * 获取菜单组件
99
+ * @returns 菜单组件
100
+ */
101
+ menuComponent() {
102
+ let that = this;
103
+ class MenuComponent extends require("./MenuComponent") {
104
+ _createRootXpath() {
105
+ return that.getXpath();
106
+ }
107
+ }
108
+ return new MenuComponent(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 {String} label 标签
129
+ * @param {String} placeholder 背景文字
130
+ * @returns 选择器组件
131
+ */
132
+ selectComponent(label, placeholder) {
133
+ let that = this;
134
+ class SelectComponent extends require("./SelectComponent") {
135
+ _createRootXpath() {
136
+ return that.getXpath();
137
+ }
138
+ }
139
+ return new SelectComponent(this.browser, label, placeholder);
140
+ }
141
+
142
+ /**
143
+ * 获取表格组件
144
+ * @returns 表格组件
145
+ */
146
+ tableComponent() {
147
+ let that = this;
148
+ class TableComponent extends require("./TableComponent") {
149
+ _createRootXpath() {
150
+ return that.getXpath();
151
+ }
152
+ }
153
+ return new TableComponent(this.browser);
154
+ }
155
+
156
+ /**
157
+ * 获取文本组件
158
+ * @param {String} text 文本
159
+ * @returns 文本组件
160
+ */
161
+ textComponent(text) {
162
+ let that = this;
163
+ class TextComponent extends require("./TextComponent") {
164
+ _createRootXpath() {
165
+ return that.getXpath();
166
+ }
167
+ }
168
+ return new TextComponent(this.browser, text);
169
+ }
170
+
171
+ }
172
+
173
+ module.exports = BlockComponent;
@@ -0,0 +1,26 @@
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
+ if (this.text){
19
+ return `//*[normalize-space(text())='${this.text}']/ancestor-or-self::button`;
20
+ }
21
+ return "//*[@type='button']";
22
+ }
23
+
24
+ }
25
+
26
+ 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}']/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,109 @@
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
+ async isEnabled() {
78
+ return await super.isEnabled();
79
+ }
80
+
81
+ /**
82
+ * 鼠标移动到组件后悬停
83
+ */
84
+ async moveMouseTo() {
85
+ await this.browser.moveMouseTo(this.getXpath());
86
+ await this.browser.sleep(Component.delayTime);
87
+ }
88
+
89
+ /**
90
+ * 滚动页面到元素位置
91
+ */
92
+ async scrollIntoView() {
93
+ (await this.browser.findElement(this.getXpath())).scrollIntoView();
94
+ }
95
+
96
+ /**
97
+ * 右击
98
+ */
99
+ async contextClick() {
100
+ const { By, until } = require("selenium-webdriver");
101
+ const xpath = this.getXpath();
102
+ await this.browser.webDriver.wait(until.elementLocated(By.xpath(xpath)), this.browser.config.timeout);
103
+ let actions = this.browser.webDriver.actions();
104
+ actions.contextClick(await this.browser.webDriver.findElement(By.xpath(xpath)))
105
+ await actions.perform();
106
+ }
107
+ }
108
+
109
+ 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::*[contains(@class,'el-dialog')]`;
20
+ }
21
+ return `//*[contains(@class,'el-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} label 标签
11
+ * @param {String} placeholder 背景文字
12
+ */
13
+ constructor(browser, label, placeholder) {
14
+ super(browser);
15
+ this.label = label;
16
+ this.placeholder = placeholder;
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,36 @@
1
+ /**
2
+ * 菜单组件类
3
+ * @作者 MaoJJ
4
+ */
5
+ class MenuComponent 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,'menuListBtn')]";
17
+ }
18
+
19
+ /**
20
+ * 选择菜单
21
+ * @param {String} firstMenuItem 一级菜单
22
+ * @param {String} secondMenuItem 二级菜单
23
+ */
24
+ async select(firstMenuItem, secondMenuItem) {
25
+ await this.browser.switchToFrame();
26
+ let xpath = this.getXpath();
27
+ await (await this.browser.findElement(xpath)).click();
28
+ xpath = `//*[contains(@class,'menuListBox')]//*[text()='${firstMenuItem}']/..//*[text()='${secondMenuItem}']`;
29
+ await (await this.browser.findElement(xpath)).click();
30
+ xpath = "//iframe[not (@style='display: none;')]";
31
+ await this.browser.switchToFrame(xpath)
32
+ }
33
+
34
+ }
35
+
36
+ module.exports = MenuComponent;
@@ -0,0 +1,87 @@
1
+ /**
2
+ * 消息组件类
3
+ * @作者: MaoJJ
4
+ */
5
+ class MessageComponent extends require("./Component") {
6
+
7
+ /**
8
+ * 消息组件
9
+ * @param {Browser} browser 浏览器
10
+ * @param {String} text 消息内容
11
+ * @param {Boolean} iframe 是否在iframe内
12
+ */
13
+ constructor(browser, text, iframe = false) {
14
+ super(browser)
15
+ this.text = text;
16
+ this.iframe = iframe;
17
+ }
18
+
19
+ _createXpath() {
20
+ return `//*[contains(normalize-space(text()),'${this.text}')]/ancestor-or-self::*[contains(@class,'el-message')]`;
21
+ }
22
+
23
+ /**
24
+ * 获取消息内容
25
+ * @returns 消息内容
26
+ */
27
+ async getText() {
28
+ if (!this.iframe) {
29
+ await this.browser.switchToFrame();
30
+ }
31
+ let xpath = this.getXpath();
32
+ let text = await (await this.browser.findElement(xpath)).getText();
33
+ if (!this.iframe) {
34
+ xpath = "//iframe[not (@style='display: none;')]";
35
+ await this.browser.switchToFrame(xpath)
36
+ }
37
+ return text;
38
+ }
39
+
40
+ /**
41
+ * 等待出现
42
+ */
43
+ async waitUntilBeVisible() {
44
+ if (!this.iframe) {
45
+ await this.browser.switchToFrame();
46
+ }
47
+ let xpath = this.getXpath();
48
+ await this.browser.waitUntilElementBeVisible(xpath);
49
+ if (!this.iframe) {
50
+ xpath = "//iframe[not (@style='display: none;')]";
51
+ await this.browser.switchToFrame(xpath);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * 等待消失
57
+ */
58
+ async waitUntilBeNotVisible() {
59
+ if (!this.iframe) {
60
+ await this.browser.switchToFrame();
61
+ }
62
+ let xpath = this.getXpath();
63
+ await this.browser.waitUntilElementBeNotVisible(xpath);
64
+ if (!this.iframe) {
65
+ xpath = "//iframe[not (@style='display: none;')]";
66
+ await this.browser.switchToFrame(xpath);
67
+ }
68
+ }
69
+
70
+ /**
71
+ * 关闭
72
+ */
73
+ async close() {
74
+ if (!this.iframe) {
75
+ await this.browser.switchToFrame();
76
+ }
77
+ let xpath = `${this.getXpath()}//i[contains(@class,'el-message__closeBtn')]`;
78
+ await (await this.browser.findElement(xpath)).click();
79
+ if (!this.iframe) {
80
+ xpath = "//iframe[not (@style='display: none;')]";
81
+ await this.browser.switchToFrame(xpath);
82
+ }
83
+ }
84
+
85
+ }
86
+
87
+ module.exports = MessageComponent;
@@ -0,0 +1,41 @@
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 `//*[normalize-space(text())='${this.label}']/ancestor-or-self::label//input[@type='radio']`;
19
+ }
20
+
21
+ /**
22
+ * 选择
23
+ */
24
+ async select() {
25
+ if (!(await (await this.browser.findElement(this.getXpath())).isSelected())) {
26
+ await (await this.browser.findElement(this.getXpath())).click();
27
+ }
28
+ }
29
+
30
+ /**
31
+ * 取消选择
32
+ */
33
+ async unselect() {
34
+ if (await (await this.browser.findElement(this.getXpath())).isSelected()) {
35
+ await (await this.browser.findElement(this.getXpath())).click();
36
+ }
37
+ }
38
+
39
+ }
40
+
41
+ module.exports = RadioComponent;
@@ -0,0 +1,43 @@
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} placeholder 背景文字
12
+ */
13
+ constructor(browser, label,placeholder) {
14
+ super(browser);
15
+ this.label = label;
16
+ this.placeholder = placeholder;
17
+ }
18
+
19
+ _createXpath() {
20
+ if (this.label) {
21
+ return `//*[normalize-space(text())='${this.label}']/../..//input`;
22
+ }
23
+ if (this.placeholder) {
24
+ return `//input[@placeholder='${this.placeholder}']`;
25
+ }
26
+ return "//input[@type='text']";
27
+ }
28
+
29
+ async select(...items) {
30
+ let xpath = this.getXpath();
31
+ await (await this.browser.findElement(xpath)).click();
32
+ xpath = "//*[@class='el-autocomplete-suggestion' and not (contains(@style,'display: none'))]";
33
+ await this.browser.waitUntilElementBeVisible(xpath);
34
+ for (let i = 0; i < items.length; i++) {
35
+ let item = items[i];
36
+ xpath = `//*[@class='el-autocomplete-suggestion' and not (contains(@style,'display: none'))]//*[contains(text(),'${item}')]/ancestor::li`;
37
+ await (await this.browser.findElement(xpath)).click();
38
+ }
39
+ }
40
+
41
+ }
42
+
43
+ module.exports = SelectComponent;