<?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/"
	>

<channel>
	<title>Transcending Frontiers &#187; How to Get Firebug, Capybara and Selenium Working Together</title>
	<atom:link href="http://blog.thefrontiergroup.com.au/tag/cucumber/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.thefrontiergroup.com.au</link>
	<description>Your peek inside the collective mind of The Frontier Group</description>
	<lastBuildDate>Mon, 02 Apr 2012 04:32:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>How to Get Firebug, Capybara and Selenium Working Together</title>
		<link>http://blog.thefrontiergroup.com.au/2010/11/how-to-get-firebug-capybara-and-selenium-working-together/</link>
		<comments>http://blog.thefrontiergroup.com.au/2010/11/how-to-get-firebug-capybara-and-selenium-working-together/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 06:07:26 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Inside TFG]]></category>
		<category><![CDATA[capybara]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=1058</guid>
		<description><![CDATA[I had an issue whereby a label I thought was fine wasn&#8217;t being picked up on my Cucumber tests. It turned out that the test environment was of course running our compiled javascript and I hadn&#8217;t compiled it since my change. The labels didn&#8217;t have the &#8216;for&#8217; attribute specified so Selenium was whinging it couldn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I had an issue whereby a label I thought was fine wasn&#8217;t being picked up on my Cucumber tests. It turned out that the test environment was of course running our compiled javascript and I hadn&#8217;t compiled it since my change. The labels didn&#8217;t have the &#8216;for&#8217; attribute specified so Selenium was whinging it couldn&#8217;t find the element I wanted to find. </p>
<p>In any case I couldn&#8217;t find an explanation of how to get Firebug working with Selenium and Capybara but after some doc reading I got my solution working so I thought I&#8217;d post it here. </p>
<p>In my env.rb file I have : </p>
<pre>
Capybara.register_driver :selenium do |app|
  Capybara::Driver::Selenium
  profile = Selenium::WebDriver::Firefox::Profile.new
  profile.add_extension(File.expand_path("features/support/firebug.xpi"))

  Capybara::Driver::Selenium.new(app, { :browser => :firefox, :profile => profile })
end
</pre>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://blog.thefrontiergroup.com.au/2010/11/how-to-get-firebug-capybara-and-selenium-working-together/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://blog.thefrontiergroup.com.au/2010/11/how-to-get-firebug-capybara-and-selenium-working-together/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Database Transactions in Cucumber Breaking Selenium</title>
		<link>http://blog.thefrontiergroup.com.au/2009/10/database-transactions-in-cucumber-breaking-selenium/</link>
		<comments>http://blog.thefrontiergroup.com.au/2009/10/database-transactions-in-cucumber-breaking-selenium/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 06:00:06 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Inside TFG]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[selenium]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=441</guid>
		<description><![CDATA[We&#8217;ve been using Selenium, Webrat, Cucumber and any number of other gems together for quite a while with very few problems. Just recently our Selenium tests just stopped working on the login step, and given our application requires users to login to do anything, it meant out test suite was basically broken from step one. [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been using Selenium, Webrat, Cucumber and any number of other gems together for quite a while with very few problems. Just recently our Selenium tests just stopped working on the login step, and given our application requires users to login to do anything, it meant out test suite was basically broken from step one.</p>
<p>Given that we thought very little of any consequence had changed it was annoying trying to troubleshoot the problem. Typically you start off thinking it&#8217;s something you did, then maybe it&#8217;s something someone you know did, then you start to branch out and think that maybe, just maybe, it was a bug elsewhere!</p>
<p>I initially started to check the logs and they seemed perfect, but it wasn&#8217;t finding the user record in the database. So I loaded the database in sqlite and lo-and-behold there were no user records to be found. I started a debug session and it reported that the user had in fact been created. I thought it had to be something to do with transactions being used. Trying to insert a record into the database and being told the database was locked confirmed this.</p>
<p>I turned out that the Cucumber gem writer determined that there should be no more global setting for turning on or off transaction support when running tests. Previously transactions were turned off by default in Cucumber, and you&#8217;d generally turn them back on if you needed them. This change is annoying because a good chunk of our suite uses Selnium for testing and it requires transactions to be turned off. It&#8217;s also a bit odd to reverse a default option and have no way to enable it at all.</p>
<p>Apparently the work around is to tag all the features and scenarios that rely on non-transactional database operations with this new tag of @no-txn. After implementing this, we&#8217;ve found it does work and so our tests are back to usual condition.</p>
<p>So if you&#8217;re running into problems with your Selenium tests using Cucumber with Rails and your database isn&#8217;t updating within a test then check out the &#8216;@no-txn&#8217; tag and see what happens after you use that.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://blog.thefrontiergroup.com.au/2009/10/database-transactions-in-cucumber-breaking-selenium/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://blog.thefrontiergroup.com.au/2009/10/database-transactions-in-cucumber-breaking-selenium/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Testing File Uploads with Webrat and Paperclip</title>
		<link>http://blog.thefrontiergroup.com.au/2009/06/testing-file-uploads-with-webrat-and-paperclip/</link>
		<comments>http://blog.thefrontiergroup.com.au/2009/06/testing-file-uploads-with-webrat-and-paperclip/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 03:13:23 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Paperclip]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Webrat]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=389</guid>
		<description><![CDATA[&#8211; Check out some of our more recent Ruby on Rails blog posts. If you&#8217;d like to hire our team, get in touch &#8211; I wanted to integrate some branding functionality into an application we&#8217;re developing and so I needed test file upload functionality. We&#8217;re using Webrat for integration tests, though this will likely change as [...]]]></description>
			<content:encoded><![CDATA[<p><em style="font-style: italic;">&#8211; Check out some of our more recent </em><a title="Ruby on Rails posts" href="http://thefrontiergroup.com.au/blog/category/ruby-on-rails/"><em style="font-style: italic;">Ruby on Rails blog posts</em></a><em style="font-style: italic;">. If you&#8217;d like to hire our team, <a title="Get in touch" href="http://thefrontiergroup.com.au/pages/contact-us">get in touch</a></em><em style="font-style: italic;"> &#8211;</em></p>
<p>I wanted to integrate some branding functionality into an application we&#8217;re developing and so I needed test file upload functionality. We&#8217;re using Webrat for integration tests, though this will likely change as we increase the amount of Javascript in the app. I added Paperclip to handle the file attachments for logos, and everything was working.</p>
<p>When I added validation to the model, making sure that the file being attached was an image, this broke the tests. It didn&#8217;t seem to matter what type the file was, it would fail no matter what on the file type validation.</p>
<p>I used ruby-debug to debug my test and it seems by default Webrat sends file uploads as plain text. It does have the option to specify the file type when attaching the file, so the easiest way around this is just to specify the MIME type for the file. Now my Cucumber step looks something like this :</p>
<pre class="ruby">When /^I attach "([^\"]*)" image to the "([^\"]*)" file field$/ do |filename, field|
  type = filename.split(".")[1]

  if type == "jpg"
    type = "image/jpeg"
  end

  attach_file field, File.join(RAILS_ROOT, test_asset_path, filename), type
end</pre>
<p>Obviously this will need some work as I progress, but it works. At this stage I have an assets folder in my features folder to store any files that I need for my tests.</p>
<p>On the confirmation end of the test I just have a simple tag test to check that the image tag is displaying, and it contains the correct src attribute :</p>
<pre class="ruby">Then /^I should see tag "(.+)"$/ do |selector|
  (Hpricot(response.body)/selector).should_not be_empty
end</pre>
<p>So in my feature test I have :</p>
<pre class="ruby">Then I should see tag "img[@src*='']"</pre>
<p>This just confirms that there is an image tag that contains the file name of the file that I uploaded in the test.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://blog.thefrontiergroup.com.au/2009/06/testing-file-uploads-with-webrat-and-paperclip/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://blog.thefrontiergroup.com.au/2009/06/testing-file-uploads-with-webrat-and-paperclip/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

