Explaining how the real world works!     RSS Feed The Automated Tester on Twitter The Automated Tester on LinkedIn The AutomatedTester on github

Lights! Camera! Action! Video recording of Selenium

Thu 06 May 2010

Last night I was trying to show a client of mine how a Selenium script looks when running on my linux box. My client has an issue that when they run the test the browser just dies. Screen sharing was an option but when we have done this before the screen sharing doesn't show the screen that well. The other issue was trying to get time when we were both free.

I wanted just a video of what was happening and then I can watch it to see what the issue may be. This way my client could do it in their own time when they have a moment. There are tools out there to record a person's screen. There is camtasia which is really good. Unfortunately I did not want my client to worry about when to start recording and when to stop recording. I wanted a no frills no fuss solution for them. They are not technical in the slightest which is why they hired me.

My next thought came back to something that Jason Huggins said to me last year at GTAC 2009. Jason had put a small API onto pyvnc2swf and had created Castro. Castro is a python library that allows users to programmatically record what is happening on the screen and then create a SWF file so you can view it within a web page for everyone to see. This is exactly what I was after since I could write a script for my client to run and that would record the test. I would hopefully be able to then see where the issue may lie.

It did solve my problem brilliantly and this has become the standard way for me to help my clients. If something isn't working perfectly for them I get them to work through the steps below and then record what the issue could be.

I have only done this on Ubuntu 9.10, hence the use of apt-get, but it should work on all machines except x64 Windows. This is because Python SetupTools doesn't really work on x64 Windows that well because of the way Windows controls its registry.

Setup VNCServer :
System > Preferences > Remote Desktop Prefences

Check "Allow others to view your desktop

In a terminal window run the follow:

sudo apt-get install python-dev python-pygame python-tk python-setuptools ffmpeg flvtool2
sudo easy_install castro

Once all that has been installed you are now ready to create your video of your test.

 
from selenium import selenium
import unittest, time, re, castro

class mypms(unittest.TestCase):
    def setUp(self):
        self.verificationErrors = []
        self.video = castro.Castro()
        self.video.start()
        self.selenium = selenium("localhost", 4444, "*firefox", "http://www.theautomatedtester.co.uk/")
        self.selenium.start()
        self.selenium.window_maximize()
		
    def test_my(self):
        sel = self.selenium
		sel.open("/")
		sel.click("link=blog")
		sel.wait_for_page_to_load("30000")
		
    def tearDown(self):
        self.selenium.stop()
        self.video.stop()
        self.video.process()
        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
    unittest.main()
	

If you were to run the script above it would dump the file into /tmp and you can view the video over there. This is a very handy tool and a quick way to see where scripts are going wrong and hopefully be happy like me.

woohooo got #Castro working to record video for my #Selenium tests on my linux boxless than a minute ago via TweetDeck

    Area: blog

blog comments powered by Disqus