2

I am following a View Based Class model to setup a Calabash testing framework for my app , i.e., each view has a class containing the requisite methods for that view.

But when I call calabash functions such as "wait_for()" it throws me an error:

undefined method `wait_for' for LoggedInPage:Class (NoMethodError)

I have already added these in my env.rb

 require 'calabash-cucumber/wait_helpers'
 require 'calabash-cucumber/operations'
 World(Calabash::Cucumber::Operations)
 World(Calabash::Cucumber::WaitHelpers)
ArK
  • 20,698
  • 67
  • 109
  • 136

1 Answers1

1

The issue probably that the page object classes aren't being initialised in the same 'world' as cucumber is running in. Adding the files to env adds them and their methods to the world that cucumber is running. You have to pass that world into your page objects when they are created to give them access to those functions.

Have your page object classes inherit from calabashes page object bases - http://www.rubydoc.info/gems/calabash-cucumber/Calabash/IBase and when you create a new instance of a page object pass in self.

class MyPage < Calabash::IBase
...

new_instance_of_page_object = MyPage.new(self)

In this specific case, inheriting from IBase will give you access to the functions you are talking about, but passing in self will mean you have access to any other things that you have added in your env file.

alannichols
  • 1,496
  • 1
  • 10
  • 20
  • 1
    alannichols is correct, except that the convention is to use `page(MyPage)` to create new instances of subclasses of `Calabash::IBase`. Here is a link to an example project: https://github.com/calabash/ios-webview-test-app – jmoody Apr 07 '15 at 11:44