提交 94c58e3a authored 作者: 黄承天's avatar 黄承天

完成遍历测试执行类与方法

上级 e5dccc09
......@@ -101,6 +101,12 @@
<artifactId>selenium-java</artifactId>
<version>4.0.0-alpha-4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
</dependencies>
<build>
......
package com.zjty.autotest.pojo.report;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* <p>Description : autotest
* <p>Date : 2020/3/24 11:15
* <p>@author : C
* 元素测试信息
*/
public class Detail {
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ElementDetail {
/**
* 元素类型
......@@ -17,11 +25,6 @@ public class Detail {
*/
private Integer responseTime;
/**
* 路径
*/
private String url;
/**
* 是否通过
*/
......@@ -31,4 +34,5 @@ public class Detail {
* 信息(未通过理由)
*/
private String message;
}
......@@ -44,4 +44,8 @@ public class Measure {
*/
private String screenshot;
/**
* 所有元素测试信息
*/
private List<ElementDetail> elementDetails;
}
......@@ -3,7 +3,6 @@ package com.zjty.autotest.service;
import org.springframework.stereotype.Service;
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection")
@Service
public class TransHelper {
......
......@@ -9,18 +9,21 @@ import com.zjty.autotest.pojo.test.Project;
import com.zjty.autotest.service.impl.SeleniumExecutor;
import com.zjty.autotest.util.WebDriverUtil;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.logging.LogType;
import org.openqa.selenium.logging.LoggingPreferences;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Sleeper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.time.Duration;
import java.util.*;
import java.util.logging.Level;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Slf4j
@SpringBootTest
......@@ -30,10 +33,10 @@ class AutotestApplicationTests {
SeleniumExecutor seleniumExecutor;
@Test
public void execute() {
public void execute() throws InterruptedException {
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, "caozuoyuan"));
inputs.add(new Input(null, null, null, "caozuoyuan123"));
String url = "http://192.168.1.244:8080/person/#/login";
Project project = new Project(
......@@ -43,9 +46,29 @@ class AutotestApplicationTests {
url,
inputs
);
// String url2 = "file:///C:/code/wps/index.html";
// WebDriver driver = WebDriverUtil.getWebDriver("firefox");
// driver.manage().timeouts().pageLoadTimeout(4L, TimeUnit.SECONDS);
// driver.get(url);
// Sleeper.SYSTEM_SLEEPER.sleep(Duration.ofSeconds(2));
// String source1 = driver.getPageSource();
// driver.get(url2);
// driver.get(url);
// Sleeper.SYSTEM_SLEEPER.sleep(Duration.ofSeconds(2));
// String source2 = driver.getPageSource();
// System.out.println(Objects.equals(source1,source2));
Report report = seleniumExecutor.execute(project);
for (Measure measure : report.getMeasures()) {
System.out.println(measure);
}
// Document document = Jsoup.parse(driver.getPageSource());
// List<Element> elements = document.getAllElements().stream()
// .filter(element -> element.childrenSize() == 0)
// .collect(Collectors.toList());
// for (Element element : elements) {
// System.out.println(element.attributes());
// }
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论