Selenium+Java+屏幕记录器-无法录制屏幕

Selenium+Java+屏幕记录器-无法录制屏幕,java,selenium-webdriver,video,screen-recording,Java,Selenium Webdriver,Video,Screen Recording,我已经创建了下一个用于在Selenium Webriver自动化中录制视频的类 首先,我在POM中使用Monte Media jar依赖项: <dependency> <groupId>com.github.stephenc.monte</groupId> <artifactId>monte-screen-recorder</artifactId> <version>0.7.

我已经创建了下一个用于在Selenium Webriver自动化中录制视频的类

首先,我在POM中使用Monte Media jar依赖项:

 <dependency>
        <groupId>com.github.stephenc.monte</groupId>
        <artifactId>monte-screen-recorder</artifactId>
        <version>0.7.7.0</version>
    </dependency>
我想做的是调用静态void方法来开始录制iniciaGrabacion,并停止从任何其他类重新录制finalizaGrabacion,而不是在我发布的同一个类中

public static void iniciaGrabacion(InternetExplorerDriver driver)throws Exception{

    //Método para comenzar de la grabación.
    screenRecorder.start();

}

public static void finalizaGrabacion(InternetExplorerDriver driver)throws Exception{

    //Método para finalizar de la grabación.
    screenRecorder.stop();
我运行任何其他类,使用以下行调用这些方法:

Video.iniciaGrabacion((InternetExplorerDriver)driver);
截止日期:

Video.finalizaGrabacion((InternetExplorerDriver)driver);
但我面临着下一个问题:

java.lang.NullPointerException
at cl.chilito.util.report.Video.iniciaGrabacion(Video.java:63)
at cl.chile.automatizacion.casos.prestamos.PrestamoNuevoK.PrestamoNuevoK(PrestamoNuevoK.java:97)
at cl.chile.automatizacion.casos.prestamos.PrestamoNuevoK.testPrestamoNuevoK(PrestamoNuevoK.java:78)
有人能帮我吗

public static void startRecording() throws Exception
    {

    File file = new File("C:\\videos");

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int width = screenSize.width;
    int height = screenSize.height;

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


    GraphicsConfiguration gc = GraphicsEnvironment
            .getLocalGraphicsEnvironment()
            .getDefaultScreenDevice()
            .getDefaultConfiguration();


    screenRecorder = new VideoRecorder(gc, captureSize,
            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, "Video"); //Video puede ser cambiado al nombre que deseen
    screenRecorder.start();
}
以及停止方法:

public static void stopRecording() throws Exception
    {
        screenRecorder.stop();
    }
从外部类调用:

Classname.startRecording; Classname.stopRecording


工作正常。

此问题中焦点的可能重复是关于屏幕视频录制,NullPointException只是结果。
public static void stopRecording() throws Exception
    {
        screenRecorder.stop();
    }