无法为方案创建Calabash步骤定义

时间:2017-04-17 06:14:54

标签: ui-automation calabash calabash-android

我是Calabash的新手,并试图在功能文件下面创建步骤定义以及相应的场景(QA看起来像可能重复但在SOF中找不到答案)如何使用UIAutomator查看器工具生成步骤定义。为enter image description here添加了错误屏幕截图,我们将非常感谢您对此问题的任何帮助。

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

1 个答案:

答案 0 :(得分:0)

功能文件:

 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

步骤定义:

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