Skip to content

Commit

Permalink
1. Updated capture image by new library "AShot".
Browse files Browse the repository at this point in the history
2. Updated checkstyle plugin version to 8.18 version at least.
  • Loading branch information
ansonliao committed Jun 26, 2019
1 parent ad22831 commit 85a68fb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
22 changes: 19 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.github.ansonliao</groupId>
<artifactId>Selenium-Extensions</artifactId>
<version>2.3.7-1qaz2wedc</version>
<version>2.3.7</version>
<packaging>jar</packaging>

<name>Selenium-Extensions</name>
Expand Down Expand Up @@ -41,7 +41,7 @@
<maven.jxr.plugin.version>2.3</maven.jxr.plugin.version>
<webdrivermanager.version>2.2.5</webdrivermanager.version>
<thoughtworks.qdox.version>2.0-M7</thoughtworks.qdox.version>
<puppycrawl.checkstyle.version>6.1.1</puppycrawl.checkstyle.version>
<puppycrawl.checkstyle.version>8.18</puppycrawl.checkstyle.version>
<maven.compiler.plugin.version>3.6.0</maven.compiler.plugin.version>
<maven.surefire.plugin.version>2.19.1</maven.surefire.plugin.version>
<fast.classpath.scanner.version>2.7.5</fast.classpath.scanner.version>
Expand All @@ -50,6 +50,7 @@
<aeonbits.owner.version>1.0.10</aeonbits.owner.version>
<gson.version>2.8.5</gson.version>
<jsonpath.version>2.4.0</jsonpath.version>
<ashot.version>1.5.2</ashot.version>
<dependency.locations.enabled>false</dependency.locations.enabled>
</properties>

Expand Down Expand Up @@ -89,6 +90,21 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.ashot</groupId>
<artifactId>ashot</artifactId>
<version>${ashot.version}</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</exclusion>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down Expand Up @@ -185,7 +201,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${puppycrawl.checkstyle.version}</version>
<version>[${puppycrawl.checkstyle.version},)</version>
</dependency>
</dependencies>
<configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import com.github.ansonliao.selenium.utils.MyFileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import ru.yandex.qatools.ashot.AShot;

import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
Expand All @@ -19,8 +21,8 @@ public class ScreenshotManager {
.concat("screenshots");

public String capture(Class<?> clazz, String imgPrefix, String browserName) {
File scrFile = ((TakesScreenshot) WDManager.getDriver())
.getScreenshotAs(OutputType.FILE);
// File scrFile = ((TakesScreenshot) WDManager.getDriver())
// .getScreenshotAs(OutputType.FILE);

String destDir = String.join(
FILE_SEPARATOR,
Expand All @@ -32,7 +34,11 @@ public String capture(Class<?> clazz, String imgPrefix, String browserName) {
new Timestamp(System.currentTimeMillis()).getTime()))
.concat(".jpeg"));
try {
MyFileUtils.copyFile(scrFile, new File(destDir));
// MyFileUtils.copyFile(scrFile, new File(destDir));
ImageIO.write(
new AShot().takeScreenshot(WDManager.getDriver()).getImage(),
"PNG",
new File(destDir));
} catch (IOException e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 85a68fb

Please sign in to comment.