Skip to content

Commit 1152e99

Browse files
committed
Fixed screenshot path incorrect issue.
1 parent 3167f6f commit 1152e99

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

src/main/java/com/github/ansonliao/selenium/internal/ScreenshotManager.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,15 @@ public String capture(Class<?> clazz, String imgPrefix, String browserName) {
1515
File scrFile = ((TakesScreenshot) WDManager.getDriver())
1616
.getScreenshotAs(OutputType.FILE);
1717

18-
String destDir = Constants.SCREENSHOT_DIR
19-
.concat(Constants.FILE_SEPARATOR)
20-
.concat(clazz.getPackage().getName())
21-
.concat(Constants.FILE_SEPARATOR)
22-
.concat(this.getClass().getSimpleName())
23-
.concat(Constants.FILE_SEPARATOR)
24-
.concat(browserName)
25-
.concat(Constants.FILE_SEPARATOR)
26-
.concat(imgPrefix)
27-
.concat("_")
28-
.concat(String.valueOf(new Timestamp(System.currentTimeMillis()).getTime()))
29-
.concat(".jpeg");
18+
String destDir = String.join(
19+
Constants.FILE_SEPARATOR,
20+
Constants.SCREENSHOT_DIR,
21+
clazz.getPackage().getName(),
22+
clazz.getSimpleName(),
23+
browserName,
24+
imgPrefix.concat("_").concat(String.valueOf(
25+
new Timestamp(System.currentTimeMillis()).getTime()))
26+
.concat(".jpeg"));
3027
try {
3128
MyFileUtils.copyFile(scrFile, new File(destDir));
3229
} catch (IOException e) {

src/main/java/com/github/ansonliao/selenium/utils/MyFileUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public static synchronized File createScreenshotFolderForBrowser(
1111
Class clazz, String browserName) {
1212
String className = clazz.getSimpleName();
1313
String packageName = clazz.getPackage().getName();
14-
String destDir = Constants.SCREENSHOT_DIR + Constants.FILE_SEPARATOR
15-
+ packageName + Constants.FILE_SEPARATOR
16-
+ className + Constants.FILE_SEPARATOR + browserName;
14+
String destDir = String.join(
15+
Constants.FILE_SEPARATOR, Constants.SCREENSHOT_DIR,
16+
packageName, className, browserName);
1717

1818
if ((new File(destDir)).exists()) {
1919
return new File(destDir);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.github.ansonliao.selenium.utils;
2+
3+
public class SEFilterUtils {
4+
5+
//public static boolean addBrowserGroupToReport() {
6+
// final String KEY = "addBrowserGroupToReport";
7+
//
8+
//}
9+
}

0 commit comments

Comments
 (0)