Taking screenshot of flash object using Selenium with Webdriver Taking screenshot of flash object using Selenium with Webdriver selenium selenium

Taking screenshot of flash object using Selenium with Webdriver


In order to get this working, I had to use the wmode=transparent attribute. But obviously, this will depend on whether you can edit the source of the webpage you're trying to screenshot.

To edit an existing HTML page, add the WMODE parameters to the HTML code.

Add the following parameter to the OBJECT tag:

 <param name="wmode" value="transparent">

Cheers,ns


I fix the problem by following nonshatter's advice. I was screenshotting external pages, so I had to change wmode to "transparent" at runtime. Therefore, I needed to change all the EMBED and OBJECT using javascript. I found this nice script: http://www.onlineaspect.com/2009/08/13/javascript_to_fix_wmode_parameters/

So I simply made a script to execute that and uploaded to "mysite.com/myscript.js" and now the working script here:

from selenium import webdriverscript = '''    var s = document.createElement('script');    s.src = 'http://mysite.com/myscript.js';    document.body.appendChild(s);'''def webshot(url, filename):    browser = webdriver.Firefox()    browser.get(url)    browser.execute_script(script)    browser.save_screenshot(filename)    browser.quit()

As far as I can tell from scanning the javascript, it should work for nearly any flash case. I've only done a few tests, but I can at least verify that it works when screenshotting youtube pages with video playing.