Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to screencast automated tests using Java? [closed]

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.

like image 726
Manu Avatar asked Nov 20 '15 14:11

Manu


People also ask

How Java is used in automation Testing?

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.

How do you automate test cases in TestNG?

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.

What is selenium WebDriver and how can we use it with Java?

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.


3 Answers

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();
    }
like image 98
Keshav Avatar answered Oct 13 '22 05:10

Keshav


An another option would be to run your tests remotely on BrowserStack or Sauce Labs - both services have test run Video Recording available.

like image 3
alecxe Avatar answered Oct 13 '22 04:10

alecxe


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

like image 2
Jens Schauder Avatar answered Oct 13 '22 05:10

Jens Schauder