Željko Filipin's Blog on Software and Testing

Test like you do not need the money.

Archive for March, 2006

UTF-8 and Ruby

with 4 comments

I use Watir to test web applications.

At application under test, after user is created I need to get her or his database id. I use it later to check if script is at the right page. For example, view user page url is

http://{application_under_test}/ViewUser.aspx?m={user_database_id}

I have to know user database id to check url.

My developer made xml page with all users. Only username and database id are displayed.

Script goes there and grabs database id.

require “watir”
require “rexml/document”

username = “Aragon”
ie = Watir::IE.start(“{application_under_test}/users.xml”)
root = REXML::Document.new(ie.text).root
db_id = root.elements["item[@username='#{username}']“].attributes["id"]
puts db_id

And it works just fine.

Then, we imported data from production database. And my script returns this error:

C:\ruby\lib\ruby\1.8/rexml/parsers/treeparser.rb:85:in `parse’: #

Last 80 unconsumed characters:

There is user with username Aragón, and my script has a problem with it.

The solution? Install Ruby 1.8.3. or 1.8.4. and put this at the begging of your script:

require “win32ole”
WIN32OLE.codepage = WIN32OLE::CP_UTF8

Written by Željko Filipin

March 15th, 2006 at 1:48 pm

Posted in Ruby

FireWatir (WATiR on Firefox) Alpha v1.0 Released

without comments

You can find it here and Installation Guide is here.

More info is here.

I could not make it work. I hope I will make it work these days.

Written by Željko Filipin

March 14th, 2006 at 1:46 pm

Posted in Watir