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

修正截图资源路径

上级 e65c8c07
...@@ -45,6 +45,9 @@ public class SeleniumExecutor { ...@@ -45,6 +45,9 @@ public class SeleniumExecutor {
@Value("${selenium.executor.wait-after-click}") @Value("${selenium.executor.wait-after-click}")
private Long waitTime; private Long waitTime;
@Value("${screenshot-path}")
private String screenshotPath;
@Value("${selenium.executor.screenshot.url-host}") @Value("${selenium.executor.screenshot.url-host}")
private String screenshotPrefixHost; private String screenshotPrefixHost;
...@@ -139,9 +142,9 @@ public class SeleniumExecutor { ...@@ -139,9 +142,9 @@ public class SeleniumExecutor {
//如果出错 则提供截图 //如果出错 则提供截图
String screenshot = null; String screenshot = null;
if (!success) { if (!success) {
String screenshotName = alterUrlName(currentUrl); String screenshotName = alterUrlName(currentUrl) + ".png";
screenshot(screenshotName); screenshot(screenshotName);
screenshot = String.format("http://%s:%s/screenshots/%s", screenshotPrefixHost, screenshotPrefixPort, screenshotName); screenshot = String.format("http://%s:%s/%s", screenshotPrefixHost, screenshotPrefixPort, screenshotName);
} }
//总合信息 //总合信息
Set<String> messages = elementDetails.stream() Set<String> messages = elementDetails.stream()
...@@ -389,7 +392,13 @@ public class SeleniumExecutor { ...@@ -389,7 +392,13 @@ public class SeleniumExecutor {
private void screenshot(String name) { private void screenshot(String name) {
byte[] bytes = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); byte[] bytes = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
FileUtil.output(bytes, FileUtil.WORK_PATH + "screenshots\\" + name + ".png"); String path;
if (screenshotPath.endsWith("/")) {
path = screenshotPath + name;
} else {
path = screenshotPath + "/" + name;
}
FileUtil.output(bytes, path);
} }
private Boolean elementMatch(WebElement webElement, Element element) { private Boolean elementMatch(WebElement webElement, Element element) {
...@@ -430,7 +439,7 @@ public class SeleniumExecutor { ...@@ -430,7 +439,7 @@ public class SeleniumExecutor {
private String checkJsError() { private String checkJsError() {
try { try {
return analyseLogError(driver.manage().logs().get(LogType.BROWSER).getAll().stream().findFirst().get()); return analyseLogError(driver.manage().logs().get(LogType.BROWSER).getAll().stream().findFirst().get());
} catch (Exception e){ } catch (Exception e) {
return null; return null;
} }
} }
......
...@@ -8,7 +8,8 @@ spring.jpa.hibernate.ddl-auto=update ...@@ -8,7 +8,8 @@ spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.show-sql=false spring.jpa.show-sql=false
spring.resources.static-locations=classpath:/adapter/ spring.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/adapter/,file:${screenshot-path}
uploadFile=E:/opt/auto/test/zr/ uploadFile=E:/opt/auto/test/zr/
uploadUnFile=E:/opt/auto/test/un/ uploadUnFile=E:/opt/auto/test/un/
...@@ -17,9 +18,10 @@ spring.servlet.multipart.max-file-size=500MB ...@@ -17,9 +18,10 @@ spring.servlet.multipart.max-file-size=500MB
spring.servlet.multipart.max-request-size=500MB spring.servlet.multipart.max-request-size=500MB
# Selenium\u00FF\uFFFD\u03B5\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0135\u0234\uFFFD\u02B1\uFFFD\u48E8\uFFFD\uFFFD\uFFFD\uB8E9\uFFFD\uFFFD0\u03AA\uFFFD\uFFFD\uFFFD\u0234\uFFFD\uFFFD\uFFFD screenshot-path=C:/MyProjects/auto-test/src/main/resources/screenshots/
selenium.executor.wait-after-click=6 selenium.executor.wait-after-click=6
# Selenium\uFFFD\u1E69\uFFFD\uFFFD\u037CURL\uFFFD\u0135\uFFFD\u05B7\u01F0\u05FA\uFFFD\uFFFDip\uFFFD\uFFFD
selenium.executor.screenshot.url-host=localhost selenium.executor.screenshot.url-host=localhost
# Selenium\uFFFD\u1E69\uFFFD\uFFFD\u037CURL\uFFFD\u0135\uFFFD\u05B7\u01F0\u05FA\uFFFD\uFFFDip\uFFFD\uFFFD
selenium.executor.screenshot.url-port=13500 selenium.executor.screenshot.url-port=13500
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论