Wednesday, August 24, 2011

Some of my findings while working with cucumber

Finding # 1


I was wondering how to use utf8 characters in the cucumber feature file.
For e.g When I click the "»" button
After searching for the problem I figured out the solution:



  • ".Feature" file should be saved in utf8 format.

  • "require 'cucumber/formatter/unicode'" needs to be added in support/env.rb.


Thats it, problem got solved.


Finding # 2


If an element is clicked from a page and that click opens a new window. To perform some actions on the new window.

Got the solution from:
http://qastuffs.blogspot.com/2010/10/testing-pop-up-windows-using-selenium.html


The solution however doesn't work with capybara, atleast for me it didn't worked. I replaced "response" with "page" and then it worked as shown below:


declare these functions in your web_steps.rb:
def switch_to_new_pop_up
page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
end

def close_active_window
page.driver.browser.close
page.driver.browser.switch_to.window(page.driver.browser.window_handles[0])
end