Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
auto-test
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄承天
auto-test
Commits
ddfa4f29
提交
ddfa4f29
authored
3月 27, 2020
作者:
孙洁清
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of git.yfzx.zjtys.com.cn:hct/auto-test
上级
fd900b68
f61876e3
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
216 行增加
和
44 行删除
+216
-44
ElementMapping.java
...main/java/com/zjty/autotest/pojo/test/ElementMapping.java
+25
-0
SeleniumExecutor.java
...java/com/zjty/autotest/service/impl/SeleniumExecutor.java
+177
-37
AutotestApplicationTests.java
...test/java/com/zjty/autotest/AutotestApplicationTests.java
+14
-7
没有找到文件。
src/main/java/com/zjty/autotest/pojo/test/ElementMapping.java
0 → 100644
浏览文件 @
ddfa4f29
package
com
.
zjty
.
autotest
.
pojo
.
test
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.jsoup.nodes.Attributes
;
import
org.openqa.selenium.WebElement
;
/**
* <p>Description : autotest
* <p>Date : 2020/3/26 16:25
* <p>@author : C
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ElementMapping
{
Integer
order
;
WebElement
webElement
;
Attributes
attributes
;
}
src/main/java/com/zjty/autotest/service/impl/SeleniumExecutor.java
浏览文件 @
ddfa4f29
package
com
.
zjty
.
autotest
.
service
.
impl
;
package
com
.
zjty
.
autotest
.
service
.
impl
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Queues
;
import
com.google.common.collect.Queues
;
import
com.google.common.collect.Sets
;
import
com.google.common.collect.Sets
;
import
com.zjty.autotest.pojo.report.ElementDetail
;
import
com.zjty.autotest.pojo.report.ElementDetail
;
import
com.zjty.autotest.pojo.report.Measure
;
import
com.zjty.autotest.pojo.report.Measure
;
import
com.zjty.autotest.pojo.report.Report
;
import
com.zjty.autotest.pojo.report.Report
;
import
com.zjty.autotest.pojo.test.ElementMapping
;
import
com.zjty.autotest.pojo.test.Input
;
import
com.zjty.autotest.pojo.test.Input
;
import
com.zjty.autotest.pojo.test.Project
;
import
com.zjty.autotest.pojo.test.Project
;
import
com.zjty.autotest.util.FileUtil
;
import
com.zjty.autotest.util.FileUtil
;
import
com.zjty.autotest.util.WebDriverUtil
;
import
com.zjty.autotest.util.WebDriverUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.jsoup.Jsoup
;
import
org.jsoup.nodes.Attributes
;
import
org.jsoup.nodes.Document
;
import
org.jsoup.nodes.Element
;
import
org.openqa.selenium.*
;
import
org.openqa.selenium.*
;
import
org.openqa.selenium.support.ui.ExpectedConditions
;
import
org.openqa.selenium.support.ui.ExpectedConditions
;
import
org.openqa.selenium.support.ui.Sleeper
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.time.Duration
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Predicate
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
import
static
com
.
zjty
.
autotest
.
common
.
action
.
LabelType
.
INPUT
;
import
static
com
.
zjty
.
autotest
.
common
.
action
.
LabelType
.
INPUT
;
import
static
java
.
util
.
Objects
.
nonNull
;
import
static
java
.
util
.
Objects
.
nonNull
;
...
@@ -46,16 +55,15 @@ public class SeleniumExecutor {
...
@@ -46,16 +55,15 @@ public class SeleniumExecutor {
private
Set
<
String
>
historyUrls
=
Sets
.
newHashSet
();
private
Set
<
String
>
historyUrls
=
Sets
.
newHashSet
();
private
Set
<
Attributes
>
historyAttributes
=
Sets
.
newHashSet
();
private
Set
<
Attributes
>
currentHistoryAttributes
=
Sets
.
newHashSet
();
private
Queue
<
String
>
windowQueue
=
Queues
.
newLinkedBlockingDeque
();
private
Queue
<
String
>
windowQueue
=
Queues
.
newLinkedBlockingDeque
();
private
Queue
<
String
>
urlQueue
=
Queues
.
newLinkedBlockingDeque
();
private
Queue
<
String
>
urlQueue
=
Queues
.
newLinkedBlockingDeque
();
private
List
<
WebElement
>
elements
=
Lists
.
newArrayList
();
private
List
<
ElementMapping
>
elementMappings
=
Lists
.
newArrayList
();
/**
* 元素序号记录
*/
private
Integer
elementIndex
;
/**
/**
* 当前进行的窗口页
* 当前进行的窗口页
...
@@ -112,16 +120,19 @@ public class SeleniumExecutor {
...
@@ -112,16 +120,19 @@ public class SeleniumExecutor {
currentSource
=
driver
.
getPageSource
();
currentSource
=
driver
.
getPageSource
();
long
endTime
=
System
.
currentTimeMillis
();
long
endTime
=
System
.
currentTimeMillis
();
Long
responseTime
=
endTime
-
startTime
;
Long
responseTime
=
endTime
-
startTime
;
sleep
();
log
.
info
(
"当前URL:{} 响应时间 {} ms 开始进行遍历..."
,
currentUrl
,
responseTime
);
log
.
info
(
"当前URL:{} 响应时间 {} ms 开始进行遍历..."
,
currentUrl
,
responseTime
);
log
.
info
(
"剩余URL队列:{}"
,
urlQueue
);
log
.
info
(
"剩余URL队列:{}"
,
urlQueue
);
log
.
info
(
"正在获取当前网页所有元素..."
);
log
.
info
(
"正在获取当前网页所有元素..."
);
//获取当前网页的所有元素并放入元素队列
//获取当前网页的所有元素并放入元素队列
getAllElements
(
driver
);
Map
<
Attributes
,
WebElement
>
elements
=
getAllElements
(
driver
);
log
.
info
(
"获取完毕...共{}个元素..."
,
elements
.
size
());
log
.
info
(
"获取完毕...共{}个元素..."
,
elements
.
size
());
elements
.
forEach
((
attributes
,
element
)
->
System
.
out
.
println
(
attributes
));
//元素序号重置
//元素序号重置
elementIndex
=
0
;
currentHistoryAttributes
.
clear
()
;
//开始遍历操作元素队列中的元素 返回各个元素测试信息
//开始遍历操作元素队列中的元素 返回各个元素测试信息
List
<
ElementDetail
>
elementDetails
=
traversal
();
List
<
ElementDetail
>
elementDetails
=
Lists
.
newArrayList
();
traversal
(
elements
,
elementDetails
);
//如果全部元素通过则是通过
//如果全部元素通过则是通过
Boolean
success
=
elementDetails
.
stream
().
allMatch
(
ElementDetail:
:
getSuccess
);
Boolean
success
=
elementDetails
.
stream
().
allMatch
(
ElementDetail:
:
getSuccess
);
//如果出错 则提供截图
//如果出错 则提供截图
...
@@ -149,12 +160,19 @@ public class SeleniumExecutor {
...
@@ -149,12 +160,19 @@ public class SeleniumExecutor {
return
measure
;
return
measure
;
}
}
private
List
<
ElementDetail
>
traversal
()
{
private
void
traversal
(
Map
<
Attributes
,
WebElement
>
elements
,
List
<
ElementDetail
>
elementDetails
)
{
List
<
ElementDetail
>
elementDetails
=
Lists
.
newArrayList
();
elements
=
removeHistoryElements
(
elements
);
while
(
elementIndex
<
elements
.
size
())
{
for
(
Attributes
attributes
:
elements
.
keySet
())
{
WebElement
element
=
elements
.
get
(
elementIndex
);
WebElement
element
=
elements
.
get
(
attributes
);
ElementDetail
elementDetail
=
act
(
element
);
if
(!
currentHistoryAttributes
.
contains
(
attributes
)
&&
isInputAble
(
element
))
{
elementIndex
++;
ElementDetail
elementDetail
=
actInput
(
attributes
,
element
);
elementDetails
.
add
(
elementDetail
);
}
}
for
(
Attributes
attributes
:
elements
.
keySet
())
{
WebElement
element
=
elements
.
get
(
attributes
);
if
(!
currentHistoryAttributes
.
contains
(
attributes
)
&&
isClickAble
(
element
))
{
ElementDetail
elementDetail
=
actClick
(
attributes
,
element
);
boolean
urlChanged
=
checkURl
();
boolean
urlChanged
=
checkURl
();
boolean
sourceChanged
=
checkSource
();
boolean
sourceChanged
=
checkSource
();
if
(
urlChanged
)
{
if
(
urlChanged
)
{
...
@@ -166,29 +184,55 @@ public class SeleniumExecutor {
...
@@ -166,29 +184,55 @@ public class SeleniumExecutor {
urlQueue
.
add
(
driver
.
getCurrentUrl
());
urlQueue
.
add
(
driver
.
getCurrentUrl
());
urlQueue
=
queueDuplicateRemoval
(
urlQueue
);
urlQueue
=
queueDuplicateRemoval
(
urlQueue
);
}
}
reload
();
Map
<
Attributes
,
WebElement
>
reload
=
reload
();
}
traversal
(
reload
,
elementDetails
);
if
(
sourceChanged
)
{
reload
();
}
}
// if (sourceChanged) {
// Map<Attributes, WebElement> reload = reload();
// traversal(reload, elementDetails);
// }
elementDetails
.
add
(
elementDetail
);
elementDetails
.
add
(
elementDetail
);
}
}
return
elementDetails
;
}
}
// while (elementIndex < this.elements.size()) {
private
ElementDetail
act
(
WebElement
element
)
{
// WebElement element = this.elements.get(elementIndex);
String
type
=
""
;
// ElementDetail elementDetail = actClick(element,);
// elementIndex++;
// boolean urlChanged = checkURl();
// boolean sourceChanged = checkSource();
// if (urlChanged) {
// boolean newPage = !historyUrls.contains(driver.getCurrentUrl())
// && !Sets.newHashSet(urlQueue).contains(driver.getCurrentUrl())
// && sourceChanged;
// if (newPage) {
// log.info("检测到新url:{} 加入队列 ", driver.getCurrentUrl());
// urlQueue.add(driver.getCurrentUrl());
// urlQueue = queueDuplicateRemoval(urlQueue);
// }
// reload();
// }
// if (sourceChanged) {
// reload();
// }
// elementDetails.add(elementDetail);
// }
}
private
ElementDetail
actInput
(
Attributes
attributes
,
WebElement
element
)
{
String
type
=
element
.
getTagName
();
String
message
=
null
;
String
message
=
null
;
Long
responseTIme
=
0
L
;
Long
responseTIme
=
-
1
L
;
boolean
success
=
false
;
boolean
success
=
false
;
try
{
try
{
if
(
isEnabled
(
element
))
{
if
(
isEnabled
(
element
))
{
log
.
info
(
"操作第{}个元素 ------ text:[{}] ----- tag:[{}]"
,
elementIndex
+
1
,
element
.
getText
(),
element
.
getTagName
());
log
.
info
(
"Input元素 ------ text:[{}] ----- tag:[{}] ---- attrs:[{}]"
,
element
.
getText
(),
element
.
getTagName
(),
attributes
);
if
(
isInputAble
(
element
)
&&
!
inputs
.
isEmpty
())
{
long
startTime
=
System
.
currentTimeMillis
();
if
(!
inputs
.
isEmpty
())
{
Input
input
=
inputs
.
remove
(
0
);
Input
input
=
inputs
.
remove
(
0
);
element
.
sendKeys
(
input
.
getValue
());
element
.
sendKeys
(
input
.
getValue
());
}
}
element
.
click
();
long
endTime
=
System
.
currentTimeMillis
();
Long
responseTime
=
endTime
-
startTime
;
success
=
true
;
success
=
true
;
Alert
alert
=
ExpectedConditions
.
alertIsPresent
().
apply
(
driver
);
Alert
alert
=
ExpectedConditions
.
alertIsPresent
().
apply
(
driver
);
if
(
nonNull
(
alert
))
{
if
(
nonNull
(
alert
))
{
...
@@ -197,7 +241,43 @@ public class SeleniumExecutor {
...
@@ -197,7 +241,43 @@ public class SeleniumExecutor {
success
=
false
;
success
=
false
;
}
}
}
}
}
catch
(
ElementNotInteractableException
e
)
{
message
=
"异常的布局;"
;
success
=
false
;
log
.
error
(
"error:存在可操作范围之外的元素"
);
}
catch
(
Exception
e
)
{
message
=
"预料之外的异常:"
+
e
.
getMessage
()
+
";"
;
success
=
false
;
log
.
error
(
"error:"
+
e
);
}
historyAttributes
.
add
(
attributes
);
currentHistoryAttributes
.
add
(
attributes
);
return
new
ElementDetail
(
type
,
responseTIme
.
intValue
(),
success
,
message
);
}
private
ElementDetail
actClick
(
Attributes
attributes
,
WebElement
element
)
{
String
type
=
element
.
getTagName
();
String
message
=
null
;
Long
responseTIme
=
0L
;
boolean
success
=
false
;
try
{
if
(
isEnabled
(
element
))
{
log
.
info
(
"Click 元素 ------ text:[{}] ----- tag:[{}] ---- attrs:[{}]"
,
element
.
getText
(),
element
.
getTagName
(),
attributes
);
element
.
click
();
sleep
();
success
=
true
;
Alert
alert
=
ExpectedConditions
.
alertIsPresent
().
apply
(
driver
);
if
(
nonNull
(
alert
))
{
message
=
"出现警告窗:"
+
alert
.
getText
();
alert
.
accept
();
success
=
false
;
}
}
}
catch
(
ElementNotInteractableException
e
)
{
}
catch
(
ElementNotInteractableException
e
)
{
message
=
"异常的布局;"
;
message
=
"异常的布局;"
;
success
=
false
;
success
=
false
;
...
@@ -207,6 +287,8 @@ public class SeleniumExecutor {
...
@@ -207,6 +287,8 @@ public class SeleniumExecutor {
success
=
false
;
success
=
false
;
log
.
error
(
"error:"
+
e
);
log
.
error
(
"error:"
+
e
);
}
}
historyAttributes
.
add
(
attributes
);
currentHistoryAttributes
.
add
(
attributes
);
return
new
ElementDetail
(
return
new
ElementDetail
(
type
,
type
,
responseTIme
.
intValue
(),
responseTIme
.
intValue
(),
...
@@ -252,36 +334,49 @@ public class SeleniumExecutor {
...
@@ -252,36 +334,49 @@ public class SeleniumExecutor {
}
}
}
}
private
void
reload
()
{
private
Map
<
Attributes
,
WebElement
>
reload
()
{
driver
.
get
(
currentUrl
);
driver
.
get
(
currentUrl
);
sleep
();
currentSource
=
driver
.
getPageSource
();
currentSource
=
driver
.
getPageSource
();
getAllElements
(
driver
);
return
getAllElements
(
driver
);
}
}
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
private
void
sleep
()
{
private
void
sleep
()
{
if
(
waitTime
>
0
)
{
try
{
try
{
Thread
.
sleep
(
waitTime
);
Sleeper
.
SYSTEM_SLEEPER
.
sleep
(
Duration
.
ofSeconds
(
2L
)
);
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
}
private
void
getAllElements
(
WebDriver
driver
)
{
private
Map
<
Attributes
,
WebElement
>
getAllElements
(
WebDriver
driver
)
{
elements
.
clear
();
elementMappings
.
clear
();
List
<
WebElement
>
webElements
=
Lists
.
newArrayList
();
driver
.
findElements
(
By
.
xpath
(
"*"
))
driver
.
findElements
(
By
.
xpath
(
"*"
))
.
forEach
(
this
::
getSubElements
);
.
forEach
(
element
->
getSubElements
(
element
,
webElements
));
Document
document
=
Jsoup
.
parse
(
driver
.
getPageSource
());
List
<
Element
>
jElements
=
document
.
getAllElements
().
stream
()
.
filter
(
element
->
element
.
childrenSize
()
==
0
)
.
collect
(
Collectors
.
toList
());
Map
<
Attributes
,
WebElement
>
result
=
Maps
.
newHashMap
();
for
(
int
i
=
0
;
i
<
webElements
.
size
();
i
++)
{
WebElement
webElement
=
webElements
.
get
(
i
);
Element
jElement
=
jElements
.
get
(
i
);
if
(
elementMatch
(
webElement
,
jElement
))
{
result
.
put
(
jElement
.
attributes
(),
webElement
);
}
}
return
result
;
}
}
private
void
getSubElements
(
WebElement
element
)
{
private
void
getSubElements
(
WebElement
element
,
List
<
WebElement
>
elements
)
{
try
{
try
{
List
<
WebElement
>
results
=
element
.
findElements
(
By
.
xpath
(
"*"
));
List
<
WebElement
>
results
=
element
.
findElements
(
By
.
xpath
(
"*"
));
if
(
results
.
isEmpty
())
{
if
(
results
.
isEmpty
())
{
elements
.
add
(
element
);
elements
.
add
(
element
);
}
else
{
}
else
{
results
.
forEach
(
this
::
getSubElements
);
results
.
forEach
(
webElement
->
getSubElements
(
webElement
,
elements
)
);
}
}
}
catch
(
StaleElementReferenceException
ignored
)
{
}
catch
(
StaleElementReferenceException
ignored
)
{
}
}
...
@@ -293,11 +388,19 @@ public class SeleniumExecutor {
...
@@ -293,11 +388,19 @@ public class SeleniumExecutor {
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
private
Boolean
isClickAble
(
WebElement
element
)
{
private
Boolean
isClickAble
(
WebElement
element
)
{
try
{
return
nonNull
(
ExpectedConditions
.
elementToBeClickable
(
element
).
apply
(
driver
));
return
nonNull
(
ExpectedConditions
.
elementToBeClickable
(
element
).
apply
(
driver
));
}
catch
(
Exception
e
){
return
false
;
}
}
}
private
Boolean
isEnabled
(
WebElement
element
)
{
private
Boolean
isEnabled
(
WebElement
element
)
{
try
{
return
nonNull
(
ExpectedConditions
.
elementToBeClickable
(
element
).
apply
(
driver
));
return
nonNull
(
ExpectedConditions
.
elementToBeClickable
(
element
).
apply
(
driver
));
}
catch
(
Exception
e
){
return
false
;
}
}
}
private
String
alterUrlName
(
String
fileName
)
{
private
String
alterUrlName
(
String
fileName
)
{
...
@@ -319,4 +422,41 @@ public class SeleniumExecutor {
...
@@ -319,4 +422,41 @@ public class SeleniumExecutor {
FileUtil
.
output
(
bytes
,
FileUtil
.
WORK_PATH
+
"screenshots\\"
+
name
+
".png"
);
FileUtil
.
output
(
bytes
,
FileUtil
.
WORK_PATH
+
"screenshots\\"
+
name
+
".png"
);
}
}
private
Boolean
elementMatch
(
WebElement
webElement
,
Element
element
)
{
boolean
attributesMatch
=
element
.
attributes
().
asList
().
stream
()
.
allMatch
(
attribute
->
Objects
.
equals
(
attribute
.
getValue
(),
webElement
.
getAttribute
(
attribute
.
getKey
())));
boolean
tagMatch
=
Objects
.
equals
(
webElement
.
getTagName
(),
element
.
tagName
());
boolean
textMatch
=
Objects
.
equals
(
webElement
.
getText
(),
element
.
text
());
if
(
element
.
attributes
().
isEmpty
())
{
if
(
element
.
hasText
())
{
return
tagMatch
&&
textMatch
;
}
else
{
return
tagMatch
;
}
}
else
{
if
(
element
.
hasText
())
{
return
attributesMatch
&&
tagMatch
&&
textMatch
;
}
else
{
return
attributesMatch
&&
tagMatch
;
}
}
}
private
Map
<
Attributes
,
WebElement
>
removeHistoryElements
(
Map
<
Attributes
,
WebElement
>
elements
)
{
Map
<
Attributes
,
WebElement
>
result
=
Maps
.
newHashMap
(
elements
);
elements
.
forEach
((
attributes
,
element
)
->
{
if
(
historyAttributes
.
contains
(
attributes
))
{
result
.
remove
(
attributes
,
element
);
}
});
return
result
;
}
private
void
removeHistoryElements
()
{
elementMappings
.
forEach
((
elementMapping
)
->
{
if
(
historyAttributes
.
contains
(
elementMapping
.
getAttributes
()))
{
elementMappings
.
remove
(
elementMapping
);
}
});
}
}
}
src/test/java/com/zjty/autotest/AutotestApplicationTests.java
浏览文件 @
ddfa4f29
...
@@ -9,18 +9,17 @@ import com.zjty.autotest.pojo.test.Project;
...
@@ -9,18 +9,17 @@ import com.zjty.autotest.pojo.test.Project;
import
com.zjty.autotest.service.impl.SeleniumExecutor
;
import
com.zjty.autotest.service.impl.SeleniumExecutor
;
import
com.zjty.autotest.util.WebDriverUtil
;
import
com.zjty.autotest.util.WebDriverUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.hibernate.boot.jaxb.SourceType
;
import
org.jsoup.Jsoup
;
import
org.jsoup.Jsoup
;
import
org.jsoup.nodes.Attributes
;
import
org.jsoup.nodes.Document
;
import
org.jsoup.nodes.Document
;
import
org.jsoup.nodes.Element
;
import
org.jsoup.nodes.Element
;
import
org.jsoup.select.Elements
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.openqa.selenium.*
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.support.ui.ExpectedConditions
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.support.ui.Sleeper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
java.time.Duration
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -35,8 +34,8 @@ class AutotestApplicationTests {
...
@@ -35,8 +34,8 @@ class AutotestApplicationTests {
@Test
@Test
public
void
execute
()
throws
InterruptedException
{
public
void
execute
()
throws
InterruptedException
{
List
<
Input
>
inputs
=
Lists
.
newArrayList
();
List
<
Input
>
inputs
=
Lists
.
newArrayList
();
inputs
.
add
(
new
Input
(
null
,
null
,
null
,
"caozuoyuan"
));
inputs
.
add
(
new
Input
(
null
,
null
,
null
,
"caozuoyuan123"
));
inputs
.
add
(
new
Input
(
null
,
null
,
null
,
"caozuoyuan123"
));
inputs
.
add
(
new
Input
(
null
,
null
,
null
,
"caozuoyuan"
));
String
url
=
"http://192.168.1.244:8080/person/#/login"
;
String
url
=
"http://192.168.1.244:8080/person/#/login"
;
Project
project
=
new
Project
(
Project
project
=
new
Project
(
...
@@ -57,18 +56,26 @@ class AutotestApplicationTests {
...
@@ -57,18 +56,26 @@ class AutotestApplicationTests {
// Sleeper.SYSTEM_SLEEPER.sleep(Duration.ofSeconds(2));
// Sleeper.SYSTEM_SLEEPER.sleep(Duration.ofSeconds(2));
// String source2 = driver.getPageSource();
// String source2 = driver.getPageSource();
// System.out.println(Objects.equals(source1,source2));
// System.out.println(Objects.equals(source1,source2));
Report
report
=
seleniumExecutor
.
execute
(
project
);
Report
report
=
seleniumExecutor
.
execute
(
project
);
for
(
Measure
measure
:
report
.
getMeasures
())
{
for
(
Measure
measure
:
report
.
getMeasures
())
{
System
.
out
.
println
(
measure
);
System
.
out
.
println
(
measure
);
}
}
// Document document = Jsoup.parse(driver.getPageSource());
// Document document = Jsoup.parse(driver.getPageSource());
// List<Element> elements = document.getAllElements().stream()
// List<Element> elements = document.getAllElements().stream()
// .filter(element -> element.childrenSize() == 0)
// .filter(element -> element.childrenSize() == 0)
// .collect(Collectors.toList());
// .collect(Collectors.toList());
// for (Element element : elements) {
// for (Element element : elements) {
// System.out.println(element.attributes());
// System.out.println("==============================================");
// System.out.println(String.format("tag:%s text:%s attrs:%s",element.tagName(),element.text(),element.attributes()));
// }
// }
}
private
Boolean
elementMatch
(
WebElement
webElement
,
Attributes
Attributes
)
{
return
Attributes
.
asList
().
stream
().
allMatch
(
attribute
->
Objects
.
equals
(
attribute
.
getValue
(),
webElement
.
getAttribute
(
attribute
.
getKey
())));
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论