Google+ Followers

Sunday, 9 February 2014

calabash cross platform extended: calabash ios & Android

I have extended my test suite to follow page / screen object model.

have a look at visual representation of the page object pattern and how does it map on to different files in the test suite.

Classes

1) Ibase (ios) and Abase( Android) are base classes for IOS / Android
2) Base page extends base classes further  and implements some functionality that can be used by all classes extending it.
3) Welcome page extends base class and implements methods which are specific to welcome page

BDD
(in a typical scenario)
  1. Each step in a feature file will have implementation in step definitions folder
  2. Each step definitions will create a corresponding object of a page (ex: Welcomepage.new)
  3. Each page object will call some calabash method to verify elements (ex: query ) or do actions on app (ex: touch)  which is implement  with in page.

Sample Source code:

1) Feature file -
Scenario: Navigate to login page
    Given I am on login page
    Then I verify login page

2)  Step definition-
Given(/^I am on login page$/) do
  WelcomePage.new(self).wait_for_welcome_screen
  WelcomePage.new(self).navigate_to_login
  LoginPage.new(self).await
end


3) method implementation.
def wait_for_welcome_screen
    wait_for_elements_exist([trait])
end

4)Sample class

class WelcomePage < BasePage

  def trait
    "* marked:'Start blogging in seconds.'"
  end

  def wait_for_welcome_screen
    wait_for_elements_exist([trait])
  end

  end

5) Base page
class BasePage < Calabash::ABase
 # Template for adding commond android methods
end

1 comment:

  1. Hi

    This is really good. can you please comment on the .await
    I am not aware of what it does and why and when would one use .await.

    ReplyDelete