Filed under Ruby, Technical testing by Jared on May 18, 2011 at 12:36 pm
no comments
Tim seems to be pretty busy now that he’s a free agent, so I’m looking forward to trying this new(ish) gem he announced recently for querying browser performance stats.
I can’t believe it’s been as long as it has since I last posted. This has mostly been because I’ve been busy preparing to become a dad. I’m a dad as of two weeks ago, and have a new job, so as things settle down I hope to get through my backlog of posts, mostly on technical topics and tools.
Filed under Ruby, Software Testing by Jared on January 25, 2011 at 1:07 pm
2 comments
Alister Scott has posted some code examples on watirmelon.com that show different solutions to a problem that arises for people implementing the Page Object pattern for test automation.
I found Alister’s approach solutions interesting, because as my automation usually models business/user goals and/or domain features/concepts, I don’t often have my own page abstraction. See http://gojko.net/2009/10/06/putting-selenium-in-the-right-place/ for an example of the approach I’m thinking of.
At the top level might be something like:
google=Google.new
google.search(search_phrase)
At the next level down, I potentially want to be independent of the user interface, so it doesn’t make sense to organise around page components. I might have something like:
def search(search_phrase)
enter_search(search_phrase)
submit_search
....
end
When we get to the third (task) level, this is still at a user or business activity level, so the page model still doesn’t make sense for me. I’ll just use the browser driver directly (or my own driver abstraction):
def submit_search
Driver.button(:value, => "Google Search").click
end
Yes, I could have another level here such as:
def submit_search
GoogleHomepage.search_button.click
end
In most cases though, the task-level UI element has a single purpose, so there’s not much of an issue with violating DRY. I also try to keep the automation stack as small as possible, so can tolerate a little bit of duplication. Regardless, it’s easily factored out into a new method if duplication becomes an issue because methods are common to the domain.
I’ve seen some frameworks that have a really abstract UI driver at the next level (so that they could drive a rich client app, a mobile app and a web app all using the same methods), but I’ve never needed to do that.
I favour a business/domain oriented approach because at the business level, the goals and activities don’t change that much (and I tend to let the automation lag behind my understanding of the problem). It also encourages me to pay attention to the things that matter and be less implementation-focused.
Filed under Performance testing, Ruby by Jared on September 28, 2010 at 11:55 am
no comments
I’m hacking away at a tool to give me better JMeter results, and I needed to see progress as I iterated through the data I’d imported into MySQL. The progress bar described in my earlier post can be made to work with a simple addition:
class Sequel::Dataset
alias :size :count
end
This adds the necessary ’size’ method to Sequel’s dataset and everything’s happy.
Filed under Test automation, Watir by Jared on September 27, 2010 at 10:24 am
2 comments
My friend James has been using watir-webdriver to test his latest work. He was having trouble with Firefox prompting for the location to save files, which blocked the scripts he was running. While I’d like to claim some credit for pointing him at some helpful links, I think my real contribution was limited to being a friendly ear.
Anyway, he figured out how to fix this by changing the profile that Firefox runs with, so now you won’t have to. Check out his solution at http://jamesladdcode.com/?p=338
Filed under Technical testing, Test Tools by Jared on August 16, 2010 at 11:35 am
8 comments
Jonathan Kohl pointed me at Sikuli, a Python-based tool for automating applications using image recognition. Unlike most tools, which attempt to identify objects via public APIs, Sikuli looks at the pixels on the screen and attempts to identify objects based on how they look.
This isn’t exactly a new approach, as commercial tools have had this feature for a long time as a means of creating custom objects. So after playing with Sikuli, I wondered whether I could take advantage of it as a library to augment my Watir scripts in Ruby.
It turns out, the answer is ‘yes’, with a caveat. You need to use JRuby (although you could probably do it in Ruby using the Ruby-Java bridge – It just looked a lot harder), and you also need to use Watir-Webdriver, a new implementation of Watir’s API which is used in a number of other automation frameworks.
Below is a simple example script and instructions to get you started. It navigates to a website, then clicks on the flash control there. I’ve so far only tested this on Windows. It should work on OSX and Linux, but perhaps not quite so easily (I’m waiting on some feedback). Check the instructions for ‘Install OpenCV’ at the page with instructions for calling Sikuli from other tools.
Sikuli can be used to automate Flash components, any challenging AJAX elements of your web application, to dismiss pop-ups or probably even to inspect visual elements of the page (though I’d want to do this minimally). It’s a little slow, but an interesting and immediately useful add-on to Watir or your favourite java-based testing tool.
#Install Java, or install the JRuby/JRE bundle at the next step
#Install JRuby 1.5.1 - http://jruby.org/download
#Install Sikuli - http://sikuli.org/download.shtml
#Install watir-webdriver (eg. jgem install watir-webdriver)
#Update ssh - jgem install jruby-openssl
#Copy sikuli-script.jar to \jruby-1.5.1\lib
#Get the test image
#Download http://www.software-testing.com.au/images/flashmap_middleeast.png and put it in the image folder as below
#See http://sikuli.org/trac/wiki/How to use Sikuli Script in your JAVA programs for examples
require ‘rubygems’
require ‘watir-webdriver’
require ‘java’
java_import “org.sikuli.script.SikuliScript”
java_import “org.sikuli.script.Region”
java_import “org.sikuli.script.Screen”
start_page=’http://www.lonelyplanet.com’
image_folder=”c:/sikuli_icons/”
$screen=Screen.new
$browser=Watir::Browser.new :ie
$browser.goto start_page
$screen.click(“#{image_folder}flashmap_middleeast.png”,0)
http://sikuli.org/download.shtml
Filed under Test Tools, Test automation by Jared on July 26, 2010 at 5:35 pm
no comments
I’ve been finding popups in Watir a pain of late, with most of the solutions on watir.com not working for me. Finally today, I found something that worked. Steve Swanson’s solution did the trick.
However, before it could work, I had to figure out that the AutoIT dll wasn’t correctly registered. If you try the solution above and find it to be behaving mysteriously, then try the steps on Watir.com’s FAQ page.
Filed under Software Testing, Test Tools by Jared on July 1, 2010 at 10:32 am
no comments
Today I found out that my post on Watir and TinyMCE let someone dump their Quick Test Pro licences.
A victory for common sense…
Nothing against QTP, but if you’re testing web applications, you should probably be looking at other tools.
Filed under Technical testing, Test Tools by Jared on May 28, 2010 at 3:26 pm
2 comments
Continuing the ‘what tool’ theme from last week, today’s topic is ‘Diff’.
I frequently install windows versions of various Unix command line utilities via the Gnu Utilities for Win32 project. Diff is particularly handy not just for the programming side of automation, but also for comparing output files from automation as well as database queries. Occasionally though, I need the niceties of a graphical tool that handles side-by-side comparison of file differences a bit more nicely. So I installed KDiff3 (http://kdiff3.sourceforge.net/), and it seems pretty good, supporting three-way comparisons.
I also looked at Winmerge which has a portable version. It seems to have a nicer file diff view, but KDiff has a nicer view of folder differences. Given that it’s portable, it will go onto my tester toolkit (although there’s some evidence KDiff may be portable enough for my needs).
Are there other diff tools I should know about?
Filed under News, Test automation by Jared on February 22, 2010 at 11:50 am
no comments
I’ve just updated my celerity gem and it seems to fix all of the warnings that were flooding my scripts before.
Performance is still a touch disappointing with our website, but the changes make it much more usable (and there’s an option to turn javascript off now according to the docs at http://rubyforge.org/forum/forum.php?forum_id=34490).
Filed under Communication, Humanising work by Jared on July 27, 2008 at 7:00 am
2 comments
“In the universe, nothing can be said to be automatic, as nothing can be said to be without design. An imperfect parallel may be found in human inventions; springs may move springs, and wheels, indexes; but the motion and the regulation must be derived from the artist;”
From Elements of Chemical Philosophy Part 1, Vol.1 By Humphry Davy
Of course, the second step will be taking my automation or testing tools course (plug, plug).