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
67955fa6
Commit
67955fa6
authored
Nov 18, 2023
by
施晓雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
up
parent
49a6ae73
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
22 deletions
+23
-22
sdk-table.js
src/sdk-table.js
+23
-22
No files found.
src/sdk-table.js
View file @
67955fa6
...
...
@@ -28,29 +28,30 @@ function table () {
this
.
xpath
=
null
;
//防止反复验证,需要清空XPath
if
(
this
.
cells
.
length
<
1
)
return
_isVerified
;
let
tableXpath
=
[];
let
tableXpath
Array
=
[];
{
//获取所有单元格共同的父节点路径
let
allCellXpaths
=
this
.
cells
.
map
(
cell
=>
cell
.
xpath
.
split
(
'/'
));
// 分割每个路径为组成部分
for
(
let
i
=
0
;
i
<
allCellXpaths
[
0
].
length
;
i
++
)
{
let
currentPath
=
allCellXpaths
[
0
][
i
];
if
(
allCellXpaths
.
every
(
path
=>
path
[
i
]
===
currentPath
))
{
// 检查所有路径是否有这个部分
tableXpath
.
push
(
currentPath
);
tableXpath
Array
.
push
(
currentPath
);
}
else
{
break
;
}
//如果发现不同的,直接就可以退出了
}
//判断下tableXPathArray不能和某一个元素的路径完全相同,如果相同就应该去掉一级
}
if
(
tableXpath
.
length
<
1
)
return
_isVerified
;
//如果没有共同父节点,返回false
if
(
tableXpath
Array
.
length
<
1
)
return
_isVerified
;
//如果没有共同父节点,返回false
while
(
tableXpath
.
length
>
0
)
{
this
.
cells
.
forEach
(
cell
=>
cell
.
updateRelativePath
(
tableXpath
));
//先对所有的Cell更新下相对路径
this
.
cells
.
forEach
(
cell
=>
cell
.
updateRelativePath
(
tableXpath
Array
));
//先对所有的Cell更新下相对路径
if
(
this
.
cells
.
every
(
cell
=>
cell
.
isExist
()))
break
;
//如果每个cell都存在,成功
tableXpath
.
pop
();
//向上一级找
tableXpath
Array
.
pop
();
//向上一级找
}
if
(
tableXpath
.
length
<
1
)
return
_isVerified
;
//如果没有共同父节点,返回false
if
(
tableXpath
Array
.
length
<
1
)
return
_isVerified
;
//如果没有共同父节点,返回false
this
.
cells
.
forEach
(
cell
=>
cell
.
confirm
());
//对所有单元格进行确认
_isVerified
=
true
;
this
.
xpath
=
tableXpath
.
join
(
"/"
);
//是否可以转换成SmallXPath
this
.
xpath
=
tableXpath
Array
.
join
(
"/"
);
//是否可以转换成SmallXPath
return
_isVerified
;
}
/**
...
...
@@ -98,17 +99,17 @@ function cell (xpath, name = "", type = "", title = "") {
/**当前XPath的数组结构 */
let
_xpathArray
=
this
.
xpath
.
split
(
'/'
);
/**当前表路径的数组结构 */
this
.
_tableXpathArray
=
null
;
let
_tableXpathArray
=
null
;
/**当前单元格的相对路径的数组结构 */
this
.
_relativeXpathArray
=
null
;
let
_relativeXpathArray
=
null
;
/**
* 根据父路径更新当前的相对路径
* @param {string[]} parentXpath 父路径
*/
this
.
updateRelativePath
=
function
(
parentXpath
)
{
this
.
_tableXpathArray
=
parentXpath
;
//其实这边严谨的来说要验证一下XPath是否真的有相同的根
this
.
_relativeXpathArray
=
_xpathArray
.
slice
(
this
.
_tableXpathArray
.
length
);
_tableXpathArray
=
parentXpath
;
//其实这边严谨的来说要验证一下XPath是否真的有相同的根
_relativeXpathArray
=
_xpathArray
.
slice
(
_tableXpathArray
.
length
);
// this.relativeXpath = this._relativeXpathArray
// this.tableXpath = _tableXpathArray
// console.log(this._relativeXpathArray)
...
...
@@ -117,17 +118,11 @@ function cell (xpath, name = "", type = "", title = "") {
* 单元格是否存在
* @returns {boolean}
*/
this
.
isExist
=
function
(
cell
)
{
this
.
isExist
=
function
()
{
let
existCount
=
0
;
let
_tableXpathArray
=
[...
cell
.
_tableXpathArray
]
//深拷贝,值修改不影响原数组
let
_relativeXpathArray
=
[...
cell
.
_relativeXpathArray
]
//深拷贝,值修改不影响原数组
// 移除最后一个元素的下标
if
(
_tableXpathArray
.
length
>
0
)
{
let
lastElement
=
_tableXpathArray
[
_tableXpathArray
.
length
-
1
];
let
lastElementWithoutIndex
=
lastElement
.
split
(
'['
)[
0
];
_tableXpathArray
[
_tableXpathArray
.
length
-
1
]
=
lastElementWithoutIndex
;
}
let
_tableXpathArray
=
[...
_tableXpathArray
]
//深拷贝,值修改不影响原数组
let
_relativeXpathArray
=
[...
_relativeXpathArray
]
//深拷贝,值修改不影响原数组
_tableXpathArray
=
_tableXpathArray
.
join
(
'/'
)
_relativeXpathArray
=
_relativeXpathArray
.
join
(
'/'
)
//table[0]+relativeXpath,可以不存在,因为可能是表头,1,2
...
...
@@ -146,8 +141,14 @@ function cell (xpath, name = "", type = "", title = "") {
}
/**当所有单元格验证成功后,由表发起确认动作 */
this
.
confirm
=
function
()
{
this
.
tableXpath
=
this
.
_tableXpathArray
.
join
(
"/"
);
//处理下标的事
this
.
relativePath
=
this
.
_relativeXpathArray
.
join
(
"/"
);
// 移除最后一个元素的下标
if
(
_tableXpathArray
.
length
>
0
)
{
let
lastElement
=
_tableXpathArray
[
_tableXpathArray
.
length
-
1
];
let
lastElementWithoutIndex
=
lastElement
.
split
(
'['
)[
0
];
_tableXpathArray
[
_tableXpathArray
.
length
-
1
]
=
lastElementWithoutIndex
;
}
this
.
tableXpath
=
_tableXpathArray
.
join
(
"/"
);
//处理下标的事
this
.
relativePath
=
_relativeXpathArray
.
join
(
"/"
);
}
/**
* 根据索引获取值,返回{name:value}格式
...
...
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