使用 JAVA 在 selenium 中执行测试的屏幕录制

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29415669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 15:13:56  来源:igfitidea点击:

Screen recording of a test execution in selenium using JAVA

javaseleniumtestng

提问by Zoso619

I have created an automation program using java selenium.I have used TestNG framework. I want to record (video) of the screen those are getting executed during the script execution so it is better to track the failed/passed scenario and view the execution process.

我使用 java selenium 创建了一个自动化程序。我使用了 TestNG 框架。我想记录在脚本执行期间执行的屏幕(视频),因此最好跟踪失败/通过的场景并查看执行过程。

Can any one help me with this, how to record the screen during running the automation suite execution.

任何人都可以帮我解决这个问题,如何在运行自动化套件执行期间记录屏幕。

回答by LittlePanda

See this API (Monte Library): http://www.seleniummonster.com/boost-up-your-selenium-tests-with-video-recording-capability/

请参阅此 API(蒙特库):http: //www.seleniummonster.com/boost-up-your-selenium-tests-with-video-recording-capability/

and this link: http://unmesh.me/2012/01/13/recording-screencast-of-selenium-tests-in-java/

和这个链接:http: //unmesh.me/2012/01/13/recording-screencast-of-selenium-tests-in-java/

Example Code (from above links):

示例代码(来自上面的链接):

public void startRecording() throws Exception
{
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
this.screenRecorder = new ScreenRecorder(gc,
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);
this.screenRecorder.start();
}
public void stopRecording() throws Exception
{
this.screenRecorder.stop();
}