Skip to content

Commit 9320378

Browse files
committed
Update version 1.9.1
1 parent d6e9d2c commit 9320378

7 files changed

Lines changed: 128 additions & 89 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ ExtentReports.zip
1111
reports
1212
*.png
1313
*.jpg
14+
EmailConfig.java
15+
config.properties
1416

pom.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>anhtester.com</groupId>
88
<artifactId>AutomationFrameworkSelenium</artifactId>
9-
<version>1.8.2</version>
9+
<version>1.9.1</version>
1010
<name>AutomationFrameworkSelenium</name>
1111
<url>https://github.com/anhtester/AutomationFrameworkSelenium</url>
1212

@@ -18,13 +18,13 @@
1818
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
1919
<selenium.version>4.6.0</selenium.version>
2020
<testng.version>7.4.0</testng.version>
21-
<webdrivermanager.version>5.3.0</webdrivermanager.version>
21+
<webdrivermanager.version>5.3.1</webdrivermanager.version>
2222
<aspectjweaver.version>1.9.9.1</aspectjweaver.version>
2323
<ashot.version>1.5.4</ashot.version>
2424
<log4j.version>2.19.0</log4j.version>
25-
<slf4j.version>2.0.3</slf4j.version>
26-
<allure-testng.version>2.19.0</allure-testng.version>
27-
<allure-maven.version>2.10.0</allure-maven.version>
25+
<slf4j.version>2.0.4</slf4j.version>
26+
<allure-testng.version>2.20.0</allure-testng.version>
27+
<allure-maven.version>2.12.0</allure-maven.version>
2828
<allure-environment-writer.version>1.0.0</allure-environment-writer.version>
2929
<allure.cmd.download.url>
3030
https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline
@@ -37,12 +37,12 @@
3737
<javafaker.version>1.0.2</javafaker.version>
3838
<monte-screen-recorder.version>0.7.7.0</monte-screen-recorder.version>
3939
<mysql-connector-java.version>8.0.30</mysql-connector-java.version>
40-
<google.zxing.version>3.5.0</google.zxing.version>
40+
<google.zxing.version>3.5.1</google.zxing.version>
4141
<lombok.version>1.18.24</lombok.version>
4242
<google.guava.version>31.1-jre</google.guava.version>
4343
<javax.mail.version>1.6.2</javax.mail.version>
4444
<zip.version>1.15</zip.version>
45-
<jackson.version>2.13.4</jackson.version>
45+
<jackson.version>2.14.0</jackson.version>
4646

4747
<!-- Suite XML path -->
4848
<suite.signin.simple>src/test/resources/suites/SignIn-simple.xml</suite.signin.simple>
@@ -170,7 +170,7 @@
170170
<dependency>
171171
<groupId>tech.grasshopper</groupId>
172172
<artifactId>pdfextentreporter</artifactId>
173-
<version>1.3.1</version>
173+
<version>1.3.2</version>
174174
</dependency>
175175

176176
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->

src/main/java/anhtester/com/helpers/CaptureHelpers.java

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
import org.openqa.selenium.TakesScreenshot;
1818
import org.openqa.selenium.WebDriver;
1919

20+
import javax.imageio.ImageIO;
2021
import java.awt.*;
22+
import java.awt.image.BufferedImage;
2123
import java.io.File;
2224
import java.io.IOException;
2325
import java.text.SimpleDateFormat;
@@ -39,8 +41,7 @@ public class CaptureHelpers extends ScreenRecorder {
3941
private static SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH-mm-ss");
4042

4143
//Hàm xây dựng
42-
public CaptureHelpers(GraphicsConfiguration cfg, Rectangle captureArea, Format fileFormat, Format screenFormat,
43-
Format mouseFormat, Format audioFormat, File movieFolder, String name) throws IOException, AWTException {
44+
public CaptureHelpers(GraphicsConfiguration cfg, Rectangle captureArea, Format fileFormat, Format screenFormat, Format mouseFormat, Format audioFormat, File movieFolder, String name) throws IOException, AWTException {
4445
super(cfg, captureArea, fileFormat, screenFormat, mouseFormat, audioFormat, movieFolder);
4546
this.name = name;
4647
}
@@ -54,8 +55,7 @@ protected File createMovieFile(Format fileFormat) throws IOException {
5455
} else if (!movieFolder.isDirectory()) {
5556
throw new IOException(movieFolder + " is not a directory.");
5657
}
57-
return new File(movieFolder,
58-
name + "_" + dateFormat.format(new Date()) + "." + Registry.getInstance().getExtension(fileFormat));
58+
return new File(movieFolder, name + "_" + dateFormat.format(new Date()) + "." + Registry.getInstance().getExtension(fileFormat));
5959
}
6060

6161
// Hàm Start record video
@@ -71,18 +71,9 @@ public static void startRecord(String methodName) {
7171

7272
Rectangle captureSize = new Rectangle(0, 0, width, height);
7373

74-
GraphicsConfiguration gc = GraphicsEnvironment
75-
.getLocalGraphicsEnvironment()
76-
.getDefaultScreenDevice()
77-
.getDefaultConfiguration();
74+
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
7875
try {
79-
screenRecorder = new CaptureHelpers(gc, null,
80-
new Format(MediaTypeKey, MediaType.FILE, MimeTypeKey, MIME_AVI),
81-
new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE,
82-
CompressorNameKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, DepthKey, 24, FrameRateKey,
83-
Rational.valueOf(15), QualityKey, 1.0f, KeyFrameIntervalKey, 15 * 60),
84-
new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, "black", FrameRateKey, Rational.valueOf(30)),
85-
null, file, methodName);
76+
screenRecorder = new CaptureHelpers(gc, null, new Format(MediaTypeKey, MediaType.FILE, MimeTypeKey, MIME_AVI), new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, CompressorNameKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, DepthKey, 24, FrameRateKey, Rational.valueOf(15), QualityKey, 1.0f, KeyFrameIntervalKey, 15 * 60), new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, "black", FrameRateKey, Rational.valueOf(30)), null, file, methodName);
8677

8778
screenRecorder.start();
8879
} catch (IOException | AWTException e) {
@@ -123,4 +114,32 @@ public static void captureScreenshot(WebDriver driver, String screenName) {
123114
}
124115
}
125116

117+
public static File getScreenshot(String screenshotName) {
118+
Rectangle allScreenBounds = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
119+
String dateName = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss.SSS").format(new Date());
120+
BufferedImage image = null;
121+
try {
122+
image = new Robot().createScreenCapture(allScreenBounds);
123+
} catch (AWTException e) {
124+
throw new RuntimeException(e);
125+
}
126+
127+
String path = Helpers.getCurrentDir() + FrameworkConstants.EXTENT_REPORT_FOLDER + File.separator + "images";
128+
File folder = new File(path);
129+
if (!folder.exists()) {
130+
folder.mkdir();
131+
Log.info("Folder created: " + folder);
132+
}
133+
134+
String filePath = path + File.separator + screenshotName + dateName + ".png";
135+
File file = new File(filePath);
136+
try {
137+
ImageIO.write(image, "PNG", file);
138+
} catch (IOException e) {
139+
throw new RuntimeException(e);
140+
}
141+
return file;
142+
}
143+
144+
126145
}

0 commit comments

Comments
 (0)