Migrating to natritmeyer.com & SitePrism update

I’ve been using wordpress for this site for years. Amongst other problems, adding code snippets has been a pain; it’s not really designed for tech blogs. I’ve migrated to using GitHub pages here:

http://natritmeyer.com/

As of today, I’m no longer updating this site. See you on the other side!

PS: there’s a new version of SitePrism; I blogged about it here.

SitePrism 2.4 – #find, #has_no_element? & Capybara 2.1

SitePrism 2.4 is out! It contains the following changes:

  • It uses #find instead of #first to locate items on a page (this should increase the reliability of your tests) – you don’t need to make any changes, this is an ‘under-the-hood’ fix :)
  • A new #has_no_<element>? method has been added
  • Capybara 2.1 is now a dependency

Migrating a Capybara test suite requires a few changes to your code; since SitePrism sits on top of Capybara you’re going to have to make a few tweeks. Fear not, I’ve summarized them here:

In your Gemfile (assuming you use Selenium as your browser driver), add the following line:

  • gem ‘selenium-webdriver’

In your Capybara config block (probably in your env.rb file if you’re using cucumber or your spec_helper.rb file if you’re using rspec), add the following lines:

  • config.match = :prefer_exact
  • config.ignore_hidden_elements = false

The above will replicate the behaviour of Capybara 1.*. If you want more details, take a look at Jonas Nicklas’ post entitled Introducing Capybara 2.1, particularly if you want to replicate Capybara 2.0 behaviour rather than 1.* behaviour.

Enjoy!

SitePrism 2.1 – XPath Edition

SitePrism 2.1 is out, and thanks to a pull request from 3coins you can now use xpath instead of css if you like. Take a look at the docs here: http://rdoc.info/gems/site_prism/file/README.md#CSS_Selectors_vs__XPath_Expressions.

As usual, find SitePrism here: https://github.com/natritmeyer/site_prism

SitePrism 2.0

SitePrism 2.0 is out! Woo! So what’s changed in the API?

Nothing. Nothing at all.

So why release a new version? Well, all previous versions of SitePrism were dependent on Capybara 1.x. Now that Capybara has moved on to 2.x, SitePrism needed a few changes under the hood to get it to work with the new Capybara. That’s all! It just makes sense for SitePrism to be on the same ‘major version’ as Capybara.

Oh, there is one thing: since Capybara 2 doesn’t work with ruby 1.8 any more, SitePrism doesn’t either. You’ll need ruby 1.9 to use the new SitePrism.

Yarjuf – Yet Another RSpec JUnit Formatter (for Jenkins)

So, I’ve previously put together an JUnit formatter for RSpec so I can use RSpec with Jenkins/Hudson, but it was a bit of a hack. People seem to use and like it so I’ve redeveloped it and packaged it as a gem. I’ve also fixed a few problems with it, particularly how it groups tests together. It’s called… “Yet Another RSpec JUnit Formatter“, AKA: yarjuf. Inspired, I know.

Read about it here: https://github.com/natritmeyer/yarjuf

To install: gem install yarjuf

Assertions in Page Object methods?

A little while back, a question was asked on StackOverflow: “Why not include assertions in page methods?

I wrote an answer (something along the lines of: “Almost Never“) and it would be cool if more people added their own thoughts to the question. Whether methods in page objects should contain assertions is a debate that never goes away…

So, assertions in page object methods? Or not? Either way, go write up your thoughts!

Firefox plugin: Test Automation Password Manager

I’ve recently come across a problem when doing UI testing with Firefox on a Mac against a web app that uses NTLM authentication. Every time I navigated to the web app I was presented with a dialog box asking me for my username and password.

I did some reading and came across Alister Scott’s Automatic Firefox authentication when using Selenium-WebDriver with AutoAuth post. In it he explains a way to get around the problem:

- Create a Firefox profile using the profile manager
- Add the required credentials to the profile
- Use the above Firefox profile when running tests
- Add the AutoAuth plugin to the profile at test execution time

The above would get around my problem, but it would lead to having to maintain a firefox profile which isn’t nice. So, I decided to attempt writing a firefox plugin that would allow me to add credentials to firefox’s password manager at runtime using Javascript. After all, according to the documentation it looked possible…

After a bit of hacking, the result is my first Firefox plugin: the Test Automation Password Manager plugin. It’s quite simple to use; you can find instructions here:

https://github.com/natritmeyer/test_automation_firefox_password_manager

…and the plugin page here:

https://addons.mozilla.org/en-US/firefox/addon/test-automation-password-ma/

I’ve not tested it extensively – “It Works On My Machine:)