ui-automationcalabashcalabash-android

Not able to create Calabash step definition for scenario


I'm new to Calabash and trying to create Steps definition for below the feature file with respective scenarios (QA looks like a possible duplicate but no answer found in SOF) How to generate the step definition using UIAutomator viewer tool. error screenshot attached for refenter image description here Any help on this issue would be appreciated.

Feature: Valid Login 

Scenario: Login with valid mobile number
    When I see "Login/Signup" screen
    And  I enter "72046606**" in "etMobilNumber" text field 
    And  I click on "Login/Signup" button
    And  I enter "WebDriver12" in "etPassword" text field
    And  I click on "Login" button
    And  I wait
    Then I see "Enter mPIN" screen 


Scenario: Login with valid mPIN
    When I see "Enter mPIN" screen
    And  I click on "2" button
    And  I click on "3" button
    And  I click on "6" button
    And  I click on "9" button
    And  I wait
    Then I see "J****" text 


Scenario: Launch Money Transfer screen
    When I see "J*****" screen
    And  I click on "MoneyTransfer" button
    And  I click on "Send Money" text
    And  I wait
    Then I see "Send Money" text

Solution

  • Feature file:

     Feature: Login
    
     Scenario: I should login via valid credentials
        When I enter mobile number "7204660611" into mobile number input field with "ID" 
        Then I see "Login/Signup" button as enable
        And I tap "Login/Signup" button
        Then I wait 60 seconds
        Then I see "Password" field
        And I enter Password "WebDriver12" input Password input field with "ID"
        Then I tap "Login" button
        Then I should get new page
    

    Step Definition:

    require 'calabash-android/calabash_steps'
    
    When(/^I enter mobile number "([^"]*)" into mobile number input field with "([^"]*)"$/) do |mobileNumber, etMobileNumber|
     enter_text("* marked:'etMobileNumber'","***34*****")
    end
    
    Then(/^I see "([^"]*)" button as enable$/) do |arg1|
     if query("* marked:'btnSignin'",:enabled).first.eql?true
      else
        raise "FAILED!!! Invalid Mobile number"
     end
    end
    
    Then(/^I tap "([^"]*)" button$/) do |arg1|
      touch("* marked:'btnSignin'")
    end
    
    Then(/^I wait (\d+) seconds$/) do |arg1|
      wait_for_element_exists("* marked:'etPassword'")
    end
    
    Then(/^I see "([^"]*)" field$/) do |arg1|
      if query("* marked:'etPassword'",:enabled).first.eql?true
      else
       fail "Failed!! Password field not present"
      end
     end
    
     Then(/^I enter Password "([^"]*)" input Password input field with "([^"]*)"$/) do |arg1, arg2|
      enter_text("* marked:'etPassword'","WebD*****")
     end
    
    Then(/^I should get new page$/) do
       wait_for_element_exists("* marked:'Enter mPIN'")
    end