Saturday, 1 March 2014

How to record selenium test execution?

Ever wanted to record your test execution so that you can check where exactly it took the wrong turn?

We have something for you. Try our test recorder. It records the test execution test case wise and stores in ".mov" files.



Where can you get the test recorder?
Ans: You can find the jar here : Stable version: v2.1



What additional work you have to do for this?
Ans: You just have to add 3 lines of code for
    1. Setting up a recorder
    2. Starting the recorder
    3. Stopping the recorder
And its done.


Example:



ATUTestRecorder recorder = new ATUTestRecorder("Directory","filename",false);
recorder.start(); 
WebDriver browser = new FirefoxDriver();
browser.navigate().to("http://www.w3schools.com/ajax/ajax_database.asp");
browser.manage().window().maximize();  
browser.quit();
recorder.stop();



You have options to set some specific name to the recording file and to enable/disable audio recording. These options can be set while creating instance of TestRecorder class.

#Happy Recording
-AT

42 comments:

  1. HI .,
    Thanks for u r post..and one more thing am getting error while running this program
    Pls check the error what i am getting ..

    Strating TestRecorder..,
    Recording in Progress...
    FAILED: urlopen
    java.lang.IllegalArgumentException: No line matching interface TargetDataLine supporting format PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, big-endian is supported.
    at javax.sound.sampled.AudioSystem.getLine(Unknown Source)

    ReplyDelete
  2. Hi

    We are not able to reproduce the error that you got. However you can avoid the error by disabling the audio recording option.

    In the below statement
    TestRecorder recorder = new TestRecorder("filename",true);
    If you pass false as second parameter for the constructor the audio recording will be disabled and the error will be avoided.

    Let us know if this helps you.

    -AT

    ReplyDelete
  3. Hi ATU..
    Its a great Utility you have provided for Tester

    Thanks for it

    Regards
    Sujan

    ReplyDelete
  4. Hi Sujan,

    Thank you.. We have used external libraries for achieving this. Thanks to open source community.

    #AT

    ReplyDelete
  5. Hi i got "Fatal exception occurred. Program will exit.", while doing test recorder , but the rest of the code is working fine when i comment the test report lines, please resolve

    ReplyDelete
  6. AT-

    I need to execute the 2 test cases which are in the two .java files. When they are running i want to record the whole actions. Here i need to add start and stop methods in both the .java files and I am getting two video files. What should i do if want to make it as single video file if i have many no of test cases and each having single .java file ( Mean Test Set run)

    ReplyDelete
    Replies
    1. Ravi,

      The two java files are independently executed - so are the two video files produced. you can create a new java file and call these two classes, thereby you can get a single video recording but this is not what you would prefer to do.

      The ATU Reporter will be integrated with Recording feature. This feature will simplify the process, you will have several options to play more with the code :)

      #AT

      Delete
  7. Hello AT, First of all exceptional reporting and the best reporting till date for selenium. Below is my code am facing an error. plese help me
    ATUTestRecorder recorder = new ATUTestRecorder("G:\\record", true);
    recorder.start();
    setAuthorInfoForReports();
    setIndexPageDescription();
    // opens the VMS landing page Using get()
    driver.get("http://localhost:8090/visitor_management/login");
    boolean pageload = isElementPresent(By.id("j_username"));
    ATUReports.add("Open Vms Home Page","Loading Aplication", "Login Page should be loaded", "Login Page loaded Successfully", pageload);
    Thread.sleep(3000);
    // Enters username and password using sendkeys()
    driver.findElement(By.id("j_username")).sendKeys("frontdesk");
    boolean usernamePresent = isElementPresent(By.id("j_username"));
    ATUReports.add("Enter Username","xxxx", "Username inputbox should be displayed", "Username inputbox is displayed", usernamePresent);
    driver.findElement(By.id("j_password")).sendKeys("bluetree");
    boolean passwordPresent = isElementPresent(By.id("j_password"));
    ATUReports.add("Enter Username","xxxxx", "Password inputbox should be displayed", "Password inputbox is displayed", passwordPresent);
    Thread.sleep(3000);
    driver.findElement(By.xpath("//button[@type='button']")).click();
    boolean loginButtonPresent = isElementPresent(By.xpath("//button[@type='button']"));
    ATUReports.add("Click Login Button","Click", "Overdue for checkout should be displayed", "Overdue for checkout is displayed", loginButtonPresent);
    recorder.start();


    For above set of code am getting this exception
    Error StackTrace:
    Warning: Images.createImage no resource found for class atu.testrecorder.ATUTestRecorder /atu/testrecorder/media/images/Cursor.white.png
    java.lang.NullPointerException
    at javax.swing.ImageIcon.(Unknown Source)
    at atu.testrecorder.media.image.Images.toBufferedImage(Unknown Source)
    at atu.testrecorder.ATUTestRecorder.recorder(Unknown Source)
    at atu.testrecorder.ATUTestRecorder.(Unknown Source)
    at testcases.CreateVisitTest.testLogin(CreateVisitTest.java:102)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

    ReplyDelete
  8. Hi,

    The new ATU Reporter 5.0 has inbuilt recording feature. All you need to do is to set the property for execution. We suggest you to use the latest version to leverage the best out of it.

    #AT

    ReplyDelete
    Replies
    1. Hello AT,
      Am using the latest version of ATU Reporter. All i can say is ATU Reporter is the best reporting plugin for selenium, am eagerly waiting to use future updates. can you provide me a sample code how to use inbuild recording feature ?

      Delete
    2. Simple, In the properties file make sure you have the below property

      atu.reports.recordExecution=suite

      Setting the above property will record the execution.

      #AT

      Delete
  9. Hello AT,
    can it be possible to have filter based on "ClassName" in the ATU Reporter ??

    ReplyDelete
    Replies
    1. Hello,

      As of with the current version 5.0 this is not supported but it is definitely possible and we can incorporate such future in the successive versions. if you would request such a feature, log this in the below page.

      https://docs.google.com/spreadsheet/ccc?key=0ArrZvkq9tkwPdEpfa0tFN0RIQ0ZyXy1mSGZPdzl4MVE&usp=drive_web#gid=2

      #AT

      Delete
  10. hi
    can we record videos with audio in selenium?

    ReplyDelete
    Replies
    1. Hi,

      Yes you can, In the ATUTestRecorder constructor the boolean parameter is used to enable audio recording. setting to true will record the audio.

      #AT

      Delete
  11. It's very use full info, but how much time does it captures the video.

    ReplyDelete
    Replies
    1. The recording should capture until any of the following conditions meet first

      The Execution is completed
      or
      The storage space of disk is full

      #AT

      Delete
  12. hi,

    how to use recorder for remote webdriver??

    ReplyDelete
    Replies
    1. Do you find any solution for remote webdriver. Because I looking for the same. Its working fine for local machine, but not recording client machine screen.

      Delete
  13. Hi AT

    Can u plz provide one sample code for video recording?
    I am trying but getting below error:
    No line matching interface TargetDataLine supporting format PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, big-endian is supported.

    Thanks.

    ReplyDelete
  14. Hi,

    I am running my script in Virtual machine when i ran the test and minimized my VM i am getting black screen in the recorded video. how to get full test execution recorded even though i minimize my vm?

    ReplyDelete
    Replies
    1. Hi Vinod,

      I was just wondering if you ever found a solution for this?

      Delete
  15. Hi AT,

    Is there any possible way to record video for parallel execution.

    ReplyDelete
  16. This is a very helpful tool. Thanks!

    The only problem I have is if my test code is executed on a remote computer (through selenium grid/jenkins for example). The recorder doesn't seem to work remotely. Does anyone have a work around for this?

    ReplyDelete
  17. Is it possible to record in a different video format .I would prefer to have it recoreded in .mp4 format so we can embedded it into video tag in html report .
    Please let me know if its possible .

    ReplyDelete
  18. Hi,
    Is there a chance to make recording of the browser screen(not a black screen) if the console is locked or when i'm doing sth else on the screen. For instance i have a method for capturing screenshot of the execution browser even if screen is locked, so i can run test suite over the night on the locked console.

    Thanks in advance,
    Greg

    ReplyDelete
  19. Can you please provide the maven dependencies as well

    ReplyDelete
  20. Hi am unable to play the video in VLC player 2.1.5..please suggest

    ReplyDelete
  21. Hi,
    For me the file is generated properly at the specified location but the file is not running in VLC player neither in media player. Please adive.

    ReplyDelete
    Replies
    1. Hi nisha..if u got solution plz do share with us also..even me too facing same problem with record functinality.

      Delete
  22. Hi, After execution i have got two (*.mov) files more than 15 mb, but they are not playing in any player, the screen is just black. please help me i am blocked with this

    ReplyDelete
  23. Is it possible to record for Selenium-Ruby?

    ReplyDelete
  24. Hi... Do you have any handy document for installation... Planning to implement...

    ReplyDelete
  25. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium.
    Selenium

    ReplyDelete
  26. Well explained. Got to learn new things from your Blog on Appium.Appium training in chennai

    ReplyDelete
  27. I use ATUTestRecorder v2.1, and I set true the AudioRecording, but it doesn't record the audio and video.

    Is there anybody could help me in it?

    try {
    ATUTestRecorder recorder = new ATUTestRecorder(title,true);
    recorder.start();
    /* my code, where I do calculating, and play the video */
    recorder.stop();
    } catch (Exception exception) {
    System.out.println("video recording exception: " + exception.getMessage());
    }

    This is create the whole video in good quality, but don't add the computer audio :(

    ReplyDelete
  28. If possible to change the recorded file output file format from .mov to .mp4?

    ReplyDelete
  29. Hi i am not able to play video through Firefox,when i click "Click Me to Show/Hide the Execution Video"link video is displaying blank.

    ReplyDelete
  30. AUT Reports Support Multi-threaded parallel run with Multitest? pls let me now how to handle it , thanks in advance

    ReplyDelete