3434public class CaptureHelpers extends ScreenRecorder {
3535
3636 // ------Record with Monte Media library---------
37- public static ScreenRecorder screenRecorder ;
38- public String name ;
37+ private static ScreenRecorder screenRecorder ;
38+ private static String name ;
3939 private static SimpleDateFormat dateFormat = new SimpleDateFormat ("dd-MM-yyyy HH-mm-ss" );
40- private static PropertiesHelpers propertiesHelpers = new PropertiesHelpers ();
4140
4241 //Hàm xây dựng
4342 public CaptureHelpers (GraphicsConfiguration cfg , Rectangle captureArea , Format fileFormat , Format screenFormat ,
@@ -53,41 +52,40 @@ protected File createMovieFile(Format fileFormat) throws IOException {
5352 if (!movieFolder .exists ()) {
5453 movieFolder .mkdirs ();
5554 } else if (!movieFolder .isDirectory ()) {
56- throw new IOException (" \" " + movieFolder + " \ " is not a directory." );
55+ throw new IOException (movieFolder + " is not a directory." );
5756 }
58-
5957 return new File (movieFolder ,
60- name + "- " + dateFormat .format (new Date ()) + "." + Registry .getInstance ().getExtension (fileFormat ));
58+ name + "_ " + dateFormat .format (new Date ()) + "." + Registry .getInstance ().getExtension (fileFormat ));
6159 }
6260
6361 // Hàm Start record video
6462 public static void startRecord (String methodName ) {
6563 //Tạo thư mục để lưu file video vào
66- File file = new File ("./" + FrameworkConstants .ExportVideoPath + "/" + methodName + "/" );
64+ File file = new File ("./" + FrameworkConstants .EXPORT_VIDEO_PATH + "/" + methodName + "/" );
6765 Dimension screenSize = Toolkit .getDefaultToolkit ().getScreenSize ();
6866 int width = screenSize .width ;
6967 int height = screenSize .height ;
7068
69+ System .out .println ("width" + width );
70+ System .out .println ("height" + height );
71+
7172 Rectangle captureSize = new Rectangle (0 , 0 , width , height );
7273
73- GraphicsConfiguration gc = GraphicsEnvironment .getLocalGraphicsEnvironment ().getDefaultScreenDevice ()
74+ GraphicsConfiguration gc = GraphicsEnvironment
75+ .getLocalGraphicsEnvironment ()
76+ .getDefaultScreenDevice ()
7477 .getDefaultConfiguration ();
7578 try {
76- screenRecorder = new CaptureHelpers (gc , captureSize ,
79+ screenRecorder = new CaptureHelpers (gc , null ,
7780 new Format (MediaTypeKey , MediaType .FILE , MimeTypeKey , MIME_AVI ),
7881 new Format (MediaTypeKey , MediaType .VIDEO , EncodingKey , ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE ,
7982 CompressorNameKey , ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE , DepthKey , 24 , FrameRateKey ,
8083 Rational .valueOf (15 ), QualityKey , 1.0f , KeyFrameIntervalKey , 15 * 60 ),
8184 new Format (MediaTypeKey , MediaType .VIDEO , EncodingKey , "black" , FrameRateKey , Rational .valueOf (30 )),
8285 null , file , methodName );
83- } catch (IOException e ) {
84- e .printStackTrace ();
85- } catch (AWTException e ) {
86- e .printStackTrace ();
87- }
88- try {
86+
8987 screenRecorder .start ();
90- } catch (IOException e ) {
88+ } catch (IOException | AWTException e ) {
9189 e .printStackTrace ();
9290 }
9391 }
@@ -103,7 +101,7 @@ public static void stopRecord() {
103101
104102 public static void captureScreenshot (WebDriver driver , String screenName ) {
105103 try {
106- String path = Helpers .getCurrentDir () + FrameworkConstants .ExportCapturePath ;
104+ String path = Helpers .getCurrentDir () + FrameworkConstants .EXPORT_CAPTURE_PATH ;
107105 File file = new File (path );
108106 if (!file .exists ()) {
109107 Log .info ("No Folder: " + path );
0 commit comments