Search code examples
androidcucumbercalabash

calabash-android undefined method for second step


I'm new to calabash, and I am trying to run a test, and calabash recognizes my first step and it passes, but for the second one i get an undefined method error,

my feature file is:

Feature: Sign-in page
Scenario: Go to dashboard with skip login
Given I am on the Login Screen
When I touch the “Skip Login” button
Then I should see the Main Screen

and my rb file is

Given(/^I am on the Login Screen$/) do
  element_exists("button marked:'authenticate'")
  end

When(/^I touch the "Skip Login" button$/) do
  tap_mark 'skip_login'
end

Then(/^I should see the Main Screen$/) do
  wait_for_elements_exist("label text: 'HeaderText'")
end

When it reaches the "When" step, the app closes on my phone. Can someone please help me with this?

The output is:

Given I am on the Login Screen          # features/step_definitions/calabash

_steps.rb:1 When I touch the "Skip Login" button # features\my_first.feature:4 Then I should see the Main Screen # features/step_definitions/calabash _steps.rb:9

1 scenario (1 undefined) 3 steps (1 skipped, 1 undefined, 1 passed) 0m22.691s

You can implement step definitions for undefined steps with these snippets:

When(/^I touch the "Skip Login" button$/) do pending # express the regexp above with the code you wish you had end

One more detail, if I take the second step and move it instead of the first, it will press the button.I can't understand why this is happening, and why it will not do the second step


Solution

  • It looks like a "smart quotes" problem to me:

    When I touch the “Skip Login” button

    Those are not regular double quotes ".

    Since you are not using a regex in the step definition, I recommend this:

    Given I am on the Login Screen
    When I touch the Skip Login button
    Then I should see the Main Screen
    
    When(/^I touch the Skip Login button$/) do
      tap_mark 'skip_login'
    end