Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
auto-test
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄承天
auto-test
Commits
80ca467d
提交
80ca467d
authored
3月 31, 2020
作者:
黄承天
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
补充ActResult类
上级
39c9ec08
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
30 行增加
和
6 行删除
+30
-6
ActResult.java
src/main/java/com/zjty/autotest/pojo/test/ActResult.java
+22
-0
SeleniumExecutor.java
...java/com/zjty/autotest/service/impl/SeleniumExecutor.java
+8
-6
没有找到文件。
src/main/java/com/zjty/autotest/pojo/test/ActResult.java
0 → 100644
浏览文件 @
80ca467d
package
com
.
zjty
.
autotest
.
pojo
.
test
;
import
com.zjty.autotest.pojo.report.ElementDetail
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* <p>Description : autotest
* <p>Date : 2020/3/31 13:46
* <p>@author : C
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ActResult
{
private
Boolean
staleness
;
private
ElementDetail
elementDetail
;
}
src/main/java/com/zjty/autotest/service/impl/SeleniumExecutor.java
浏览文件 @
80ca467d
...
@@ -63,7 +63,7 @@ public class SeleniumExecutor {
...
@@ -63,7 +63,7 @@ public class SeleniumExecutor {
private
Queue
<
String
>
urlQueue
=
Queues
.
newLinkedBlockingDeque
();
private
Queue
<
String
>
urlQueue
=
Queues
.
newLinkedBlockingDeque
();
Map
<
Attributes
,
WebElement
>
elements
=
Maps
.
newHashMap
();
private
Map
<
Attributes
,
WebElement
>
elements
=
Maps
.
newHashMap
();
/**
/**
* 当前进行的窗口页
* 当前进行的窗口页
*/
*/
...
@@ -127,10 +127,10 @@ public class SeleniumExecutor {
...
@@ -127,10 +127,10 @@ public class SeleniumExecutor {
log
.
info
(
"剩余URL队列:{}"
,
urlQueue
);
log
.
info
(
"剩余URL队列:{}"
,
urlQueue
);
log
.
info
(
"正在获取当前网页所有元素..."
);
log
.
info
(
"正在获取当前网页所有元素..."
);
StringBuilder
message
=
new
StringBuilder
();
StringBuilder
message
=
new
StringBuilder
();
Set
<
String
>
messages
=
Sets
.
newHashSet
();
String
error
=
checkJsError
();
String
error
=
checkJsError
();
if
(
nonNull
(
error
))
{
if
(
nonNull
(
error
))
{
message
.
append
(
error
);
messages
.
add
(
error
);
message
.
append
(
";"
);
}
}
//获取当前网页的所有元素并放入元素队列
//获取当前网页的所有元素并放入元素队列
elements
.
clear
();
elements
.
clear
();
...
@@ -151,11 +151,11 @@ public class SeleniumExecutor {
...
@@ -151,11 +151,11 @@ public class SeleniumExecutor {
screenshot
=
String
.
format
(
"/%s"
,
screenshotName
);
screenshot
=
String
.
format
(
"/%s"
,
screenshotName
);
}
}
//总合信息
//总合信息
Set
<
String
>
messages
=
elementDetails
.
stream
()
messages
.
addAll
(
elementDetails
.
stream
()
.
filter
(
Objects:
:
nonNull
)
.
filter
(
Objects:
:
nonNull
)
.
map
(
ElementDetail:
:
getMessage
)
.
map
(
ElementDetail:
:
getMessage
)
.
filter
(
Objects:
:
nonNull
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
to
Set
(
));
.
collect
(
Collectors
.
to
List
()
));
for
(
String
msg
:
messages
)
{
for
(
String
msg
:
messages
)
{
message
.
append
(
msg
);
message
.
append
(
msg
);
message
.
append
(
";"
);
message
.
append
(
";"
);
...
@@ -198,6 +198,7 @@ public class SeleniumExecutor {
...
@@ -198,6 +198,7 @@ public class SeleniumExecutor {
}
}
}
}
@SuppressWarnings
(
"AlibabaMethodTooLong"
)
private
ActResult
act
(
Attributes
attributes
,
WebElement
element
,
String
actType
)
{
private
ActResult
act
(
Attributes
attributes
,
WebElement
element
,
String
actType
)
{
String
type
=
String
.
format
(
"<%s>%s"
,
element
.
getTagName
(),
element
.
getText
());
String
type
=
String
.
format
(
"<%s>%s"
,
element
.
getTagName
(),
element
.
getText
());
String
message
=
null
;
String
message
=
null
;
...
@@ -220,7 +221,6 @@ public class SeleniumExecutor {
...
@@ -220,7 +221,6 @@ public class SeleniumExecutor {
element
.
click
();
element
.
click
();
sleep
();
sleep
();
success
=
true
;
success
=
true
;
boolean
urlChanged
=
checkURl
();
boolean
urlChanged
=
checkURl
();
boolean
sourceChanged
=
checkSource
();
boolean
sourceChanged
=
checkSource
();
if
(
urlChanged
)
{
if
(
urlChanged
)
{
...
@@ -422,11 +422,13 @@ public class SeleniumExecutor {
...
@@ -422,11 +422,13 @@ public class SeleniumExecutor {
FileUtil
.
output
(
bytes
,
path
);
FileUtil
.
output
(
bytes
,
path
);
}
}
@SuppressWarnings
(
"unused"
)
private
Boolean
elementMatch
(
WebElement
webElement
,
Element
element
)
{
private
Boolean
elementMatch
(
WebElement
webElement
,
Element
element
)
{
return
element
.
attributes
().
asList
().
stream
()
return
element
.
attributes
().
asList
().
stream
()
.
allMatch
(
attribute
->
Objects
.
equals
(
attribute
.
getValue
(),
webElement
.
getAttribute
(
attribute
.
getKey
())));
.
allMatch
(
attribute
->
Objects
.
equals
(
attribute
.
getValue
(),
webElement
.
getAttribute
(
attribute
.
getKey
())));
}
}
@SuppressWarnings
(
"unused"
)
private
Map
<
Attributes
,
WebElement
>
removeHistoryElements
(
Map
<
Attributes
,
WebElement
>
elements
)
{
private
Map
<
Attributes
,
WebElement
>
removeHistoryElements
(
Map
<
Attributes
,
WebElement
>
elements
)
{
Map
<
Attributes
,
WebElement
>
result
=
Maps
.
newHashMap
(
elements
);
Map
<
Attributes
,
WebElement
>
result
=
Maps
.
newHashMap
(
elements
);
elements
.
forEach
((
attributes
,
element
)
->
{
elements
.
forEach
((
attributes
,
element
)
->
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论