Calabash-android 預定義steps,calabashandroid
Calabash-android目錄下的canned_steps.md中列出了一系列預定義的steps,這些steps的定義位於calabash-android\steps\目錄下。本文將介紹這些steps和用法。
1.斷言steps:定義在assert_steps.rb中
斷言看到了文本:
Then /^I see the text "([^\"]*)"$/Then /^I see "([^\"]*)"$/Then /^I should see "([^\"]*)"$/Then /^I should see text containing "([^\"]*)"$/
例:
Feature: Hello word Scenario: See hello word The I see the text "Hello world"
斷言沒看到文本:
Then /^I should not see "([^\"]*)"$/Then /^I don't see the text "([^\"]*)"$/Then /^I don't see "([^\"]*)"$/
2.輸入steps:定義在
點擊複選框
Then /^I toggle checkbox number (\d+)$/ do |index|
例:
#點擊第一個checkboxThen I togle checkbox number 1
context_menu_steps:
Then /^I long press "([^\"]*)"$/ do |text|例:Then I long press "Stop"長按其屬性text="Stop"的View
3.按鈕
點擊返回按鈕:
Then I go back
點擊Menu
Then I press the menu key
類比使用者在鍵盤上輸入entey
Then I press the enter button
4.手勢
往左滑動
Then I swipe left
往右側滑動
Then I swipe right
上下滑動,用於list控制項
Then I scroll downThen I scroll up
從menu中選擇menu_item
#從menu中選擇quitThen I select "quit" from menu
從一點拖動到另一點
Then /^I drag from (\d+):(\d+) to (\d+):(\d+) moving with (\d+) steps$/ do |from_x, from_y, to_x, to_y, steps|