I am currently working on automating my tests using Selenium with TestNg and Java. I am able to take screenshot while the tests are running, but there are some situations where the test passes when ideally it should have failed.
So, Is there any java tool that can help in recording the running Selenium tests?
Basically, I want to add screen-cast to my framework. I searched a lot on web/SO but could not find any relevant resources. Any help or suggestion is welcome.
Automation testing using Selenium with Java has made life easier for both developers and testers. Being an open-source tool, it provides an opportunity to speed up the time of execution and to remove manual redundancy and human-prone errors.
Step 1: Create a package and name it test. This package will contain all our test class files. Step 2: Inside this package, add a new class VerifySetup, add the following code, and save it. Step 3: Now execute this as a TestNG test to verify the setup.
Selenium WebDriver is a web framework that permits you to execute cross-browser tests. This tool is used for automating web-based application testing to verify that it performs expectedly. Selenium WebDriver allows you to choose a programming language to create test scripts.
You can use java code record your Test video, for this code to run you also need to add jar file to your project : Reference : Road to automation
@BeforeSuite
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();
}
@AfterSuite
public void stopRecording() throws Exception {
this.screenRecorder.stop();
}
An another option would be to run your tests remotely on BrowserStack or Sauce Labs - both services have test run Video Recording available.
One approach would be to do screenshot after each step and then combining them into a video. The answers to this questions provide a couple of candidate libraries for this task.
Another idea would be to actually do a screencast while performing the test, using some browser plugin. But I'm not sure how one would start the recording process. It might be possible to send the short cut for start/stop recording with selenium, but I'm not sure if that would work. For such plugins I can't offer more than a google search
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With