How to write Cucumber tests with frank

876 Views Asked by At

I am new to working with cucumber/frank/ruby and tried to follow the steps here http://blog.thepete.net/blog/2012/06/24/writing-your-first-frank-test/ I am trying to create a step definition. In the tutorial they give you the code to write your step definition. This is their code for the sample step definition is:

Then /^I should be on the Home screen$/ do
  check_element_exists "view view:'UIImageView' marked:'Icon512x512.png'"
end
When /^I navigate to "(.*?)"$/ do |tab_name|
  touch "view:'UITabBarButton' marked:'#{tab_name}'"
end
Then /^I should be on the Events screen$/ do
  check_element_exists "view:'UIScrollView' view:'UIButton' marked:'archery'"
  check_element_exists "view:'UIScrollView' view:'UIButton' marked:'badminton'"
  check_element_exists "view:'UIScrollView' view:'UIButton' marked:'boxing'"
end

I tried writing just the first part to apply to my application and wrote it like this:

Then /^I should be on the Map screen$/ do
  check_element_exists "view view:'UIButtonLabel' marked:'Photo View'"
end

It gives me the error Then I should be on the Map screen # features/step_definitions/navigation_steps.rb:1 frankly_map view view: 'UIButtonLabel' marked:'Photo View' accessibilityLabel failed because: invalid selector * -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array (RuntimeError) /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:53:in timeout' ./features/step_definitions/navigation_steps.rb:1:in/^I should be on the Map screen$/' features/navigation.feature:5:in `Then I should be on the Map screen'

1

There are 1 best solutions below

0
On

If I understood it correctly, and that your accessing a default button, you should have it like this:

Then /^I should be on the Map screen$/ do
  check_element_exists "view view:'UIButton' marked:'Photo View'"
end

Try posting a screenshot of your symbiote as well, cheers.