Extending webdriver to enable video recording in a grid environment

2,364 views
Skip to first unread message

David Santiago

unread,
Mar 25, 2013, 7:14:23 PM3/25/13
to seleniu...@googlegroups.com
Hi,

I want to enable video recording of tests executions in our grid webdriver environment.

I already have some alternatives to programmatically record a video of a grid's node screen. I also can intercept the session start method call in the hub by extending DefaultRemoteProxy with my custom proxy. No problems there so far.

The issue comes when thinking about how to request, from the test client side, the stop & save of the video only when the test fails. I could do so by extending webdriver with an additional command (say "video", in the same way there's a "screenshot" one already), that I would invoke from the client side through the hub (the fact that it's a grid environment is a requirement to keep in mind). From there I can communicate with a custom video recording service running in the node.

But I don't think this is a valid approach as adding commands to the protocol is, maybe, a brute force one... And I don't know of any other way of extending webdriver default commands in a grid for achieving something like this.


Ideas?

David Lai

unread,
Mar 25, 2013, 7:43:59 PM3/25/13
to seleniu...@googlegroups.com
Perhaps an another approach is to have a command to retrieve the IP address and other system information from the node so one can separately setup socket connections to a video recording service.

I wonder how sauce labs does it.  They record video sessions on all their selenium instances you run on their grid.

Kevin Menard

unread,
Mar 25, 2013, 8:20:39 PM3/25/13
to seleniu...@googlegroups.com
Hi David,

I don't know if this directly answers your question, but the two primary extension mechanisms for grid are the custom proxy, which you've already discovered, and custom servlets.  The servlets will run on the hub and have full access to the grid registry.  I have a custom servlet that provides an JSON-backed API that allows me to query the hub and see which sessions are being executed on which nodes.  I suspect you could do something similar to match the client's session ID up with the node that was running the command and then run a web service on each node that would allow you to stop the recording.

The tricky part here is the grid will relinquish the session upon error, so the registry likely won't have all the data you want at that point.  You could work around this by querying immediately after session creation and then locally storing the node info for that client session.

I went over how to do some of this at last year's SeleniumConf workshop.  I think the resources are available online (but I can't find the URL at the moment).  The class you would want to extend is org.openqa.grid.web.servlet.RegistryBasedServlet, which takes the registry as an argument.  The rest of the API is up to you :-)

--
Kevin

Krishnan Mahadevan

unread,
Mar 25, 2013, 10:35:34 PM3/25/13
to seleniu...@googlegroups.com
Adding to what Kevin elaborated, you might want to add up servlets at the node. Here's a high level on how this can work for you. 

Define a new servlet which will start/stop video recording and also provide some way in which the video can be transferred back as well. 

Inject this servlet into the node. 
Either in the remote proxy or in your test code invoke the servlet and instruct it to begin recording of the video. 

Now in your onTestPassed/onTestFailure events [ am using TestNG lingo here ] you can very well instruct the servlet to stop its operations. 

Some of the stufd that am talking about here is detailed in this post of mine : http://rationaleemotions.wordpress.com/2013/01/28/building-a-self-maintaining-grid-environment/
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/tj5y3CQyeBcJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

David Santiago

unread,
Mar 26, 2013, 6:54:32 PM3/26/13
to seleniu...@googlegroups.com
Thanks guys for taking the time to provide some insights.

I definitely like the servlet approach in the grid: it's a built-in feature that provides a way to perform custom calls on it which is pretty much what I was trying to get from the hub  :)

David

unread,
Mar 28, 2013, 1:45:10 AM3/28/13
to seleniu...@googlegroups.com
Kevin,

Do you happen to recall the name of the presentation you gave athe SeleniumConf workshop? Just wondering if there's an archived recording of your presentation online somewhere...

David Santiago

unread,
Jun 18, 2013, 7:46:09 AM6/18/13
to seleniu...@googlegroups.com
Blog post with some details about how I finally got it working: http://bit.ly/video-recordings-of-browser-tests

VJ

unread,
Jul 13, 2013, 4:51:35 PM7/13/13
to seleniu...@googlegroups.com
Hi David,

Can you make your code open source?
Video recording is a useful feature.

Thanks
VJ



--
View this message in context: http://selenium.10932.n7.nabble.com/Extending-webdriver-to-enable-video-recording-in-a-grid-environment-tp22428p27079.html
Sent from the Selenium - Users mailing list archive at Nabble.com.

David

unread,
Jul 14, 2013, 8:18:37 PM7/14/13
to seleniu...@googlegroups.com
+1 to Vijay's comment.

David Santiago Turiño

unread,
Feb 10, 2014, 6:32:28 AM2/10/14
to seleniu...@googlegroups.com
Kinda late, but I just published the code used for the video recording service to our Tuenti GitHub account: http://bit.ly/video-recorder-service

Nicolas Haumont

unread,
Mar 13, 2014, 12:31:26 PM3/13/14
to seleniu...@googlegroups.com
Hi David,

just took a look at your implementation, this is great. We tried a few years ago to use the same type of approach, but the performance of our tests were greatly impacted by the video capture and we finally dropped this project.
Now, I would like to work back on this project in my company, and have like you, a video for every failed test case.

On your side, did the implementation of this feature slow down the execution of your tests or did you see no impact at all.

Thanks

Oscar Rieken

unread,
Mar 14, 2014, 8:13:19 AM3/14/14
to seleniu...@googlegroups.com
I remember Dima(dimacus) was working on this a bit and talking about it in #selenium


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

David Santiago Turiño

unread,
Mar 14, 2014, 1:18:18 PM3/14/14
to seleniu...@googlegroups.com
Hi Nicolas,

It does have some impact, but your mileage may vary. When I worked on this I remember having to tweak the encoding options somehow as they were closely related to performance improvements in the overall process.

Nevertheless, as a reference, I can tell you that enabling videos for a 100min-long build added around 12min for me. 

Nicolas Haumont

unread,
Mar 19, 2014, 6:49:41 AM3/19/14
to seleniu...@googlegroups.com
Thanks for your answer.

I had a quick test on my windows machine, and I have around the same perfs as you.
But on my linux VMs, it's only recording a black screen instead of the browser. Did you encounter issues while running the tests in CI, or on linux virtual machines? Did you have to tweak the config?

Nicolas

David

unread,
Mar 19, 2014, 1:25:58 PM3/19/14
to seleniu...@googlegroups.com
I only used it from Windows instances running in VirtualBox, although it also works on Mac OS X. Didn't try it with Linux.




--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/j-1RdKPbskc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

Damián José

unread,
Jun 8, 2014, 12:30:37 PM6/8/14
to seleniu...@googlegroups.com
Hi David, great work. I was wondering what would happen if the stop action is not called for some reason. Will monte keep recording indifinitely?

David

unread,
Jun 9, 2014, 3:29:50 AM6/9/14
to seleniu...@googlegroups.com

From https://github.com/tuenti/VideoRecorderService/blob/master/README.md:

" Any limitation on the maximum recording time? Yes. Currently it's limited to a maximum of 2 minutes."

:)

Alasdair Macmillan

unread,
Jul 1, 2014, 5:45:51 AM7/1/14
to seleniu...@googlegroups.com
Hello all,

I was inspired by David's implementation to write a version which records HTML 5 video (WebM/VP8):

https://github.com/aimmac23/selenium-video-node

It still uses the Java AWT Robot to take screenshots, but it then passes the screenshot data into some native C code to run the video encoder. It gets between 8 to 15 frames a second, depending on how fast the Java code takes the screenshots.

I've tested that it works on Windows (64bit), Linux and OS X :)

Thanks,

Alasdair Macmillan

vignesh thangaraj

unread,
Jun 23, 2015, 12:07:17 AM6/23/15
to seleniu...@googlegroups.com
Hi David,

You provide readme file to installation steps. I a beginner to this concept. That is not a clear cut in steps. I add a monte jar to maven build. What next to the procedure? where i place your code? how can i start the servlet in the port?

Not in a clear manner. 

IN step 2 you told like using 'mvn package' command. It create a .jar file in target folder. But i extract the jar and look into it. It is just a jar. It is not a proper jar to execute(doesnt have a method to proceed. )


Can you please post a exact steps like how to start the servlet in the particular port. What is the purpose of the code in the git. 

Please contact me through the mail vigneshtha...@gmail.com

Thanks In advance.
Reply all
Reply to author
Forward
0 new messages