Monday, February 21, 2011

Last week, I have just upgraded my cucumber gem from 0.6.4 into 0.10.0 as the documentation says that the new gem from 0.7 onward should be able to parse the gherkin text 50-100 times faster.

However, after I upgraded to version 0.10.0, I get the following warning

*** WARNING: You must use ANSICON 1.31 or higher
(http://adoxa.110mb.com/ansicon) to get coloured output on Windows

I actually like the win32console better than this as you can just put the win32console gem into your gemfile so you don't have to install ansicon separately.

Anyway, here are the steps on how to install ansicon.exe:

1. Download and unzip the file from https://github.com/adoxa/ansicon/downloads
2. open cmd and navigate to the unzipped folder
3. Navigate to x64 (if you have a 64 bit machine) otherwise navigate to x86
4. Type ansicon.exe -h and you will get the following:
D:\Data\ansicon\x86>ansicon.exe -h
ANSICON by Jason Hood .
Version 1.32 (22 December, 2010). Freeware.
http://ansicon.adoxa.cjb.net/
Process ANSI escape sequences in Win32 console programs.
ansicon -i|I | -u|U
ansicon [-m[]] [-p | -e|E string | -t|T [file(s)] | program [args]]
-i install - add ANSICON to the AutoRun entry (implies -p)
-u uninstall - remove ANSICON from the AutoRun entry
-I -U use local machine instead of current user
-m use grey on black ("monochrome") or as default color
-p hook into the parent process
-e echo string
-E echo string, don't append newline
-t display files ("-" for stdin), combined as a single stream
-T display files, name first, blank line before and after
program run the specified program
nothing run a new command processor, or display stdin if redirected
is one or two hexadecimal digits; please use "COLOR /?" for details.
5. Execute 'ansicon.exe -i' to install and add ansicon to your Windows
6. Run your cucumber 0.10.0 test and you should
get the coloured output result on Windows

I use gem bundler for my test and in the past I only run it on Mac and therefore I didn't have to configure it to run in Windows. However, now I need to be able to run gem bundler in Windows, Ubuntu and Mac. This is because there are some gems that I specifically need to install only for Windows.

To configure your gemfile for windows platform, simply use the following syntax in your gemfile:

Tuesday, February 8, 2011

I have been forced to use the 'sleep' method to wait for my page to load before I can check elements on the page as a temporary solution to my problem. The tests that I have been running somehow cannot get the element that I wanted. If I use the sleep method and wait for 1 - 2 seconds, then the test will be able to find that element. This is not an ideal solution. The automation test should be able to wait automatically until it can find the element on the page and we should not specify the time to wait.

I am currently using Gizmo, a page model testing framework, to dry up my testing assertion.

The code above turns out to not give me the latest html content. The reason is because Gizmo is using Nokogiri to get the HTML content. When the page is initialized it will grab whatever html content it is currently loading. That is why my "@document.css("#navigation_listings").inner_text" returns nill instead of the text that I want.

One solution is to always 'Refresh' the page by assigning @document with the latest html content again "@document = Nokogiri::HTML(body)". However, this is not ideal because you have to refresh every time you want to get the value.

Another solution is to just not use the @document variable but to just use the capybara find method which will automatically wait until it finds the element to appear on the page. I eventually use this Capybara 'find' method over the @document.