Skip to content

Commit 85a68fb

Browse files
committed
1. Updated capture image by new library "AShot".
2. Updated checkstyle plugin version to 8.18 version at least.
1 parent ad22831 commit 85a68fb

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

pom.xml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.github.ansonliao</groupId>
66
<artifactId>Selenium-Extensions</artifactId>
7-
<version>2.3.7-1qaz2wedc</version>
7+
<version>2.3.7</version>
88
<packaging>jar</packaging>
99

1010
<name>Selenium-Extensions</name>
@@ -41,7 +41,7 @@
4141
<maven.jxr.plugin.version>2.3</maven.jxr.plugin.version>
4242
<webdrivermanager.version>2.2.5</webdrivermanager.version>
4343
<thoughtworks.qdox.version>2.0-M7</thoughtworks.qdox.version>
44-
<puppycrawl.checkstyle.version>6.1.1</puppycrawl.checkstyle.version>
44+
<puppycrawl.checkstyle.version>8.18</puppycrawl.checkstyle.version>
4545
<maven.compiler.plugin.version>3.6.0</maven.compiler.plugin.version>
4646
<maven.surefire.plugin.version>2.19.1</maven.surefire.plugin.version>
4747
<fast.classpath.scanner.version>2.7.5</fast.classpath.scanner.version>
@@ -50,6 +50,7 @@
5050
<aeonbits.owner.version>1.0.10</aeonbits.owner.version>
5151
<gson.version>2.8.5</gson.version>
5252
<jsonpath.version>2.4.0</jsonpath.version>
53+
<ashot.version>1.5.2</ashot.version>
5354
<dependency.locations.enabled>false</dependency.locations.enabled>
5455
</properties>
5556

@@ -89,6 +90,21 @@
8990
</exclusion>
9091
</exclusions>
9192
</dependency>
93+
<dependency>
94+
<groupId>ru.yandex.qatools.ashot</groupId>
95+
<artifactId>ashot</artifactId>
96+
<version>${ashot.version}</version>
97+
<exclusions>
98+
<exclusion>
99+
<groupId>org.seleniumhq.selenium</groupId>
100+
<artifactId>selenium-java</artifactId>
101+
</exclusion>
102+
<exclusion>
103+
<groupId>org.hamcrest</groupId>
104+
<artifactId>hamcrest-all</artifactId>
105+
</exclusion>
106+
</exclusions>
107+
</dependency>
92108
<dependency>
93109
<groupId>org.slf4j</groupId>
94110
<artifactId>slf4j-api</artifactId>
@@ -185,7 +201,7 @@
185201
<dependency>
186202
<groupId>com.puppycrawl.tools</groupId>
187203
<artifactId>checkstyle</artifactId>
188-
<version>${puppycrawl.checkstyle.version}</version>
204+
<version>[${puppycrawl.checkstyle.version},)</version>
189205
</dependency>
190206
</dependencies>
191207
<configuration>

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import com.github.ansonliao.selenium.utils.MyFileUtils;
55
import org.openqa.selenium.OutputType;
66
import org.openqa.selenium.TakesScreenshot;
7+
import ru.yandex.qatools.ashot.AShot;
78

9+
import javax.imageio.ImageIO;
810
import java.io.File;
911
import java.io.IOException;
1012
import java.sql.Timestamp;
@@ -19,8 +21,8 @@ public class ScreenshotManager {
1921
.concat("screenshots");
2022

2123
public String capture(Class<?> clazz, String imgPrefix, String browserName) {
22-
File scrFile = ((TakesScreenshot) WDManager.getDriver())
23-
.getScreenshotAs(OutputType.FILE);
24+
// File scrFile = ((TakesScreenshot) WDManager.getDriver())
25+
// .getScreenshotAs(OutputType.FILE);
2426

2527
String destDir = String.join(
2628
FILE_SEPARATOR,
@@ -32,7 +34,11 @@ public String capture(Class<?> clazz, String imgPrefix, String browserName) {
3234
new Timestamp(System.currentTimeMillis()).getTime()))
3335
.concat(".jpeg"));
3436
try {
35-
MyFileUtils.copyFile(scrFile, new File(destDir));
37+
// MyFileUtils.copyFile(scrFile, new File(destDir));
38+
ImageIO.write(
39+
new AShot().takeScreenshot(WDManager.getDriver()).getImage(),
40+
"PNG",
41+
new File(destDir));
3642
} catch (IOException e) {
3743
e.printStackTrace();
3844
}

0 commit comments

Comments
 (0)