<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>WatirMelon</title>
	<atom:link href="http://watirmelon.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://watirmelon.com</link>
	<description>A 93% Watir Based Blog by Alister Scott</description>
	<lastBuildDate>Fri, 27 Jan 2012 19:26:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='watirmelon.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/c9de640b304257bb2361e16d95fec265?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>WatirMelon</title>
		<link>http://watirmelon.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://watirmelon.com/osd.xml" title="WatirMelon" />
	<atom:link rel='hub' href='http://watirmelon.com/?pushpress=hub'/>
		<item>
		<title>Writing a CoffeeScript web application using TDD</title>
		<link>http://watirmelon.com/2012/01/23/writing-a-coffeescript-web-application-using-tdd/</link>
		<comments>http://watirmelon.com/2012/01/23/writing-a-coffeescript-web-application-using-tdd/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 11:00:20 +0000</pubDate>
		<dc:creator>Alister Scott</dc:creator>
				<category><![CDATA[Automated Testing]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[CoffeeScript]]></category>
		<category><![CDATA[Jasmine]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://watirmelon.com/?p=1184</guid>
		<description><![CDATA[As part of the Test Automation Bazaar minesweeper challenge, a colleague and I developed a CoffeeScript implementation of minesweeper. We wanted to use a test first approach to writing our CoffeeScript, so we decided to use Jasmine. Setting up a &#8230; <a href="http://watirmelon.com/2012/01/23/writing-a-coffeescript-web-application-using-tdd/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1184&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As part of the Test Automation Bazaar <a href="http://watir.com/test-automation-bazaar/minesweeper-challenge/">minesweeper challenge</a>, a <a href="https://twitter.com/#!/markryall">colleague</a> and I <a href="https://github.com/minesweeper/minesweeper.github.com">developed</a> a <a href="http://coffeescript.org/">CoffeeScript</a> implementation of <a href="http://minesweeper.github.com/">minesweeper</a>. We wanted to use a test first approach to writing our CoffeeScript, so we decided to use <a href="http://pivotal.github.com/jasmine/">Jasmine</a>.</p>
<p><strong>Setting up a development environment</strong></p>
<p>Even though we were developing the application in CoffeeScript, which generates JavaScript, we found it easy to use a simple ruby environment to boostrap these tools. Our environment therefore looked something like this:</p>
<ul>
<li>Ruby 1.9.2 (specified through a <a href="http://beginrescueend.com/">RVM</a> .rvmrc file)</li>
<li><a href="http://coffeescript.org/">CoffeeScript</a> installed via <a href="http://mxcl.github.com/homebrew/">Homebrew</a></li>
<li><em>guard, guard-coffeescript, guard-sass gems</em> for automatically generating JavaScript from CoffeeScript (and CSS from <a href="http://sass-lang.com/">Sass</a>)</li>
<li>jasmine gem: for writing/running tests</li>
<li>Sublime Text 2 editor for writing code</li>
</ul>
<p><strong>Specifying a Guardfile</strong></p>
<p>A Guardfile consists of a bunch of guards that perform actions whenever a file is modified in that location. Our Guardfile looked like:</p>
<p><pre class="brush: ruby;">
guard 'coffeescript', :output =&gt; 'javascripts' do
  watch /^coffeescripts\/.*[.]coffee/
end

guard 'coffeescript', :output =&gt; 'spec/javascripts' do
  watch /^spec\/coffeescripts\/.*[.]coffee/
end

guard 'sass', :input =&gt; 'stylesheets'
</pre></p>
<p><strong>Writing a Jasmine specification in CoffeeScript</strong></p>
<p>A Jasmine spec in CoffeeScript looked something like this:</p>
<p><pre class="brush: jscript;">
describe 'GameState', -&gt;
  game_state = null
  field = Field.new mineCount: 1, rows: 1, cols: 3

  beforeEach -&gt;
    game_state = GameState.new field

  it 'should initialise lost to false', -&gt;
    expect(game_state.lost()).toEqual false

  it 'should initialise won to false', -&gt;
    expect(game_state.won()).toEqual false

  it 'should initialise remaining_mines to mine_count', -&gt;
    expect(game_state.remaining_mines()).toEqual 1

  it 'should initialise remaining_mines to mine_count', -&gt;
    expect(game_state.remaining_cells()).toEqual 2
</pre></p>
<p><strong>Running Jasmine tests</strong></p>
<p>The jasmine gem makes it very easy to run your jasmine tests. There&#8217;s a rake task called &#8216;jasmine&#8217; which you can run to launch a jasmine server locally on port 8888. If you browse to that page, you&#8217;ll see something like this:</p>
<p><img class=" wp-image-1186 alignnone" title="Jasmine Test Results" src="http://watirmelon.files.wordpress.com/2012/01/screen-shot-2012-01-23-at-6-41-54-pm.png?w=584&#038;h=362" alt="" width="584" height="362" /></p>
<p><strong>Test First CoffeeScript development</strong></p>
<p>Now that you have Jasmine running, and Guard generating the CoffeeScript, it&#8217;s easy to write a new spec, refresh the Jasmine browser page to run all your tests (in our case in a third of a second) and then write the code to make it pass.</p>
<p><strong>Automatically running Jasmine tests on Travis CI</strong></p>
<p>If you&#8217;ve got your CoffeeScript and Jasmine on github, it&#8217;s trivial to automatically run all your Jasmine tests using the Jasmine::Ci rake task on <a href="http://travis-ci.org/#!/minesweeper/minesweeper.github.com">Travis CI</a>. All you need is a .travis.yml file like:</p>
<p><pre class="brush: ruby;">

language: ruby
rvm:
  - 1.9.2
env:
  - DISPLAY=:99.0
before_install: sh -e /etc/init.d/xvfb start
</pre></p>
<p>Once you add the project to travis, it&#8217;ll automatically run whenever you push. Magic.</p>
<p><strong>Lessons Learned</strong></p>
<ul>
<li><strong>Use Sublime Text 2 for CoffeeScript joy:</strong> TextMate 2 forces you to use tabs (4) for CoffeeScript development, we couldn&#8217;t find a way to make it stop, and had to switch to Sublime Text 2 (for the better).</li>
<li><strong>You still need to know JavaScript:</strong> all CoffeeScript does is generate JavaScript for both your application code and Jasmine specs. We found ourselves often delving into the generated code to see what was actually going on, and when using Firebug to debug.</li>
<li><strong>Use the <em>jasmine_content</em> div to test the DOM.</strong> Jasmine uses a special div with an id of <em>jasmine_content</em>, which we used to inject and test HTML.</li>
<li><strong>CoffeeScript classes are odd:</strong> we instead used closures to encapsulate state, using a new method on an object, which has the added benefit of looking like ruby.</li>
</ul>
<p>I hope you enjoy your CoffeeScript test driven development with Jasmine.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/watirmelon.wordpress.com/1184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/watirmelon.wordpress.com/1184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/watirmelon.wordpress.com/1184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/watirmelon.wordpress.com/1184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/watirmelon.wordpress.com/1184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/watirmelon.wordpress.com/1184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/watirmelon.wordpress.com/1184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/watirmelon.wordpress.com/1184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/watirmelon.wordpress.com/1184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/watirmelon.wordpress.com/1184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/watirmelon.wordpress.com/1184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/watirmelon.wordpress.com/1184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/watirmelon.wordpress.com/1184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/watirmelon.wordpress.com/1184/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1184&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://watirmelon.com/2012/01/23/writing-a-coffeescript-web-application-using-tdd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/344eed26ff913de38b45620d18eed695?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">alisterscott</media:title>
		</media:content>

		<media:content url="http://watirmelon.files.wordpress.com/2012/01/screen-shot-2012-01-23-at-6-41-54-pm.png" medium="image">
			<media:title type="html">Jasmine Test Results</media:title>
		</media:content>
	</item>
		<item>
		<title>Have you always wanted to automate minesweeper?</title>
		<link>http://watirmelon.com/2012/01/16/have-you-always-wanted-to-automate-minesweeper/</link>
		<comments>http://watirmelon.com/2012/01/16/have-you-always-wanted-to-automate-minesweeper/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 17:19:42 +0000</pubDate>
		<dc:creator>Alister Scott</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[minesweeper]]></category>

		<guid isPermaLink="false">http://watirmelon.com/?p=1177</guid>
		<description><![CDATA[I am running a contest as part of the Test Automation Bazaar in Austin, Texas from March 23-24. The challenge is to write a robot that plays (and wins) expert games of minesweeper. You can use whatever language and tool &#8230; <a href="http://watirmelon.com/2012/01/16/have-you-always-wanted-to-automate-minesweeper/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1177&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-1181" title="Screen Shot 2012-01-15 at 7.40.32 PM" src="http://watirmelon.files.wordpress.com/2012/01/screen-shot-2012-01-15-at-7-40-32-pm.png?w=584" alt=""   />I am running a contest as part of the Test Automation Bazaar in Austin, Texas from March 23-24.</p>
<p>The challenge is to write a robot that plays (and wins) expert games of minesweeper. You can use whatever language and tool you like. A colleague of mine, Mark Ryall, and myself have written a web version of minesweeper from scratch using Coffeescript. It&#8217;s available to play at <a href="http://minesweeper.github.com">minesweeper.github.com</a>.</p>
<p>Full details of the contest are on the <a href="http://watir.com/test-automation-bazaar/minesweeper-challenge/">conference web site</a> hosted on watir.com.</p>
<p>Good luck! It sounds easier than it is.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/watirmelon.wordpress.com/1177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/watirmelon.wordpress.com/1177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/watirmelon.wordpress.com/1177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/watirmelon.wordpress.com/1177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/watirmelon.wordpress.com/1177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/watirmelon.wordpress.com/1177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/watirmelon.wordpress.com/1177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/watirmelon.wordpress.com/1177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/watirmelon.wordpress.com/1177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/watirmelon.wordpress.com/1177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/watirmelon.wordpress.com/1177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/watirmelon.wordpress.com/1177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/watirmelon.wordpress.com/1177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/watirmelon.wordpress.com/1177/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1177&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://watirmelon.com/2012/01/16/have-you-always-wanted-to-automate-minesweeper/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:thumbnail url="http://watirmelon.files.wordpress.com/2012/01/screen-shot-2012-01-16-at-1-09-52-am.png?w=150" />
		<media:content url="http://watirmelon.files.wordpress.com/2012/01/screen-shot-2012-01-16-at-1-09-52-am.png?w=150" medium="image">
			<media:title type="html">Screen Shot 2012-01-16 at 1.09.52 AM</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/344eed26ff913de38b45620d18eed695?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">alisterscott</media:title>
		</media:content>

		<media:content url="http://watirmelon.files.wordpress.com/2012/01/screen-shot-2012-01-15-at-7-40-32-pm.png" medium="image">
			<media:title type="html">Screen Shot 2012-01-15 at 7.40.32 PM</media:title>
		</media:content>
	</item>
		<item>
		<title>A tale of three ruby automated testing APIs (redux)</title>
		<link>http://watirmelon.com/2011/12/03/a-tale-of-three-ruby-automated-testing-apis-redux/</link>
		<comments>http://watirmelon.com/2011/12/03/a-tale-of-three-ruby-automated-testing-apis-redux/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 02:17:55 +0000</pubDate>
		<dc:creator>Alister Scott</dc:creator>
				<category><![CDATA[ATDD]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Specification by Example]]></category>
		<category><![CDATA[Watir]]></category>
		<category><![CDATA[Watir-WebDriver]]></category>
		<category><![CDATA[capybara]]></category>
		<category><![CDATA[selenium-webdriver]]></category>
		<category><![CDATA[watir-webdriver]]></category>

		<guid isPermaLink="false">http://watirmelon.com/?p=1171</guid>
		<description><![CDATA[Redux Note: I originally wrote a similar article to this before going on parental leave about six weeks ago. Whilst I didn&#8217;t intend to offend, it seemed that a few people took my article the wrong way. I understand that &#8230; <a href="http://watirmelon.com/2011/12/03/a-tale-of-three-ruby-automated-testing-apis-redux/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1171&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Redux Note:</strong> I originally wrote a similar article to this before going on parental leave about six weeks ago. Whilst I didn&#8217;t intend to offend, it seemed that a few people took my article the wrong way. I understand that a lot of effort goes into creating a web testing API, but that doesn&#8217;t mean that everyone will agree with what you&#8217;ve made.</p>
<p>Sadly, an <a href="http://en.wikipedia.org/wiki/Anonymous_post">anonymous coward</a> attacked myself and the company who I work (even though I don&#8217;t mention that company on this blog), so for the first time in this blog&#8217;s history, I have had to turn comment moderation on. I am sorry to the other genuine commenters whose comments have been lost in transition, and now have to wait for their new comments to be approved.</p>
<p>Since then I have received numerous emails asking where my article went, and commenting that people found it interesting and worthwhile. So I have decided to repost this article, hopefully with a little less contention this time around, making it clear, this is my <em>opinion</em> and experience: <a href="http://en.wiktionary.org/wiki/your_mileage_may_vary">YMMV</a>.</p>
<p><strong>Intro</strong></p>
<p>As a consultant I get to see and work on a lot of automated testing solutions using different automated web testing APIs. Lately I&#8217;ve been thinking about how these APIs are different and what makes them so.</p>
<p>My main interest is in ruby, and fortunately ruby has three solid examples of three different kinds of web testing APIs, two of which extend the lowest level API: selenium-webdriver.</p>
<p>I&#8217;ll (try to) explain here what I consider to be three kinds of automated web testing APIs and where I consider the sweet spot to be and and why.</p>
<p><strong>A meaty example</strong></p>
<p>As a carnivore, I thought I would explain my concept in terms I can relate to. If you&#8217;re a beef eater, there are many different kinds of beef that you can use to make some tasty food to eat. I&#8217;ll use three different kinds of beef for my example. The first (rawest) kind would involve getting a beef carcass and filleting it yourself to eventually make some edible food. The second kind of beef you could use is beef that is already in a slightly usable form, but you can then use yourself to make some edible food. For example, you can buy minced beef at a butcher, and then make your own hamburger patties, taco fillings etc from it. The final type of beef you could use is beef that has already been prepared so you can directly consume it, for example, sausages which can be cooked and consumed as is.</p>
<p>I consider these three examples of different kinds of beef to roughly correlate to automated web testing APIs, of which I also consider to be three kinds of.</p>
<p>The first is a <strong>Web Driver API</strong>, which is the rawest form of an API, its job is to drive a browser by issuing it commands. It provides a high level of user control, but like filleting a beef carcass it&#8217;s more &#8216;work&#8217;. An example in ruby of this API is the <a href="http://code.google.com/p/selenium/wiki/RubyBindings">selenium-webdriver API</a>, which controls the browser using the webdriver drivers.</p>
<p>The second kind of automated web testing API is the <strong>Browser API</strong>, which is a higher level API but still provides user control. This is the minced beef of APIs, as whilst it&#8217;s in a more usable form than a carcass, you still have a lot of control (and potential to what you can do with it). An example in ruby of this API is the <a title="Watir-WebDriver tests on Firefox 7: getting rid of the send data to Mozilla message" href="http://watirwebdriver.com/">watir-webdriver API</a>, which uses the underlying selenium-webdriver carcass to control the browser.</p>
<p>The final kind of automated web testing API is the <strong>Web Form DSL</strong> (Domain Specific Language) which is a very high level API that provides users with specific methods to automate web forms and their elements. This is the beef sausages of APIs as sometimes you feel like eating something else besides sausages, but it&#8217;s difficult to make anything else edible <em>but</em> sausages<em> from</em> sausages. An example in ruby of this Web Form DSL is the <a href="http://rubydoc.info/github/jnicklas/capybara/master/Capybara/DSL">Capybara DSL</a>.</p>
<p>Visually, this looks something like this:</p>
<p><a href="http://watirmelon.files.wordpress.com/2011/12/threekindsofautomatedwebtestingapis.png"><img class="alignnone size-full wp-image-1172" title="ThreekindsofautomatedwebtestingAPIs" src="http://watirmelon.files.wordpress.com/2011/12/threekindsofautomatedwebtestingapis.png?w=584&#038;h=344" alt="" width="584" height="344" /></a></p>
<p><strong>Show me the code™</strong></p>
<p>So exactly what do these APIs look like?</p>
<p>I knew you&#8217;d ask, that&#8217;s why I came prepared.</p>
<p>Say I want to accomplish a fairly basic scenario on my <a href="http://bit.ly/watir-webdriver-demo">example Google Doc form</a>:</p>
<ul>
<li>Start a browser</li>
<li>Navigate to the watir-webdriver-demo form</li>
<li>Check whether text field with id &#8216;entry_0&#8242; exists (this <strong>should</strong> exist)</li>
<li>Check whether text field with id &#8216;entry_99&#8242; exists (this <strong>shouldn&#8217;t</strong> exist)</li>
<li>Set a text field with id &#8216;entry_0&#8242; to &#8217;1&#8242;</li>
<li>Set a text field with id &#8216;entry_0&#8242; to &#8217;2&#8242;</li>
<li>Select &#8216;Ruby&#8217; from select list with id &#8216;entry_1&#8242;</li>
<li>Click the Submit button</li>
</ul>
<p>This is how <em>I would do it</em> in the three different APIs:</p>
<p><pre class="brush: ruby;">
# * Start browser
# * Navigate to watir-webdriver-demo form
# * Check whether text field with id 'entry_0' exists
# * Check whether text field with id 'entry_99' exists
# * Set text field with id 'entry_0' to '1'
# * Set text field with id 'entry_0' to '2'
# * Select 'Ruby' from select list with id 'entry_1'
# * Click the Submit button

require 'bench'

benchmark 'selenium-webdriver' do
  require 'selenium-webdriver'

  driver = Selenium::WebDriver.for :firefox
  driver.navigate.to 'http://bit.ly/watir-webdriver-demo'
  begin
    driver.find_element(:id, 'entry_0')
  rescue Selenium::WebDriver::Error::NoSuchElementError
    # doesn't exist
  end
  begin
    driver.find_element(:id, 'entry_99').displayed?
  rescue Selenium::WebDriver::Error::NoSuchElementError
    # doesn't exist
  end
  driver.find_element(:id, 'entry_0').clear
  driver.find_element(:id, 'entry_0').send_keys '1'
  driver.find_element(:id, 'entry_0').clear
  driver.find_element(:id, 'entry_0').send_keys '2'
  driver.find_element(:id, 'entry_1').find_element(:tag_name =&gt; 'option', :value =&gt; 'Ruby').click
  driver.find_element(:name, 'submit').click
  driver.quit
end

benchmark 'watir-webdriver' do
  require 'watir-webdriver'
  b = Watir::Browser.start 'bit.ly/watir-webdriver-demo', :firefox
  b.text_field(:id =&gt; 'entry_0').exists?
  b.text_field(:id =&gt; 'entry_99').exists?
  b.text_field(:id =&gt; 'entry_0').set '1'
  b.text_field(:id =&gt; 'entry_0').set '2'
  b.select_list(:id =&gt; 'entry_1').select 'Ruby'
  b.button(:name =&gt; 'submit').click
  b.close
end

benchmark 'capybara' do
  require 'capybara'
  session = Capybara::Session.new(:selenium)
  session.visit('http://bit.ly/watir-webdriver-demo')
  session.has_field?('entry_0') # =&gt; true
  session.has_no_field?('entry_99') # =&gt; true
  session.fill_in('entry_0', :with =&gt; '1')
  session.fill_in('entry_0', :with =&gt; '2')
  session.select('Ruby', :from =&gt; 'entry_1')
  session.click_button 'Submit'
  session.driver.quit
end

run 10
</pre></p>
<p>This is how long they took for me to run:</p>
<pre>                        user     system      total        real
selenium-webdriver  1.810000   0.840000  22.130000 ( 73.123340)
watir-webdriver     1.940000   0.870000  24.380000 ( 79.388494)
capybara            1.950000   0.890000  24.080000 ( 79.920051)</pre>
<p><strong>Note:</strong> Capybara doesn&#8217;t always require a &#8216;session&#8217;, it&#8217;s only for non <a href="http://en.wikipedia.org/wiki/Rack_%28web_server_interface%29">ruby rack applications</a>, but since my example (Google) is not a rack application, as are most of the applications I test, my example must use the session.</p>
<p><strong>When using ruby, why Watir-WebDriver is <em>my</em> sweet spot</strong></p>
<p>I <em>personally</em> find Watir-WebDriver to be the most elegant solution, as the API is high enough for me to be highly readable/usable, but low enough to be powerful and for me to feel like <em>I&#8217;m</em> in control.</p>
<p>For example, being able to select an element by a explicit identifier (name, class name, id, anything) is a huge deal to me. I personally don&#8217;t like relying on the API to determine which selector to use: for example Capybara only supports <em>name, id</em> and <em>label</em>, but you can&#8217;t tell <em>fill_in</em> which specific one to choose: it appears to try each selector one by one until it finds it.</p>
<p>I have found that Watir-WebDriver also also provides lots of flexibility/neatness. For example: it&#8217;s the only API shown here that allows URLs to not have a &#8216;http://&#8217; prefix (how many people do you know who type in http:// into a browser?).</p>
<p>In my opinion, the high level APIs like Capybara don&#8217;t provide enough <em>control</em> (for example &#8211; being able to specify the explicit selector), but the low level APIs like webdriver don&#8217;t provide enough <em>functionality</em>. This is evident when I am using a language other than ruby (like C#) when I find myself writing a large number of web element extension methods because webdriver doesn&#8217;t provide any of them. A <strong>.set</strong> method is a classic example, even Simon Stewart writes a <a href="http://code.google.com/p/selenium/wiki/LoadableComponent"><em>clearAndType</em></a> method in his examples even though he wrote webdriver which sadly misses it (you must call .clear, <strong>and</strong> .send_keys).</p>
<p><strong>My biggest concern about high level field APIs</strong></p>
<p>But my biggest issue with the high level APIs is that I&#8217;ve frequently seen them used to write test <strong>scripts</strong> that are step by step interactions with a web form. Instead of thinking of a business application as that, people see it as a series of forms that you &#8216;fill in&#8217;. This means people create scenarios like Aslak Hellesøy included in his <a href="http://aslakhellesoy.com/post/11055981222/the-training-wheels-came-off">recent post</a> about cucumber web steps (which uses Capybara) and the problems it has created.</p>
<pre>Scenario: Successful login
  Given a user "Aslak" with password "xyz"
  And I am on the login page
  And I fill in "User name" with "Aslak"
  And I fill in "Password" with "xyz"
  When I press "Log in"
  Then I should see "Welcome, Aslak"</pre>
<p>I&#8217;m not saying it&#8217;s not possible to end up with something as ugly as above using other APIs, but I am saying the web form DSL style naturally relates to this: as the APIs look so similar to this style because that&#8217;s what the DSL was designed for: filling in forms. I&#8217;ve seen people frequently write generic, reusable cucumber steps to match the web form DSL like:</p>
<p><pre class="brush: ruby;">
When /^I fill in &quot;(.+)&quot; with &quot;(.+)&quot;$/ do |value, field|
  fill_in field, :with =&gt; value
end
</pre></p>
<p>But this means you end up with less readable, less maintainable <a href="http://concordion.org/Technique.html"><strong>test scripts</strong></a> rather than business readable executable <strong>specifications</strong>.<br />
<strong></strong></p>
<p><strong>Summary</strong></p>
<p>Ultimately what I am looking for in an automated web testing API is simplicity <strong>and</strong> full control. I personally find browser APIs like Watir-WebDriver and Watir give me this, and this is why I love them so. Your mileage may vary, you may like different styles of APIs better, but I&#8217;ve seen other APIs so badly abused by people not even thinking about it, so it makes sense to think about what you&#8217;re trying to achieve and whether what you&#8217;re doing is the right way.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/watirmelon.wordpress.com/1171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/watirmelon.wordpress.com/1171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/watirmelon.wordpress.com/1171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/watirmelon.wordpress.com/1171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/watirmelon.wordpress.com/1171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/watirmelon.wordpress.com/1171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/watirmelon.wordpress.com/1171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/watirmelon.wordpress.com/1171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/watirmelon.wordpress.com/1171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/watirmelon.wordpress.com/1171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/watirmelon.wordpress.com/1171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/watirmelon.wordpress.com/1171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/watirmelon.wordpress.com/1171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/watirmelon.wordpress.com/1171/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1171&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://watirmelon.com/2011/12/03/a-tale-of-three-ruby-automated-testing-apis-redux/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/344eed26ff913de38b45620d18eed695?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">alisterscott</media:title>
		</media:content>

		<media:content url="http://watirmelon.files.wordpress.com/2011/12/threekindsofautomatedwebtestingapis.png" medium="image">
			<media:title type="html">ThreekindsofautomatedwebtestingAPIs</media:title>
		</media:content>
	</item>
		<item>
		<title>Cukepatch: rich editing of feature files on Github</title>
		<link>http://watirmelon.com/2011/11/25/cukepatch-rich-editing-of-feature-files-on-github/</link>
		<comments>http://watirmelon.com/2011/11/25/cukepatch-rich-editing-of-feature-files-on-github/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 00:10:08 +0000</pubDate>
		<dc:creator>Alister Scott</dc:creator>
				<category><![CDATA[Automated Testing]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Specification by Example]]></category>
		<category><![CDATA[cukepatch]]></category>
		<category><![CDATA[github]]></category>

		<guid isPermaLink="false">http://watirmelon.com/?p=1167</guid>
		<description><![CDATA[I&#8217;ve been a strong advocate of using the built in Github web text editor for editing feature files for some time, as it means that non-technical business users don&#8217;t need to worry about having git clients installed and pulling/pushing changes. &#8230; <a href="http://watirmelon.com/2011/11/25/cukepatch-rich-editing-of-feature-files-on-github/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1167&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been a strong advocate of using the built in Github web text editor for editing feature files for some time, as it means that non-technical business users don&#8217;t need to worry about having git clients installed and pulling/pushing changes.</p>
<p>The benefit of this method over a publishing system such as <a href="https://www.relishapp.com/">Relish</a> is that you can send a subject matter expert a URL to a Github feature file, and if they recognize that the specification is incorrect, they can immediately update it, unlike Relish where they need to go to the source code and push a change.</p>
<p>The downside is that the editor is a pretty basic, meaning no syntax highligting, step completion etc. Until now that is&#8230;</p>
<p>Aslak Hellesøy and Julien Biezemans <a href="https://groups.google.com/forum/#!topic/cukes/minS8B_s_xs">recently announced</a> <strong>Cukepatch</strong>: rich editing of feature files on Github. There&#8217;s some detail on the Cukes Google Group about it, but essentially it provides rich editing (syntax highlighting/validation and step completion) using a Google Chrome user script that reads a cucumber file you create in your public cucumber repository.</p>
<p>I did this for both WatirMelonCucumber and EtsyWatirWebDriver, and the results look like this:</p>
<p><a href="http://watirmelon.files.wordpress.com/2011/11/watirmeloncucumber.png"><img class="alignnone size-full wp-image-1168" title="WatirMelonCucumber" src="http://watirmelon.files.wordpress.com/2011/11/watirmeloncucumber.png?w=584&#038;h=386" alt="" width="584" height="386" /></a></p>
<p>This looks very promising indeed. There&#8217;s a few caveats at the moment including the requirement for a backend server, only working with public repositories, having to manually install the user script and being Google Chrome only. As these are overcome, I can see this becoming the de facto way for business users to write and edit specifications. Well done guys.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/watirmelon.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/watirmelon.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/watirmelon.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/watirmelon.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/watirmelon.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/watirmelon.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/watirmelon.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/watirmelon.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/watirmelon.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/watirmelon.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/watirmelon.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/watirmelon.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/watirmelon.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/watirmelon.wordpress.com/1167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1167&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://watirmelon.com/2011/11/25/cukepatch-rich-editing-of-feature-files-on-github/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/344eed26ff913de38b45620d18eed695?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">alisterscott</media:title>
		</media:content>

		<media:content url="http://watirmelon.files.wordpress.com/2011/11/watirmeloncucumber.png" medium="image">
			<media:title type="html">WatirMelonCucumber</media:title>
		</media:content>
	</item>
		<item>
		<title>WatirMelon Spinach</title>
		<link>http://watirmelon.com/2011/10/29/watirmelon-spinach/</link>
		<comments>http://watirmelon.com/2011/10/29/watirmelon-spinach/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 12:41:00 +0000</pubDate>
		<dc:creator>Alister Scott</dc:creator>
				<category><![CDATA[Business Driven]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Specification by Example]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[spinach]]></category>
		<category><![CDATA[watir-webdriver]]></category>

		<guid isPermaLink="false">http://watirmelon.com/?p=1159</guid>
		<description><![CDATA[Hello Spinach! &#8220;Spinach is a new awesome BDD framework that features encapsulation and modularity of your step definitions.&#8221; Seems like a good idea, so I thought I&#8217;d give it a try, and convert my existing simple Watirmelon Cucumber tests to &#8230; <a href="http://watirmelon.com/2011/10/29/watirmelon-spinach/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1159&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello <a href="http://codegram.github.com/spinach/">Spinach</a>!</p>
<p><a href="http://codegram.github.com/spinach/"><img class="alignnone size-full wp-image-1160" title="spinach" src="http://watirmelon.files.wordpress.com/2011/10/spinach.png?w=584" alt=""   /></a></p>
<blockquote><p>&#8220;Spinach is a new awesome BDD framework that features encapsulation and modularity of your step definitions.&#8221;</p></blockquote>
<p>Seems like a good idea, so I thought I&#8217;d give it a try, and convert my existing simple <a href="https://github.com/alisterscott/WatirMelonCucumber">Watirmelon Cucumber tests</a> to use Spinach instead (<a href="https://github.com/alisterscott/watirmelon-spinach">link to my source code</a>). It was very easy to do, here&#8217;s some observations:</p>
<ul>
<li>It&#8217;s easy to get existing Cukes running using Spinach, but I imagine if you were starting out using Spinach you&#8217;d design things a lot differently</li>
<li>Steps belong in their own class, but you can include mixins to reuse steps &#8211; the ruby way</li>
<li>Steps are in a <em>steps</em> directory under features &#8211; shorter than <em>step_definitions</em></li>
<li>Goodbye regular expressions in step definitions, which is a bit of a shame, as you can no longer capture values from the step name</li>
<li>As you can&#8217;t have regular expressions in step names, I find myself repeating steps that are similar but slightly different, this means my example steps have gone from 41 to 57 lines of code</li>
<li>Scenario Outlines aren&#8217;t supported at the moment, but I have raised this as a <a href="https://github.com/codegram/spinach/issues/62">feature request</a></li>
<li><a href="http://rubydoc.info/github/codegram/spinach/master/Spinach/Hooks">Hooks</a> are dramatically improved, so I found them very easy to use and understand</li>
<li>There is no cucumber world, so you do a normal include instead, and env.rb is still supported</li>
<li>It displays really cool ticks on the command line when you&#8217;re running your <em>spins</em></li>
</ul>
<p><img class="alignnone size-full wp-image-1161" title="Spinach Results" src="http://watirmelon.files.wordpress.com/2011/10/screen-shot-2011-10-29-at-10-32-39-pm.png?w=584&#038;h=418" alt="" width="584" height="418" /></p>
<p>Well done to Codegram for releasing Spinach. If anything, it creates some great innovations that I imagine may find their way into Cucumber in the future.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/watirmelon.wordpress.com/1159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/watirmelon.wordpress.com/1159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/watirmelon.wordpress.com/1159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/watirmelon.wordpress.com/1159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/watirmelon.wordpress.com/1159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/watirmelon.wordpress.com/1159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/watirmelon.wordpress.com/1159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/watirmelon.wordpress.com/1159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/watirmelon.wordpress.com/1159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/watirmelon.wordpress.com/1159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/watirmelon.wordpress.com/1159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/watirmelon.wordpress.com/1159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/watirmelon.wordpress.com/1159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/watirmelon.wordpress.com/1159/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1159&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://watirmelon.com/2011/10/29/watirmelon-spinach/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/344eed26ff913de38b45620d18eed695?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">alisterscott</media:title>
		</media:content>

		<media:content url="http://watirmelon.files.wordpress.com/2011/10/spinach.png" medium="image">
			<media:title type="html">spinach</media:title>
		</media:content>

		<media:content url="http://watirmelon.files.wordpress.com/2011/10/screen-shot-2011-10-29-at-10-32-39-pm.png" medium="image">
			<media:title type="html">Spinach Results</media:title>
		</media:content>
	</item>
		<item>
		<title>Watir-WebDriver tests on Firefox 7: getting rid of the send data to Mozilla message</title>
		<link>http://watirmelon.com/2011/10/05/watir-webdriver-tests-on-firefox-7-getting-rid-of-the-send-data-to-mozilla-message/</link>
		<comments>http://watirmelon.com/2011/10/05/watir-webdriver-tests-on-firefox-7-getting-rid-of-the-send-data-to-mozilla-message/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 10:30:30 +0000</pubDate>
		<dc:creator>Alister Scott</dc:creator>
				<category><![CDATA[Watir-WebDriver]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[profiles]]></category>
		<category><![CDATA[webdriver]]></category>

		<guid isPermaLink="false">http://watirmelon.com/?p=1138</guid>
		<description><![CDATA[Update 6 October 2011: The send data to Mozilla question will be turned off by default in the next release (2.8.0) of the selenium-webdriver gem which watir-webdriver uses. I&#8217;ve been running Watir-WebDriver tests against Firefox 7, which works superbly. The &#8230; <a href="http://watirmelon.com/2011/10/05/watir-webdriver-tests-on-firefox-7-getting-rid-of-the-send-data-to-mozilla-message/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1138&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Update 6 October 2011:</strong> The send data to Mozilla question will be turned off by default in the next release (2.8.0) of the selenium-webdriver gem which watir-webdriver uses.</p>
<p>I&#8217;ve been running Watir-WebDriver tests against Firefox 7, which works superbly. The biggest change is Firefox 7 now supports performance metrics, so this means you can use the <a title="Easily capturing response time metrics using the Watir-WebDriver-Performance gem" href="http://watirmelon.com/2011/07/19/easily-capturing-response-time-metrics-using-the-watir-webdriver-performance-gem/">watir-webdriver-peformance gem</a>: yay! It also means my <a title="Watir-WebDriver &amp; Cucumber Examples for Etsy.com" href="http://watirmelon.com/2011/04/23/watir-webdriver-etsy/">EtsyWatirWebDriver project</a> now collects page metrics using Firefox.</p>
<p>The only slight annoyance is the presence of the &#8216;send data to Mozilla?&#8217; dialog bar. Never fear, it&#8217;s easily dismissed.</p>
<p><pre class="brush: ruby; light: true;">
require 'watir-webdriver'
profile = Selenium::WebDriver::Firefox::Profile.new
profile['toolkit.telemetry.prompted'] = true
b = Watir::Browser.new :firefox, :profile =&gt; profile
</pre></p>
<p>Enjoy.</p>
<p><img class="alignnone size-full wp-image-1139" title="Send data to mozilla" src="http://watirmelon.files.wordpress.com/2011/10/screen-shot-2011-10-05-at-9-14-51-pm.png?w=584&#038;h=117" alt="Send data to mozilla" width="584" height="117" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/watirmelon.wordpress.com/1138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/watirmelon.wordpress.com/1138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/watirmelon.wordpress.com/1138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/watirmelon.wordpress.com/1138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/watirmelon.wordpress.com/1138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/watirmelon.wordpress.com/1138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/watirmelon.wordpress.com/1138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/watirmelon.wordpress.com/1138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/watirmelon.wordpress.com/1138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/watirmelon.wordpress.com/1138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/watirmelon.wordpress.com/1138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/watirmelon.wordpress.com/1138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/watirmelon.wordpress.com/1138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/watirmelon.wordpress.com/1138/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1138&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://watirmelon.com/2011/10/05/watir-webdriver-tests-on-firefox-7-getting-rid-of-the-send-data-to-mozilla-message/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/344eed26ff913de38b45620d18eed695?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">alisterscott</media:title>
		</media:content>

		<media:content url="http://watirmelon.files.wordpress.com/2011/10/screen-shot-2011-10-05-at-9-14-51-pm.png" medium="image">
			<media:title type="html">Send data to mozilla</media:title>
		</media:content>
	</item>
		<item>
		<title>C#: Avoiding the WebDriverException: No response from server for url</title>
		<link>http://watirmelon.com/2011/10/04/c-avoiding-the-webdriverexception-no-response-from-server-for-url/</link>
		<comments>http://watirmelon.com/2011/10/04/c-avoiding-the-webdriverexception-no-response-from-server-for-url/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 09:52:51 +0000</pubDate>
		<dc:creator>Alister Scott</dc:creator>
				<category><![CDATA[Selenium]]></category>
		<category><![CDATA[SpecDriver]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CSharp]]></category>
		<category><![CDATA[SpecFlow]]></category>
		<category><![CDATA[webdriver]]></category>

		<guid isPermaLink="false">http://watirmelon.com/?p=1135</guid>
		<description><![CDATA[When it comes to automated testing, there&#8217;s not much worse than intermittent failures, especially when they stem from the driver itself. The current version of the C# WebDriver bindings has such a failure, but I worked out a reasonable way &#8230; <a href="http://watirmelon.com/2011/10/04/c-avoiding-the-webdriverexception-no-response-from-server-for-url/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1135&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When it comes to automated testing, there&#8217;s not much worse than intermittent failures, especially when they stem from the driver itself. The current version of the C# WebDriver bindings has such a failure, but I worked out a reasonable way to avoid it happening. Basically it involves creating a WebDriver extension method that I use instead of Driver.FindElement, which tries a number of times to find the element, ignoring the exception that is intermittently raised.</p>
<p>I hope you find this useful if you&#8217;re consuming WebDriver in C#.</p>
<p><pre class="brush: csharp;">
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
namespace Extensions
{
    public static class WebDriverExtensions
    {
        public static SelectElement GetSelectElement(this IWebDriver driver, By by)
        {
            return new SelectElement(driver.GetElement(by));
        }
        public static IWebElement GetElement(this IWebDriver driver, By by)
        {
            for (int i = 1; i &lt;= 5; i++ )
            {
                try
                {
                    return driver.FindElement(by);
                }
                catch (Exception e)
                {
                    Console.WriteLine(&quot;Exception was raised on locating element: &quot; + e.Message);
                }
            }
            throw new ElementNotVisibleException(by.ToString());
        }
    }
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/watirmelon.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/watirmelon.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/watirmelon.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/watirmelon.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/watirmelon.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/watirmelon.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/watirmelon.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/watirmelon.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/watirmelon.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/watirmelon.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/watirmelon.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/watirmelon.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/watirmelon.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/watirmelon.wordpress.com/1135/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1135&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://watirmelon.com/2011/10/04/c-avoiding-the-webdriverexception-no-response-from-server-for-url/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/344eed26ff913de38b45620d18eed695?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">alisterscott</media:title>
		</media:content>
	</item>
		<item>
		<title>Watir-Page-Helper 0.3.0: now with added frames</title>
		<link>http://watirmelon.com/2011/09/21/watir-page-helper-0-3-0-now-with-added-frames/</link>
		<comments>http://watirmelon.com/2011/09/21/watir-page-helper-0-3-0-now-with-added-frames/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 02:50:52 +0000</pubDate>
		<dc:creator>Alister Scott</dc:creator>
				<category><![CDATA[Watir-WebDriver]]></category>
		<category><![CDATA[watir-page-helper]]></category>

		<guid isPermaLink="false">http://watirmelon.com/?p=1132</guid>
		<description><![CDATA[I&#8217;ve just release version 0.3.0 of my watir-page-helper gem, with support for frames. To use a frame, you define it as you would any other element: and then you can use the frame, or any elements within that frame: I &#8230; <a href="http://watirmelon.com/2011/09/21/watir-page-helper-0-3-0-now-with-added-frames/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1132&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just release <a href="http://rubygems.org/gems/watir-page-helper">version 0.3.0</a> of my watir-page-helper gem, with support for frames.</p>
<p>To use a frame, you define it as you would any other element:</p>
<p><pre class="brush: ruby; light: true;">
class PageIFrame &lt; BasePageClass
  direct_url TEST_URL
  frame :iframe, :id =&gt; &quot;myiframe&quot;
  link(:ilink) { |page|  page.iframe.link(:text =&gt; 'Link in an iFrame') }
end
</pre></p>
<p>and then you can use the frame, or any elements within that frame:</p>
<p><pre class="brush: ruby; light: true;">
it &quot;should support elements within a iframe&quot; do
  page = PageIFrame.new @browser, true
  page.iframe.exist?.should be_true
  page.ilink_link.exist?.should be_true
  page.ilink
end
</pre></p>
<p>I hope you find this update useful.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/watirmelon.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/watirmelon.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/watirmelon.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/watirmelon.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/watirmelon.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/watirmelon.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/watirmelon.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/watirmelon.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/watirmelon.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/watirmelon.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/watirmelon.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/watirmelon.wordpress.com/1132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/watirmelon.wordpress.com/1132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/watirmelon.wordpress.com/1132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1132&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://watirmelon.com/2011/09/21/watir-page-helper-0-3-0-now-with-added-frames/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/344eed26ff913de38b45620d18eed695?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">alisterscott</media:title>
		</media:content>
	</item>
		<item>
		<title>Visible content locators and i18n in automated tests</title>
		<link>http://watirmelon.com/2011/09/20/visible-content-locators-and-i18n-in-automated-tests/</link>
		<comments>http://watirmelon.com/2011/09/20/visible-content-locators-and-i18n-in-automated-tests/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 11:28:18 +0000</pubDate>
		<dc:creator>Alister Scott</dc:creator>
				<category><![CDATA[Automated Testing]]></category>
		<category><![CDATA[Test Automation]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[selectors]]></category>
		<category><![CDATA[xpath]]></category>

		<guid isPermaLink="false">http://watirmelon.com/?p=1128</guid>
		<description><![CDATA[I recently read a rebuttal to my post about death to xpath selectors, which raises a point of not using user visible strings in/as selectors to identify elements. The reasoning is that if the time comes to internationalize your site, &#8230; <a href="http://watirmelon.com/2011/09/20/visible-content-locators-and-i18n-in-automated-tests/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1128&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently read a <a href="http://element34.ca/blog/death-to-visible-content-as-locators-in-automated-tests">rebuttal</a> to my post about <a title="Death to xpath (and css) selectors in automated tests" href="http://watirmelon.com/2011/08/09/death-to-xpath-and-css-selectors-in-automated-tests/">death to xpath selectors</a>, which raises a point of not using user visible strings in/as selectors to identify elements. The reasoning is that if the time comes to internationalize your site, then your selectors will be brittle as they&#8217;re written in a specific language.</p>
<p>Fair point, but if you&#8217;re not testing the location of user visible content, then what are you testing? In Australia, I have found it rare (like one project out of about thirty I&#8217;ve worked on) that additional languages are supported. But on that one project I used visible user strings to locate objects that weren&#8217;t brittle whatsoever. But how? Adam says you can&#8217;t do it!</p>
<p>Well, I translate my locators too. That way I am testing both the <em>functionality</em> of the site, the <em>content</em> of the site, and the <em>internationalized content</em> of the site, all at once! No hands.</p>
<p>So how would I do it for my said poor example I used previously?</p>
<p>I&#8217;d wrap any selector with something like translate</p>
<p><pre class="brush: ruby; light: true;">
  @browser.link(:text =&gt; translate('Buy')).click
</pre></p>
<p>and have a translate method defined in a mix-in:</p>
<p><pre class="brush: ruby; light: true;">
def translate phrase
  #translate some phrase here using same method as AUT
  phrase
end
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/watirmelon.wordpress.com/1128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/watirmelon.wordpress.com/1128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/watirmelon.wordpress.com/1128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/watirmelon.wordpress.com/1128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/watirmelon.wordpress.com/1128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/watirmelon.wordpress.com/1128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/watirmelon.wordpress.com/1128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/watirmelon.wordpress.com/1128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/watirmelon.wordpress.com/1128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/watirmelon.wordpress.com/1128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/watirmelon.wordpress.com/1128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/watirmelon.wordpress.com/1128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/watirmelon.wordpress.com/1128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/watirmelon.wordpress.com/1128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1128&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://watirmelon.com/2011/09/20/visible-content-locators-and-i18n-in-automated-tests/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/344eed26ff913de38b45620d18eed695?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">alisterscott</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting Firefox download.dir with watir-webdriver on Windows</title>
		<link>http://watirmelon.com/2011/09/19/setting-firefox-download-dir-with-watir-webdriver-on-windows/</link>
		<comments>http://watirmelon.com/2011/09/19/setting-firefox-download-dir-with-watir-webdriver-on-windows/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 01:28:34 +0000</pubDate>
		<dc:creator>Alister Scott</dc:creator>
				<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Watir-WebDriver]]></category>

		<guid isPermaLink="false">http://watirmelon.com/?p=1123</guid>
		<description><![CDATA[I was recently unsuccessfully trying to set the Firefox download directory on Windows using a Watir-WebDriver/Selenium-WebDriver profile. Thanks to a comment on this blog, it turns out there is a bug whereby if your download path contains a \n or &#8230; <a href="http://watirmelon.com/2011/09/19/setting-firefox-download-dir-with-watir-webdriver-on-windows/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1123&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was recently unsuccessfully trying to set the Firefox download directory on Windows using a Watir-WebDriver/Selenium-WebDriver profile. Thanks to a <a href="http://watirmelon.com/2011/09/07/determining-file-mime-types-to-autosave-using-firefox-watir-webdriver/#comment-3436">comment</a> on this blog, it turns out there is a bug whereby if your download path contains a \n or \r, then it reverts back to the default location.</p>
<p>So, a download path like &#8220;C:\new\raw&#8221; will fail without telling you why.</p>
<p>Fortunately, it&#8217;s now been <a href="http://code.google.com/p/selenium/issues/detail?id=2485">fixed</a>, but hasn&#8217;t been released, so in the meantime, you can double escape it</p>
<p><pre class="brush: ruby; light: true;">
require 'watir-webdriver'
p = Selenium::WebDriver::Firefox::Profile.new
p['browser.download.dir'] = &quot;C:\\\\new\\\\raw&quot;
p['browser.download.folderList'] = 2
p['browser.helperApps.neverAsk.saveToDisk'] = &quot;application/pdf&quot;
b = Watir::Browser.new :firefox, :profile =&gt; p
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/watirmelon.wordpress.com/1123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/watirmelon.wordpress.com/1123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/watirmelon.wordpress.com/1123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/watirmelon.wordpress.com/1123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/watirmelon.wordpress.com/1123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/watirmelon.wordpress.com/1123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/watirmelon.wordpress.com/1123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/watirmelon.wordpress.com/1123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/watirmelon.wordpress.com/1123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/watirmelon.wordpress.com/1123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/watirmelon.wordpress.com/1123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/watirmelon.wordpress.com/1123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/watirmelon.wordpress.com/1123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/watirmelon.wordpress.com/1123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=watirmelon.com&amp;blog=2177915&amp;post=1123&amp;subd=watirmelon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://watirmelon.com/2011/09/19/setting-firefox-download-dir-with-watir-webdriver-on-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/344eed26ff913de38b45620d18eed695?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">alisterscott</media:title>
		</media:content>
	</item>
	</channel>
</rss>
