@winning-test/component 0.0.87 → 0.0.89
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.
|
@@ -16,7 +16,7 @@ class ButtonComponent extends require("./Component") {
|
|
|
16
16
|
|
|
17
17
|
_createXpath() {
|
|
18
18
|
if (this.text){
|
|
19
|
-
return `//*[normalize-space(text())='${this.text}'
|
|
19
|
+
return `//*[normalize-space(text())='${this.text}']/ancestor-or-self::button`;
|
|
20
20
|
}
|
|
21
21
|
return "//*[@type='button']";
|
|
22
22
|
}
|
|
@@ -15,39 +15,29 @@ class CheckboxComponent extends require("./Component") {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
_createXpath() {
|
|
18
|
-
if (this.label)
|
|
19
|
-
return `//*[normalize-space(text())='${this.label}']
|
|
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']";
|
|
20
23
|
}
|
|
21
|
-
return "//*[@class='el-checkbox']";
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {...String} items 选项
|
|
27
|
+
* 选择
|
|
27
28
|
*/
|
|
28
|
-
async select(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
let item = items[i];
|
|
32
|
-
xpath = `${this.getXpath()}//*[text()='${item}']/..//input`;
|
|
33
|
-
if (!(await (await this.browser.findElement(xpath)).isSelected())) {
|
|
34
|
-
await (await this.browser.findElement(xpath)).click();
|
|
35
|
-
}
|
|
29
|
+
async select() {
|
|
30
|
+
if (!(await (await this.browser.findElement(this.getXpath())).isSelected())) {
|
|
31
|
+
await (await this.browser.findElement(this.getXpath())).click();
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
34
|
|
|
39
35
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {...String} items 选项
|
|
36
|
+
* 取消选择
|
|
42
37
|
*/
|
|
43
|
-
async unselect(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
let item = items[i];
|
|
47
|
-
xpath = `${this.getXpath()}//*[text()='${item}']/..//input`;
|
|
48
|
-
if (await (await this.browser.findElement(xpath)).isSelected()) {
|
|
49
|
-
await (await this.browser.findElement(xpath)).click();
|
|
50
|
-
}
|
|
38
|
+
async unselect() {
|
|
39
|
+
if (await (await this.browser.findElement(this.getXpath())).isSelected()) {
|
|
40
|
+
await (await this.browser.findElement(this.getXpath())).click();
|
|
51
41
|
}
|
|
52
42
|
}
|
|
53
43
|
|
package/lis60/page/Page.js
CHANGED
|
@@ -137,6 +137,26 @@ class Page extends require("@winning-test/autotest-webui").Page {
|
|
|
137
137
|
await this.browser.switchToFrame(xpath)
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
/**
|
|
141
|
+
* 切换到最外层iframe
|
|
142
|
+
*/
|
|
143
|
+
async switchToDefultFrame() {
|
|
144
|
+
await this.browser.switchToFrame();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 切换到对应的iframe
|
|
149
|
+
* @param {string} id
|
|
150
|
+
*/
|
|
151
|
+
async switchToFrame(id) {
|
|
152
|
+
try {
|
|
153
|
+
await this.browser.switchToFrame(`//iframe[@id='${id}']`);
|
|
154
|
+
|
|
155
|
+
} catch (error) {
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
140
160
|
}
|
|
141
161
|
|
|
142
162
|
module.exports = Page;
|
package/package.json
CHANGED
|
@@ -34,6 +34,15 @@ class TableComponent extends require("./Component") {
|
|
|
34
34
|
*/
|
|
35
35
|
async getTableData() {
|
|
36
36
|
let ret = [];
|
|
37
|
+
// 先判断表单是否有数据,没有的话返回[]
|
|
38
|
+
let z_xpath = `${this.getXpath()}${this._createBodyXapth()}`
|
|
39
|
+
if(!await this.browser.isDisplayed(`${z_xpath}`, 2000)) {
|
|
40
|
+
return ret;
|
|
41
|
+
}
|
|
42
|
+
if(!await this.browser.isDisplayed(`${z_xpath}//tr`, 2000)) {
|
|
43
|
+
return ret;
|
|
44
|
+
}
|
|
45
|
+
// 默认表格有数据
|
|
37
46
|
let xpath = `(${this.getXpath()}${this._createBodyXapth()}//tr)[1]`;
|
|
38
47
|
await this.browser.waitUntilElementBeVisible(xpath);
|
|
39
48
|
await this.browser.sleep(TableComponent.delayTime);
|