TestGen4Ruby: One Point Oh

From regular versioning culture, one would think that TestGen4Ruby has just graduated and is now an all-mature big boy. False. Just as a clarification, I’m using the versioning scheme suggested by Rubygem’s manual, which can be summed up as: left number => breaks compatibility; middle number => adds new feature without breaking previous stuff; right number => bugfix, cleanup or some other minor change that doesn’t affect the API.

More explanation and arguments in favor of this strategy can be found at the manual itself.

This new version basically fixes a little problem with the input from TestGen4Web. It’s a dirty little fix that doesn’t cover all cases, because that is impossible from inside tg4rb. To fix this for good, a good many changes must be made to tg4w itself. I’m currently working on this.

Just so the “One Point Oh” spirit doesn’t get totally blown away by the clever versioning policy, there is a graduation of sorts going on for TestGen4Web today: this is the last change that is part of my work during the Google Summer of Code (I didn’t have time to commit this before the “pencils down” deadline so I’m releasing now, but it was coded inside that time window). So from now on I’ll just keep fiddling with it on my own. It is a good feeling knowing that now I have a little (my first!) baby free software project on my hands :-)

Well, to the official release notes already:

Subject: [ANN] tg4rb 1.0.0 Released

tg4rb version 1.0.0 has been released!

* <by Helder Ribeiro>
* <(http://tg4rb.googlecode.com)>

## FEATURES:

* takes an XML with actions from tg4w and outputs stand-alone Ruby code that can be run directly or embedded into existing code (e.g. for test automation).
* can be used as a library or as an executable script.
* takes the xpath from tg4w and uses only enough info to guarantee the uniqueness of the referenced element, allowing the generated script to keep working even with some change to page structure.

## PROBLEMS:

* the generated code is damn ugly.
* a few action types from the XML input still aren’t recognized.
* some dependencies aren’t very clearly sorted out yet. you might find you need something that is not specified. if yes, please report this as an issue in our issue tracker.
* i don’t know, find more and let me know =)

## SYNOPSIS:

Changes:

## 1.0.0 / 2007-08-21
* NOTE: This version breaks compatibility with previous version! Scripts written in previous versions won’t work.
* fixed small bug with escaping single quotes
* API change: changed the visibility of element_by_least_restrictive_xpath in Tg4rbToolbox to private
* API change: created public method element() in Tg4rbToolbox
* provided workaround for bug in xpath from tg4w: now clicks on links work with the link’s text (requires HPricot)

## 0.0.2 / 2007-07-09
* fixed silly import problem on generated script

* <by Helder Ribeiro>
* <(http://tg4rb.googlecode.com)>

[ANN] tg4rb 0.0.2 Released!!

Here’s my Google Summer of Code baby!!! =D If you find any problem with the code or the documentation, please send an email to the mailing list or post an issue in our issue tracker. I’m off to Peru today, so I might not check email too often, but I’ll try my best to keep up. Enjoy!

* <by Helder Ribeiro>
* <(http://code.google.com/p/tg4rb)>

## FEATURES:

* takes an XML with actions from tg4w and outputs stand-alone Ruby code that can be run directly or embedded into existing code (e.g. for test automation).
* can be used as a library or as an executable script.
* takes the xpath from tg4w and uses only enough info to guarantee the uniqueness of the referenced element, allowing the generated script to keep working even with some change to page structure.

## PROBLEMS:

* the generated code is damn ugly.
* a few action types from the XML input still aren’t recognized.
* some dependencies aren’t very clearly sorted out yet. you might find you need something that is not specified. if yes, please report this as an issue in our issue tracker.
* i don’t know, find more and let me know =)

## SYNOPSIS:

Changes:

## 0.0.2 / 2007-07-09
* fixed silly import problem on generated script

## 0.0.1 / 2007-07-09
- Birthday
* <by Helder Ribeiro>
* <(http://code.google.com/p/tg4rb)>

Posted in Uncategorized. Tags: , , , , , , . 1 Comment »

TestGen4Web from SVN (or howto start contributing to it)

Yes, this is “from svn”, but first we need to install the current release and then replace it by the code from svn (there must be a better way of doing this, but this works). Go to

http://developer.spikesource.com/frs/?group_id=14&release_id=71

download and install the latest version (0.41.1-beta). This will create a directory {3c20433a-61bc-42fe-831d-415860e17283} under ~/.mozilla/firefox/vllrmpro.default/extensions (or wherever else your firefox extensions are kept).

Now we have to replace this directory by the TestGen4Web code from SVN. First, though, you’ll need an account at SpikeSource (yes, just to check the thing out; go figure).

Done that, choose a directory where you want to keep that code and check it out from SVN (mine is ~work/):

cd ~/work
svn co http://scm.spikesource.com/testgen4web

This will create a “testgen4web” directory in the chosen directory. Now we replace the old directory by a link to our checked out code:

cd ~/.mozilla/firefox/vllrmpro.default/extensions
rm \{3c20433a-61bc-42fe-831d-415860e17283\} -f
ln -s ~/work/testgen4web/extension \{3c20433a-61bc-42fe-831d-415860e17283\}

[If you're on Windows, emptying out the original directory and copying the contents of testgen4web/extension/ into it should work]

Well, that’s it, basically. Now you go around coding and changing things and, after you’re done, save your files and restart Firefox. It comes up again with your new code loaded automatically. Pretty cool, huh?

You can find more resources about TestGen4Web at:

http://developer.spikesource.com/wiki/index.php/Projects:TestGen4Web

Please drop a comment if you run into any problems while trying to do the above.

Happy Hacking ;-)

Posted in Uncategorized. Tags: , , , , , , , . Leave a Comment »

How to empty a Gmail label with FireWatir

When you have a huge label with thousands of messages, Gmail can’t handle deleting all of them at a time (it says it can, but for me it’s never worked). This solves the problem.

I wrote it more as a practice to get familiar with FireWatir, so it’s not very pretty or anything and it’s a bit slow. I think WWW::Mechanize would be faster at it (although you wouldn’t have the eye-candy of seeing the live action on the browser ;-). I’ll port it to Mechanize, once I have some time, as a bootstrap into learning that too. I’ll have to subscribe to a few more lists in order to have testing ammo for all that. ;-)

If you have doubts on how to use or suggestions on how to improve it please feel free to contact me. It assumes, by the way, that Gmail is in German. Replace that string with the one that comes up for your language.

P.S.: there’s also a syntax highlighted version. Does anyone know of a way to highlight the code here in WordPress?

def empty_label(label)
  # you need a Firefox instance already running with JSSh installed and listening
  ff = Firefox.new
  # Goes to Gmail in HTML
  ff.goto('http://mail.google.com/mail/h/x4odcwnm5f5v/?s=l&l=#{label}')
  a = []
  # doing 'c.set' didn't work for me here so I had to do this hack of getting the value
  # and then acquiring the element through ff.checkbox(:value,value)
  ff.checkboxes.each {|c| a << c.value}

  while a.length > 0 do
    c = []
    a.each {|v| c << ff.checkbox(:value,v)}
    # checks all checkboxes
    c.each {|e| e.set}
    # clicks the drop-down entry for deleting
    ff.select_list(:name,'tact').select('In den Papierkorb verschieben')
    ff.button(:name,'nvp_tbu_go').click
    a = []
    ff.checkboxes.each {|c| a << c.value}
  end
end
Posted in Uncategorized. Tags: , , , , , . Leave a Comment »

One feed per tag in WordPress

WordPress lets you choose to see only the entries with a specified tag from a blog, like, say, http://obvio171.wordpress.com/tag/soc. Thinking it would also have one feed per tag in the same way, I added that address to Planet-Soc as my soc feed.

To my great surprised, it crawled all of my posts and dumped it into the planet (sorry about that guys). I don’t know if they actually have a way to get one feed per tag, but I couldn’t find it, so I wrote the following:

#! /usr/bin/ruby
require 'rss'
rss = RSS::Parser.parse(open('http://obvio171.wordpress.com/feed/'))
channel = RSS::Rss::Channel.new
rss.channel.items.select {|i| !(i.categories.select {|c| c.content == "soc"}).empty?}.each {|i| channel.items << i}
channel.link = rss.channel.link
channel.title = rss.channel.title
channel.description = rss.channel.description
channel.generator = rss.channel.generator
rss.channel = channel
begin
File.delete('rss_soc.xml')
rescue
end
File.new('rss_soc.xml','w') << rss.to_xml

Now I only have to find a way to remove the old feed from planet-soc and add the new one (which btw is hosted at http://www.students.ic.unicamp.br/~ra033245/rss_soc.xml if anyone’s interested).

Posted in Uncategorized. Tags: , , , , , . 2 Comments »

Around the clock

The first aspect of the Free Software culture I immediately got into contact with was the timezone mess. As soon as I got accepted it was very clear what had to be done: “i need to meet up with my mentors”.

I’m in Campinas, ~100km from São Paulo, Brazil, so UTC-3:00. Angrez is in Bangalore, India, UTC+5:30. Aaron is in Seattle, USA, UTC-8:00. When Angrez gets to work early in the morning it’s past midnight for me and it catches Aaron right after a full day’s work. And still it’s the best time for us to meet online.

It’s a bit difficult then to say things like “so should we meet at five?” without having to do some annoying math in your head (I find the simplest math to be the toughest). Good thing that in these cases good-ol’ Google Calendar comes in to the rescue! I’ve set up a shared calendar where I enter the meeting times and everyone sees it conveniently in their own timezone. The simple stuff. :-)

This asynchronous nature of things sheds some light on why the free software communities make the most use (and the most development) of communication and collaboration tools based mainly in text: source code control (I’ve heard that deep conversations go on in SVN commit messages), issue tracking, mailing lists, IRC, IMs, blogs, etc.

At my current work, nobody in my team (including myself) has any experience with projects different from single-programmer course assignments, thesis-related mockup programs and the like. And we work on a big project. And although we have available to us lots of those communication/collaboration tools (the whole IBM proprietary suite), we only make very basic use of reserved checkout/checkin features (we’re dead scared of merges!), we do releases by copying code, we check out thirty files, do lots of different things and commit at the end of the day. Heck, we don’t even comment commits.

For now that’s one very immediate benefit I’ve taken from starting to get my feet wet on the free software world. I’ve become quite interested in these version control, issue tracking things and now I’m studying the documentation for that bloody suite, searching around for tips on best practices (stupid stuff like comment the freaking commit – better yet with a single short descriptive line followed by meatier description -, only commit consistent states to the trunk – we don’t actually use branches yet, I’m just practicing the lingo-, one feature per commit, etc.) and, of course, I’ve been nagging the hell out of my colleagues =)

Firewatir-Gen

So it is official. My proposal for the Google Summer of Code program has been accepted by Ruby Central Inc. and will receive Google funding. The one for Eclipse wasn’t accepted, and it was the one I had dedicated myself less to, so I’m very happy with what I got.

Angrez Singh is my mentor and Aaron Patterson is my co-mentor. It is a great thing that I got such great mentors, because they are very knowledgeable on the field I’m about to embark in. Angrez is the main developer of Firewatir and Aaron is the man behind the Mechanize library.

The title of the proposal was “A Recorder/Code generator for FireWatir” and, for now, I have named the project Firewatir-Gen. I’ve created some empty bootstrap resources:

I’ll be keeping a weekly (in the least) column here where I’ll report the latest developments and decisions taken from the meetings with my mentors (which will happen twice a week). So you can filter the activity for the project specifically (although it will most likely be the *only* activity) through the tag firewatir-gen.

The mailing list for now is open, so everyone is welcome to come in and give their two cents. If the flurry of contributions and discussions get out of hand we might think of making a firewatir-gen-core list and a firewatir-gen-talk one :P

Posted in Uncategorized. Tags: , , . 1 Comment »

The quest for the difference begins

Selenium Core, Selenium RC, Watir, FireWatir, SafariWatir, MineralWatir, Selenium IDE, TestGen4Web. These are all tools related to doing functional testing of web applications. The first six are concerned with providing an API for driving the browser like a user would. The latter 2 record user actions and output code to reproduce them.

Problem is: each has very, very little documentation. And what exists is severely outdated. You can’t tell one from the other.

I’ll start digging up stuff and posting here to keep my findings in one place.

This presentation sheds a bit of light on the differences in architecture between the various Selenia. It’d be great to find the contents of the presentation besides the slides.

Posted in Uncategorized. Tags: , , , , , , . 1 Comment »

Summer of Code All-nighters

After about a week of digging up stuff on Free Software projects, subscribing to a dozen mailing lists, emailing developers, reading documentation, waiting for feedback, thinking up proposals, twisting and changing them, confronting them wih my own limitations and interests, I finally gave birth to two applications for the Google Summer of Code, one for Ruby Central and the other for Eclipse. Below are the abstracts:

The Ruby Central application:

This project aims at allowing users to record normal usage on a website and then have a script generated that can reproduce such actions.

This script is generated in Ruby and can be changed and mixed with existing Ruby code to extend its behaviour, using regular Ruby variables, loop constructs, etc.

A parser is going to be built for Firefox logs of user-activity (extracted by existing free software extensions) with the ability to generate code for the browser-driving tool FireWatir.

The Eclipse application:

Ruby has a fast-growing community which has not yet settled for one particular
editor/IDE and still has ongoing debates on that topic. It has not found a home
yet.

The ability to change one’s surroundings and make it more confortable for daily
usage by implementing helpers appropriate to one’s specific needs is crucial in
having this feeling of acquaintance and familiarity with a tool.

Unfortunately, the barrier of entry into Eclipse plug-in development for Ruby
users is still pretty high, as few are as skilled in Java as they are in Ruby.

This project aims to bridge that gap by allowing Eclipse plug-ins (or a subset
of the possible ones) to be develop entirely in Ruby.

This last one was written on a rush and with almost no previous research so it’s not very well-finished. I’m open to any ideas and suggestions on either one.