Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
Vue-WebDriver
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
高源
Vue-WebDriver
Commits
2e4c4efe
Commit
2e4c4efe
authored
Nov 19, 2023
by
施晓雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新逻辑错误代码
parent
92f8d5ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
18 deletions
+8
-18
sdk-table.js
src/sdk-table.js
+8
-18
No files found.
src/sdk-table.js
View file @
2e4c4efe
...
...
@@ -83,16 +83,12 @@ function table () {
if
(
!
_isVerified
)
return
null
;
//如果还没通过验证不返回数据
let
rowIndex
=
1
;
while
(
true
)
{
let
cellResult
=
{}
let
result
=
{};
// 为每个 cell 创建一个新的结果对象
this
.
cells
.
forEach
(
cell
=>
{
let
result
=
{};
// 为每个 cell 创建一个新的结果对象
cell
.
getData
(
result
,
rowIndex
);
// 调用 getData 方法
if
(
Object
.
keys
(
result
).
length
>
0
)
{
rtns
.
push
(
result
);
// 如果 result 对象非空,则添加到 rtn 数组
cellResult
=
result
}
});
if
(
Object
.
keys
(
cellResult
).
length
===
0
)
break
;
//不断的根据rowIndex取值,直到取不到值就退出,需要注意如果第0行是表头,也不一定可以取到值
if
(
Object
.
keys
(
result
).
length
===
0
)
break
;
//不断的根据rowIndex取值,直到取不到值就退出,需要注意如果第0行是表头,也不一定可以取到值
rtns
.
push
(
result
);
rowIndex
++
;
}
return
rtns
;
...
...
@@ -146,14 +142,10 @@ function cell (xpath, name = "", type = "", title = "") {
*/
this
.
isExist
=
function
()
{
let
existCount
=
0
;
// let _tableXpathArrays = [..._tableXpathArray]; //深拷贝,值修改不影响原数组
// let _relativeXpathArrays = [..._relativeXpathArray];//深拷贝,值修改不影响原数组
let
_tableXpathArrays
=
_tableXpathArray
.
join
(
'/'
)
let
_relativeXpathArrays
=
_relativeXpathArray
.
join
(
'/'
)
for
(
let
i
=
1
;
i
<
3
;
i
++
)
{
// 验证是否能找到元素
let
_xpath
=
_tableXpathArrays
+
'['
+
i
+
']'
+
'/'
+
_relativeXpathArrays
;
let
result
=
document
.
evaluate
(
_x
path
,
document
,
null
,
XPathResult
.
FIRST_ORDERED_NODE_TYPE
,
null
);
let
cellXpath
=
_tableXpathArray
.
join
(
'/'
)
+
'['
+
i
+
']'
+
'/'
+
_relativeXpathArray
.
join
(
'/'
)
;
let
result
=
document
.
evaluate
(
cellX
path
,
document
,
null
,
XPathResult
.
FIRST_ORDERED_NODE_TYPE
,
null
);
if
(
!!
result
.
singleNodeValue
)
{
existCount
++
;
}
...
...
@@ -171,12 +163,10 @@ function cell (xpath, name = "", type = "", title = "") {
* @param {int} index 索引号
*/
this
.
getData
=
function
(
result
,
index
)
{
let
rea
lXpath
=
this
.
tableXpath
+
"["
+
index
+
"]"
+
'/'
+
this
.
relativeXpath
;
let
results
=
document
.
evaluate
(
rea
lXpath
,
document
,
null
,
XPathResult
.
FIRST_ORDERED_NODE_TYPE
,
null
);
let
cel
lXpath
=
this
.
tableXpath
+
"["
+
index
+
"]"
+
'/'
+
this
.
relativeXpath
;
let
results
=
document
.
evaluate
(
cel
lXpath
,
document
,
null
,
XPathResult
.
FIRST_ORDERED_NODE_TYPE
,
null
);
if
(
!!
results
.
singleNodeValue
)
{
result
[
this
.
name
]
=
'动态绑定属性值'
result
[
'xpath'
]
=
results
.
singleNodeValue
.
innerText
return
result
result
[
this
.
name
]
=
results
.
singleNodeValue
.
innerText
;
}
};
return
this
;
//返回当前对象
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment