<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7644350219026181017</id><updated>2011-04-21T18:11:49.195-07:00</updated><category term='selenium'/><category term='getScreenshot'/><title type='text'>Browserbeaten - testing browsers using images</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://browserbeaten.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644350219026181017/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://browserbeaten.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Tarjei Huse</name><uri>http://www.blogger.com/profile/16267652566362178506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7644350219026181017.post-4467432071944675689</id><published>2008-01-26T05:14:00.000-08:00</published><updated>2008-01-26T08:06:38.214-08:00</updated><title type='text'>Using Selenium for getting a full image of a page.</title><content type='html'>&lt;p&gt;&lt;br /&gt;The last few weeks I've been working on and off on a patch to acquire complete images of websites using Selenium-rc, now it is done. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;The patch builds on the &lt;a href="http://jira.openqa.org/browse/SRC-395"&gt;work done by Robert Zimmermann&lt;/a&gt;, but takes it a few steps further, creating two new selenium commands:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;initScreenshots&lt;/code&gt; creates a calibration image that is used to define the area that will be saved into the image. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;You can then navigate to the spot where you want to take a picture, and then call &lt;code&gt;getFullScreenshot&lt;/code&gt; to get a full image.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;Both commands maximize the window and getFullScreenshot also takes multiple screenshots of the page (while scrolling it) and then merges these together.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt; You can see a sample image taken of &lt;a href="http://www.nytimes.com/"&gt;http://www.nytimes.com/&lt;/a&gt; &lt;a href="http://folk.uio.no/tarjeih/selenium/ff-result.png"&gt;here (firefox) &lt;/a&gt;. I'm having a smal problem getting IE to do proper scrolling, but that should be fixable.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Compiling and running it yourself&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;I've attached the patches to &lt;a href="http://jira.openqa.org/browse/SRC-395"&gt;bug #395&lt;/a&gt;. As a further help, you can find ready compiled jars for testing here: &lt;a href="http://folk.uio.no/tarjeih/selenium/"&gt;http://folk.uio.no/tarjeih/selenium/&lt;/a&gt;. You need to compile your tests using the selenium-java-client-driver-0.9.3-SNAPSHOT.jar file.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;To run the server, you need to increase the amount of heap space to be able to merge the images. Here's the commandline I use to run this on windows:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;java -Xmx256m -jar "Z:\selenium-server-0.9.3-SNAPSHOT-standalone.jar" -multiWindow &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Further work&lt;/h3&gt;&lt;br /&gt;The basic patch is fairly clean, although some of the merge tests depend on quite a few images and also contains some Unixims, mainly that it saves files to /tmp. &lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Sample tests:&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;  &lt;style type="text/css"&gt;&lt;br /&gt;    &lt;!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }--&gt;&lt;br /&gt;  &lt;/style&gt;&lt;br /&gt;&lt;!-- ======================================================== --&gt;&lt;br /&gt;&lt;!-- = Java Sourcecode to HTML automatically converted code = --&gt;&lt;br /&gt;&lt;!-- =   Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard  markus@jave.de   = --&gt;&lt;br /&gt;&lt;!-- =     Further information: http://www.java2html.de     = --&gt;&lt;br /&gt;&lt;br /&gt;    &lt;code&gt;&lt;br /&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;java.awt.image.BufferedImage;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;java.io.File;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;javax.imageio.ImageIO;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;junit.framework.TestCase;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;com.thoughtworks.selenium.DefaultSelenium;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;com.thoughtworks.selenium.Selenium;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;TestRemoteFullImage&amp;nbsp;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;extends&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;TestCase&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;{&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;Selenium&amp;nbsp;selenium;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;testRemoteImage&lt;/font&gt;&lt;font color="#000000"&gt;()&amp;nbsp;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;throws&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;Exception&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;{&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;String&amp;nbsp;url&amp;nbsp;=&amp;nbsp;&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;http://www.nytimes.com/&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;selenium&amp;nbsp;=&amp;nbsp;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;DefaultSelenium&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;wintest&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;,&amp;nbsp;&lt;/font&gt;&lt;font color="#990000"&gt;4444&lt;/font&gt;&lt;font color="#000000"&gt;,&amp;nbsp;&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;*firefox&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;,&amp;nbsp;url&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;selenium.start&lt;/font&gt;&lt;font color="#000000"&gt;()&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;System.out.println&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#000000"&gt;selenium.initScreenshots&lt;/font&gt;&lt;font color="#000000"&gt;())&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;selenium.open&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#000000"&gt;url&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;selenium.waitForPageToLoad&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;20000&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;BufferedImage&amp;nbsp;rendImage&amp;nbsp;=&amp;nbsp;selenium.getFullScreenshot&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;png&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;File&amp;nbsp;file&amp;nbsp;=&amp;nbsp;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;File&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;/tmp/imresult.png&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;assertNotNull&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#000000"&gt;rendImage&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;ImageIO.write&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#000000"&gt;rendImage,&amp;nbsp;&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;png&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;,&amp;nbsp;file&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;testRemoteImageOnIE&lt;/font&gt;&lt;font color="#000000"&gt;()&amp;nbsp;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;throws&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;Exception&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;{&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;String&amp;nbsp;url&amp;nbsp;=&amp;nbsp;&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;http://www.nytimes.com/&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;selenium&amp;nbsp;=&amp;nbsp;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;DefaultSelenium&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;wintest&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;,&amp;nbsp;&lt;/font&gt;&lt;font color="#990000"&gt;4444&lt;/font&gt;&lt;font color="#000000"&gt;,&amp;nbsp;&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;*iexplore&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;,&amp;nbsp;url&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;selenium.start&lt;/font&gt;&lt;font color="#000000"&gt;()&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;System.out.println&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#000000"&gt;selenium.initScreenshots&lt;/font&gt;&lt;font color="#000000"&gt;())&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;selenium.open&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#000000"&gt;url&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;selenium.waitForPageToLoad&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;20000&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;BufferedImage&amp;nbsp;rendImage&amp;nbsp;=&amp;nbsp;selenium.getFullScreenshot&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;png&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;File&amp;nbsp;file&amp;nbsp;=&amp;nbsp;&lt;/font&gt;&lt;font color="#7f0055"&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000000"&gt;File&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;/tmp/iexporeresult.png&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;assertNotNull&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#000000"&gt;rendImage&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;ImageIO.write&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#000000"&gt;rendImage,&amp;nbsp;&lt;/font&gt;&lt;font color="#2a00ff"&gt;&amp;#34;png&amp;#34;&lt;/font&gt;&lt;font color="#000000"&gt;,&amp;nbsp;file&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#000000"&gt;;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#ffffff"&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#000000"&gt;}&lt;/font&gt;&lt;/code&gt;&lt;br /&gt;    &lt;br /&gt;   &lt;/td&gt;&lt;br /&gt;  &lt;!-- end source code --&gt;&lt;br /&gt;   &lt;/tr&gt;&lt;br /&gt;  &lt;!-- start Java2Html link --&gt;&lt;br /&gt;   &lt;tr&gt;&lt;br /&gt;    &lt;td align="right"&gt;&lt;br /&gt;&lt;small&gt;&lt;br /&gt;&lt;a href="http://www.java2html.de" target="_blank"&gt;Java2html&lt;/a&gt;&lt;br /&gt;&lt;/small&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;&lt;!-- =       END of automatically generated HTML code       = --&gt;&lt;br /&gt;&lt;!-- ======================================================== --&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7644350219026181017-4467432071944675689?l=browserbeaten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://browserbeaten.blogspot.com/feeds/4467432071944675689/comments/default' title='Legg inn kommentarer'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7644350219026181017&amp;postID=4467432071944675689' title='0 Kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644350219026181017/posts/default/4467432071944675689'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644350219026181017/posts/default/4467432071944675689'/><link rel='alternate' type='text/html' href='http://browserbeaten.blogspot.com/2008/01/using-selenium-for-getting-full-image.html' title='Using Selenium for getting a full image of a page.'/><author><name>Tarjei Huse</name><uri>http://www.blogger.com/profile/16267652566362178506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644350219026181017.post-5109339136140932605</id><published>2008-01-11T03:22:00.000-08:00</published><updated>2008-01-11T03:36:08.848-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='selenium'/><category scheme='http://www.blogger.com/atom/ns#' term='getScreenshot'/><title type='text'>Selenuim now has captureImage()</title><content type='html'>I just noticed over the holidays that &lt;a href="http://www.openqa.org/selenium-rc/"&gt;Selenium&lt;/a&gt; has got support for retrieving images of a browser. It is still a &lt;a href="http://forums.openqa.org/thread.jspa?threadID=11321&amp;amp;tstart=0"&gt;patch&lt;/a&gt; though, but I've given it a spin and it works quite well. I'm now trying to extend it to capture the whole "page" not the part shown by the browsers viewport. More on that in a later post. Here's the basic code I use to get a picture:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;import java.awt.image.BufferedImage;&lt;br /&gt;import java.awt.image.RenderedImage;&lt;br /&gt;import java.io.File;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;import javax.imageio.ImageIO;&lt;br /&gt;import com.thoughtworks.selenium.DefaultSelenium;&lt;br /&gt;import com.thoughtworks.selenium.Selenium;&lt;br /&gt;import junit.framework.TestCase;&lt;br /&gt;&lt;br /&gt;public class SimpleScreenshotTest extends TestCase {&lt;br /&gt;   private Selenium selenium;&lt;br /&gt;&lt;br /&gt;   public void setUp() throws Exception {&lt;br /&gt;       String url = "http://www.google.com";&lt;br /&gt;       // browsers:&lt;br /&gt;       //selenium = new DefaultSelenium("wintest", 4444, "*iexplore", url);&lt;br /&gt;       selenium = new DefaultSelenium("wintest", 4444, "*firefox", url);&lt;br /&gt;       selenium.start();&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   protected void tearDown() throws Exception {&lt;br /&gt;       selenium.stop();&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * The normal google test, just with a screenshot twist.&lt;br /&gt;    */&lt;br /&gt;&lt;br /&gt;   public void testGoogle() throws Throwable {&lt;br /&gt;       selenium.open("http://www.google.com/webhp?hl=en");&lt;br /&gt;&lt;br /&gt;       assertEquals("Google", selenium.getTitle());&lt;br /&gt;&lt;br /&gt;       /* use maximize window to be able to get as much of the viewport as possible. */&lt;br /&gt;       selenium.windowMaximize();&lt;br /&gt;       selenium.waitForPageToLoad("5000");&lt;br /&gt;       // note: getScreenshot does not validate the inputparameters.&lt;br /&gt;       RenderedImage rendImage = selenium.getScreenshot("png");&lt;br /&gt;       if (rendImage == null) {&lt;br /&gt;           fail("Rendered image null!");&lt;br /&gt;       }&lt;br /&gt;       File file = new File("/tmp/newimage-.png");&lt;br /&gt;       ImageIO.write(rendImage, "png", file);&lt;br /&gt;   }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The next thing now will be to look into creating shots of the whole page.&lt;br /&gt;&lt;br /&gt;If someone needs help building Selenium with the patch, post to the comments and I'll do a quick writeup of how to compile selenium-rc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7644350219026181017-5109339136140932605?l=browserbeaten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://browserbeaten.blogspot.com/feeds/5109339136140932605/comments/default' title='Legg inn kommentarer'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7644350219026181017&amp;postID=5109339136140932605' title='0 Kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644350219026181017/posts/default/5109339136140932605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644350219026181017/posts/default/5109339136140932605'/><link rel='alternate' type='text/html' href='http://browserbeaten.blogspot.com/2008/01/selenuim-now-has-captureimage.html' title='Selenuim now has captureImage()'/><author><name>Tarjei Huse</name><uri>http://www.blogger.com/profile/16267652566362178506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644350219026181017.post-934038627255804525</id><published>2007-10-28T02:43:00.000-07:00</published><updated>2007-11-27T01:46:03.967-08:00</updated><title type='text'>Grabbing the complete picture</title><content type='html'>One of the goals of my project is to make the process of making HTML+CSS code from a designers sketch picture test driven.&lt;br /&gt;&lt;br /&gt;To do this, I need to strip out the margins and headers of the various images I get from &lt;a href="http://browsershots.org/"&gt;browsershots.org&lt;/a&gt; (my preferred way right now of getting pictures of websites).&lt;br /&gt;&lt;br /&gt;This isn't easy, but I am working on different approaches starting of by trying to segment on the color of the  surrounding element. My goal is to use as little information as possible about the image to extract what I want.&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;pre wrap=""&gt;&lt;span style="font-family: Georgia,serif;"&gt;&lt;/span&gt;A problem with the current images is that each image includes the whole browser window including scrollbars, addressbars and other browser specific stuff. It is a goal to be able to remove as much of this clutter as possible. We want a clean image of just the rendered page.&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;As a test, I started with four images from four different browsers, firefox 1.5, firefox 2.0, safari and opera. Somehow I forgot to include IE in the dataset.&lt;br /&gt;&lt;br /&gt;You can find the images here:&lt;br /&gt;&lt;a class="moz-txt-link-freetext" href="http://folk.uio.no/tarjeih/matlab/"&gt;http://folk.uio.no/tarjeih/matlab/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;For now I've done removal of horizontal components in the image. To do this, I used matlab to get the variance of each horizontal line in the image. Then I set a cutoff point wrt to variance and also cutoff points that I was only interested in lines 120 or 50 pixels from the top or bottom respectively.&lt;br /&gt;&lt;br /&gt;For each picture I got two sets of lines, one for the lines on top with variance bellow the set cutoff point and one for the lines close to the bottom.&lt;br /&gt;&lt;br /&gt;I then used the line closest to the center for each of these sets as the line where I thought the webpage started.&lt;br /&gt;&lt;br /&gt;The images in the directory show the results.&lt;br /&gt;&lt;br /&gt;The file &lt;browsername&gt;.png is the original image and the file cut-&lt;browsername&gt;.png shows the image with red lines drawn where I found lines with variance bellow the cutoff point.&lt;br /&gt;&lt;br /&gt;Files named figure-&lt;browsername&gt;.png.eps shows the two images side by&lt;br /&gt;side.&lt;br /&gt;&lt;br /&gt;Relevant matlab code is also in the directory:&lt;br /&gt;- cutPic.m is the function that finds the cut off points.&lt;br /&gt;- getCutPicLines.m is the script that goes through the images and&lt;br /&gt;crops them.&lt;br /&gt;- colorLines is a script to color the relevant lines in the image.&lt;br /&gt;- tmp_rmLines .m is a starting attempt at making the script work in&lt;br /&gt;both dimensions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Questions/Problems/Ideas/Comments:&lt;/span&gt;&lt;br /&gt;* It is fairly obvious that this approach works best at the top and bottom.&lt;br /&gt;* I'm wondering if I should use information about which browser this is when cropping the image. I was hoping I didn't have to, but I seem to be wrong.&lt;br /&gt;* I will need an approach to deciding if there is stuff surrounding the image, esp if there is a scrollbar in the image.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7644350219026181017-934038627255804525?l=browserbeaten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://browserbeaten.blogspot.com/feeds/934038627255804525/comments/default' title='Legg inn kommentarer'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7644350219026181017&amp;postID=934038627255804525' title='0 Kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644350219026181017/posts/default/934038627255804525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644350219026181017/posts/default/934038627255804525'/><link rel='alternate' type='text/html' href='http://browserbeaten.blogspot.com/2007/10/grabbing-complete-picture.html' title='Grabbing the complete picture'/><author><name>Tarjei Huse</name><uri>http://www.blogger.com/profile/16267652566362178506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644350219026181017.post-2486690359001913859</id><published>2007-10-17T01:43:00.000-07:00</published><updated>2007-10-17T03:20:30.510-07:00</updated><title type='text'>Browserbeaten - what's in a name?</title><content type='html'>Why browserbeaten? Because nitwit, bit, imtest and a host of other names on blogspot were taken.&lt;br /&gt;&lt;br /&gt;Browserbeaten also refers to the state of many web developers today. We  make cool and jazzy AJAX based sites with lots of nice CSS and then the whole shebang collapses as the boss says "Why doesn't this work with Safari?" and you have to work double overtime to fix browserbugs just before release . The browser beat you.&lt;br /&gt;&lt;br /&gt;In my view, browsers is the new portability challenge for developers. Therefore we need to find ways to test our products across a lot of browsers fast. I'm a great fan (if not always a perfect practitioner) of Test driven development (TDD).&lt;br /&gt;&lt;br /&gt;Right now I am working on a masters thesis that tries to combine techniques from computer vision with ideas from test driven development to see if it is possible to make a tool that tests the design of a web page in different browsers.&lt;br /&gt;&lt;br /&gt;This blog is my dumping ground for ideas, links and that I will use to develop my masters thesis.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7644350219026181017-2486690359001913859?l=browserbeaten.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://browserbeaten.blogspot.com/feeds/2486690359001913859/comments/default' title='Legg inn kommentarer'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7644350219026181017&amp;postID=2486690359001913859' title='0 Kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644350219026181017/posts/default/2486690359001913859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644350219026181017/posts/default/2486690359001913859'/><link rel='alternate' type='text/html' href='http://browserbeaten.blogspot.com/2007/10/browserbeaten-whats-in-name.html' title='Browserbeaten - what&apos;s in a name?'/><author><name>Tarjei Huse</name><uri>http://www.blogger.com/profile/16267652566362178506</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
