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
4ca0469f
Commit
4ca0469f
authored
Nov 28, 2023
by
郁子恒
Browse files
Options
Browse Files
Download
Plain Diff
解决合并冲突
parents
c0d4f2bd
7a129fd4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
30 deletions
+94
-30
collectionTable.vue
src/components/collectionTable.vue
+88
-25
sdk-table.js
src/sdk-table.js
+6
-5
No files found.
src/components/collectionTable.vue
View file @
4ca0469f
...
...
@@ -2,12 +2,13 @@
<div
class=
"collectionTable"
>
<div
style=
"display: flex;height: 40px;padding-left: 15px;text-align: left;align-items: center;justify-content: space-between;"
>
<template
v-if=
"isSelectTable"
>
<el-tooltip
class=
"item"
effect=
"dark"
content=
"
请右击页面元素
"
placement=
"top"
>
<el-tooltip
class=
"item"
effect=
"dark"
content=
"
点击新增,右击页面元素添加数据
"
placement=
"top"
>
<!--
<el-button
style=
"width: 60px;height: 30px;"
size=
"mini"
class=
"button-new-tag"
@
click=
"selectElement"
>
选择元素
</el-button>
-->
<!--
<vxe-button
icon=
"fa fa-plus"
>
新增
</vxe-button>
-->
<el-button
type=
"primary"
size=
"mini"
style=
"width: 20px;height: 20px;"
@
click=
"selectElement"
>
<img
style=
"width: 12px;height: 12px;"
src=
"../assets/add.svg"
>
<el-button
type=
"primary"
size=
"mini"
style=
"width: 40px;height: 20px;"
@
click=
"selectElement"
>
<img
style=
"width: 10px;height: 10px;vertical-align: bottom;"
src=
"../assets/add.svg"
>
<span>
新增
</span>
</el-button>
</el-tooltip>
</
template
>
...
...
@@ -21,11 +22,13 @@
</div>
<!-- 全部表格信息 -->
<div
style=
"overflow: auto;height: 290px;"
:style=
"{ width: widthResize + 'px' }"
>
<vxe-table
:data=
"SelectTableData"
ref=
"xTableColumn"
border
class=
"mytable-scrollbar"
height=
"250"
v-if=
"isSelectTable"
auto-resize
style=
"margin-bottom: 5px;"
>
<vxe-table
:data=
"SelectTableData"
ref=
"xTableColumn"
border
class=
"mytable-scrollbar"
height=
"250"
v-if=
"isSelectTable"
auto-resize
style=
"margin-bottom: 5px;"
@
current-change=
"currentChangeEvent"
highlight-hover-row
highlight-current-row
>
<vxe-column
field=
""
title=
"列名"
min-width=
"150"
>
<
template
v-slot=
"{ row }"
>
<div
style=
"display: flex;flex-direction: column;"
>
<
span>
选中内容:
{{
row
.
contentText
}}
</span
>
<
!--
<span>
选中内容:
{{
row
.
contentText
}}
</span>
--
>
<vxe-input
v-model=
"row.title"
placeholder=
"请填写列名"
size=
"mini"
></vxe-input>
</div>
</
template
>
...
...
@@ -33,7 +36,7 @@
<vxe-column
field=
""
title=
"属性名"
min-width=
"150"
>
<
template
v-slot=
"{ row }"
>
<div
style=
"display: flex;flex-direction: column;"
>
<
span>
选中内容:
{{
row
.
contentText
}}
</span
>
<
!--
<span>
选中内容:
{{
row
.
contentText
}}
</span>
--
>
<vxe-input
v-model=
"row.name"
placeholder=
"请填写属性名"
size=
"mini"
></vxe-input>
</div>
</
template
>
...
...
@@ -41,17 +44,23 @@
<vxe-column
field=
""
title=
"值类型"
min-width=
"170"
>
<
template
v-slot=
"{ row }"
>
<div
style=
"display: flex;flex-direction: column;"
>
<span>
选中内容:
{{
row
.
contentText
}}
</span>
<el-select
style=
"height: 28px;"
v-model=
"row.type"
placeholder=
"选择值类型"
v-if=
"row.typeOptions.length > 1"
:popper-append-to-body=
"false"
filterable
remote
>
<el-option
v-for=
"num in row.typeOptions"
:key=
"num.xpath"
:value=
"num.value"
:label=
"num.label"
></el-option>
<!--
<span>
选中内容:
{{
row
.
contentText
}}
</span>
-->
<el-select
style=
"height: 28px;"
v-model=
"row.type"
placeholder=
"选择值类型"
v-if=
"row.typeOptions.length > 1"
:popper-append-to-body=
"false"
filterable
remote
>
<el-option
v-for=
"num in row.typeOptions"
:key=
"num.xpath"
:value=
"num.label"
:label=
"num.value"
></el-option>
</el-select>
<vxe-input
style=
"width: 100% !important;"
v-model=
"row.type"
:placeholder=
"row.typeOptions[0].label"
size=
"mini"
v-else
disabled
></vxe-input>
<vxe-input
style=
"width: 100% !important;"
v-model=
"row.type"
:placeholder=
"row.typeOptions[0].value"
size=
"mini"
v-else
disabled
></vxe-input>
</div>
</
template
>
</vxe-column>
<vxe-column
title=
"操作"
min-width=
"70"
fixed=
"right"
>
<
template
#
default=
"{ row }"
>
<vxe-button
status=
"danger"
content=
"删除"
@
click=
"columnDelete(row)"
style=
"width: 50px;"
></vxe-button>
<img
style=
"width: 50px;height: 28px;vertical-align: bottom;"
src=
"../assets/close.svg"
@
click=
"columnDelete(row)"
>
<!--
<vxe-button
status=
"danger"
content=
"删除"
@
click=
"columnDelete(row)"
style=
"width: 50px;"
></vxe-button>
-->
</
template
>
</vxe-column>
</vxe-table>
...
...
@@ -80,6 +89,7 @@ export default {
contextMenuListenerAdded
:
false
,
index
:
0
,
tableName
:
''
,
selectedRow
:
null
}
},
created
()
{
...
...
@@ -96,7 +106,19 @@ export default {
this
.
tableName
=
this
.
activedAction
.
table
.
name
;
}
},
mounted
()
{
},
mounted
()
{
let
_this
=
this
document
.
addEventListener
(
'click'
,
function
(
event
)
{
// 如果点击的不是当前高亮的元素,移除高亮
if
(
event
.
target
!==
window
.
currentlyHighlighted
)
{
if
(
window
.
currentlyHighlighted
)
{
window
.
currentlyHighlighted
.
style
.
backgroundColor
=
''
;
}
window
.
currentlyHighlighted
=
null
;
}
});
},
watch
:
{},
computed
:
{},
methods
:
{
...
...
@@ -112,7 +134,16 @@ export default {
_this
.
SelectTableData
=
this
.
SelectTableData
.
filter
(
item
=>
item
.
_X_ROW_KEY
!==
row
.
_X_ROW_KEY
)
// 先将删除的元素清空,并且将背景色还原
_this
.
SelectTableData
=
_this
.
SelectTableData
.
filter
(
xpath
=>
xpath
.
xpath
!==
row
.
xpath
);
_this
.
setElementBackgroundColor
(
row
.
xpath
,
''
)
// 将表格最后一个选中,添加背景色
if
(
_this
.
SelectTableData
.
length
>
0
)
{
_this
.
$refs
.
xTableColumn
.
setCurrentRow
(
_this
.
SelectTableData
[
_this
.
SelectTableData
.
length
-
1
])
_this
.
setElementBackgroundColor
(
_this
.
SelectTableData
[
_this
.
SelectTableData
.
length
-
1
].
xpath
,
'orange'
)
}
if
(
_this
.
table
==
null
)
return
_this
.
table
.
cells
=
_this
.
table
.
cells
.
filter
(
xpath
=>
xpath
!==
row
.
xpath
);
},
columnBack
()
{
...
...
@@ -120,6 +151,21 @@ export default {
_this
.
isSelectTable
=
true
_this
.
tableData
=
[]
},
// 行选中事件
currentChangeEvent
({
row
})
{
if
(
this
.
selectedRow
==
null
)
{
this
.
selectedRow
=
row
}
if
(
this
.
selectedRow
.
xpath
!==
row
.
xpath
)
{
this
.
setElementBackgroundColor
(
this
.
selectedRow
.
xpath
,
''
)
this
.
selectedRow
=
row
this
.
setElementBackgroundColor
(
row
.
xpath
,
'orange'
)
}
else
{
this
.
setElementBackgroundColor
(
row
.
xpath
,
'orange'
)
}
},
// 获取页面元素
selectElement
()
{
...
...
@@ -140,9 +186,9 @@ export default {
if
(
targetElement
.
tagName
===
'A'
)
{
// 链接
info
=
{
xPath
:
'
xPath
'
,
url
:
'href
'
,
text
:
'textContent
'
xPath
:
'
元素路径
'
,
href
:
'超链接
'
,
text
Content
:
'文本
'
};
typeOptions
=
Object
.
entries
(
info
).
map
(([
label
,
value
])
=>
{
return
{
label
,
value
};
...
...
@@ -155,9 +201,9 @@ export default {
}
else
if
(
targetElement
.
tagName
===
'IMG'
)
{
// 图片
info
=
{
xPath
:
'xPath
'
,
src
:
'
src
'
,
alt
:
'
alt
'
"xPath"
:
'元素路径
'
,
src
:
'
超链接
'
,
alt
:
'
属性
'
};
typeOptions
=
Object
.
entries
(
info
).
map
(([
label
,
value
])
=>
{
return
{
label
,
value
};
...
...
@@ -170,8 +216,7 @@ export default {
}
else
{
// 其他标签
info
=
{
// xPath:'xPath',
text
:
'textContent'
textContent
:
'文本'
};
typeOptions
=
Object
.
entries
(
info
).
map
(([
label
,
value
])
=>
{
return
{
label
,
value
};
...
...
@@ -185,8 +230,16 @@ export default {
info
.
name
=
'ID'
+
_this
.
index
++
info
.
type
=
''
_this
.
SelectTableData
.
push
(
info
)
console
.
log
(
_this
.
SelectTableData
)
// sdkTable--------------------------------------------------------------------------------------------------------
// 将新加入的tableData添加高亮
_this
.
$refs
.
xTableColumn
.
setCurrentRow
(
_this
.
SelectTableData
[
_this
.
SelectTableData
.
length
-
1
])
// 移除先前元素的背景色(如果有)
if
(
window
.
currentlyHighlighted
)
{
window
.
currentlyHighlighted
.
style
.
backgroundColor
=
''
;
}
// 更新背景色并保存当前元素
event
.
target
.
style
.
backgroundColor
=
'orange'
;
window
.
currentlyHighlighted
=
event
.
target
;
// 移除事件监听器
document
.
removeEventListener
(
'contextmenu'
,
contextMenuHandler
);
_this
.
contextMenuListenerAdded
=
false
;
...
...
@@ -215,6 +268,13 @@ export default {
}
}
},
setElementBackgroundColor
(
xpath
,
color
)
{
let
result
=
document
.
evaluate
(
xpath
,
document
,
null
,
XPathResult
.
FIRST_ORDERED_NODE_TYPE
,
null
);
let
selectedElement
=
result
.
singleNodeValue
;
if
(
selectedElement
)
{
selectedElement
.
style
.
backgroundColor
=
color
;
}
},
validateNames
(
arr
)
{
let
_this
=
this
;
let
names
=
new
Set
();
...
...
@@ -276,10 +336,13 @@ export default {
_this
.
table
.
Name
=
_this
.
activedAction
.
Name
_this
.
table
.
Alias
=
_this
.
activedAction
.
Alias
_this
.
$emit
(
'dataChanged'
,
_this
.
table
);
console
.
log
(
this
.
table
)
// 防止父级改变,子级未改变重新赋值
this
.
activedAction
.
table
=
this
.
table
;
this
.
$emit
(
'dataChanged'
,
this
.
activedAction
);
_this
.
activedAction
.
table
=
_this
.
table
;
_this
.
$emit
(
'dataChanged'
,
_this
.
activedAction
);
// _this.setElementBackgroundColor('/HTML/BODY/DIV[3]', 'orange')
if
(
_this
.
selectedRow
==
null
)
return
_this
.
setElementBackgroundColor
(
this
.
selectedRow
.
xpath
,
''
)
}
},
}
...
...
src/sdk-table.js
View file @
4ca0469f
...
...
@@ -14,9 +14,9 @@ function table () {
* 新生成一个单元格
* @param {any} xpath
*/
this
.
newCell
=
function
(
xpath
,
name
,
type
,
types
,
title
)
{
this
.
newCell
=
function
(
xpath
,
name
,
type
,
types
,
title
)
{
_isVerified
=
false
;
//加入了
let
newCell
=
new
cell
(
xpath
,
name
,
type
,
types
,
title
);
let
newCell
=
new
cell
(
xpath
,
name
,
type
,
types
,
title
);
this
.
cells
.
push
(
newCell
);
}
/**
...
...
@@ -102,7 +102,7 @@ function table () {
* @param {string} type 元素取值类型,文本,链接,元素路径(点击动作用)
* @param {string} title 标题信息
*/
function
cell
(
xpath
,
name
,
type
,
types
,
title
)
{
function
cell
(
xpath
,
name
,
type
,
types
,
title
)
{
/**当前单元格的绝对路径,存入Action时有用 */
this
.
xpath
=
xpath
;
/**当前单元格存储数据时的属性名 */
...
...
@@ -167,9 +167,10 @@ function cell (xpath, name, type,types, title) {
let
cellXpath
=
this
.
tableXpath
+
"["
+
index
+
"]"
+
'/'
+
this
.
relativeXpath
;
let
results
=
document
.
evaluate
(
cellXpath
,
document
,
null
,
XPathResult
.
FIRST_ORDERED_NODE_TYPE
,
null
);
if
(
!!
results
.
singleNodeValue
)
{
// console.log(results)
if
(
this
.
type
==
'xPath'
)
{
result
[
this
.
name
]
=
this
.
xpath
result
[
this
.
name
]
=
xpath
}
else
if
(
this
.
type
==
'文本'
)
{
result
[
this
.
name
]
=
results
.
singleNodeValue
[
'textContent'
];
}
else
{
result
[
this
.
name
]
=
results
.
singleNodeValue
[
this
.
type
];
}
...
...
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