提交 80ca467d authored 作者: 黄承天's avatar 黄承天

补充ActResult类

上级 39c9ec08
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;
}
...@@ -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.toSet()); .collect(Collectors.toList()));
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论