Post

1 Star2 Stars3 Stars4 Stars5 Stars
Loading ... Loading ...

By Rafaela Azevedo
Hi guys ! I hope you are well ! Here there are many commands of calabash-ios that are very useful :)
Assertions

fail(msg=”Error. Check log for details.”)
check_element_exists(query)check_element_does_not_exist(query)check_view_with_mark_exists(expected_mark)
check_element_exists(“view marked:’#{expected_mark}'”)

Touch

touch(uiquery, options={})

irb(main):037:0> touch(“view marked:’switch'”)
irb(main):038:0> tap ‘switch’
irb(main):040:0> touch(“view marked:’First'”, :offset => {:x => 50, :y => 0})
irb(main):041:0> touch(nil, :offset => {:x => 50, :y => 0})

Keyboard

keyboard_enter_char(chr)
irb(main):043:0> keyboard_enter_char “a”
irb(main):076:0> keyboard_enter_char “More”
keyboard_enter_text(text)
irb(main):044:0> keyboard_enter_text “The Quick Brown Fox”
done
Scroll

scroll(uiquery, direction)
irb(main):082:0> scroll “scrollView”, :down

Tables

scroll_to_row(uiquery, number)
irb(main):081:0> scroll_to_row “tableView”, 2
scroll_to_cell(options)
{:query => “tableView”,
:row => 0,
:section => 0,
:scroll_position => :top,
:animate => true}
irb(main):003:0> scroll_to_cell(:row => 13, :section => 0)
=> [“; contentOffset: {0, 0}>. Delegate: LPThirdViewController, DataSource: LPThirdViewController”]
:row the row to scroll to
:section the section to scroll to
:scroll_position the position to scroll to :top, :bottom, :middle
:animate animate the scrolling or noteach_cell(options, &block)
{:query => “tableView”, #the table view to act on
:post_scroll => 0.3, #a pause after each action taken
:skip_if => nil, #an optional proc to skip some cells
:animate => true #animate the scrolling?
}
irb(main):008:0> each_cell(:post_scroll=>0) do |row, sec|
irb(main):009:1* puts “Row #{row} in Section #{sec}”
irb(main):010:1> end
Row 0 in Section 0
Row 1 in Section 0
Row 2 in Section 0
Row 3 in Section 0

irb(main):001:0> table_labels = []
=> []

irb(main):002:0> each_cell(:animate => false, :post_scroll => 0.1) do |row, sec|
irb(main):003:1* txt = query(“tableViewCell indexPath:#{row},#{sec} label”, :text).first
irb(main):004:1> table_labels end
=> 1

irb(main):006:0> table_labels
=> [“Cell 0”, “Cell 1”, “Cell 2”, “Cell 3”, “Cell 4”, “Cell 5”, “Cell 6”, “Cell 7”, “Cell 8”, “Cell 9”, “Cell 10”, “Cell 11”, “Cell 12”, “Cell 13”, “Cell 14”, “Cell 15”, “Cell 16”, “Cell 17”, “Cell 18”, “Cell 19”, “Cell 20”, “Cell 21”, “Cell 22”, “Cell 23”, “Cell 24”, “Cell 25”, “Cell 26”, “Cell 27”, “Cell 28”, “Cell 29”]

Rotation
rotate(dir)
irb(main):083:0> rotate :left

(Event) Playback
playback(recording, options={})
irb(main):103:0> playback “drag_switch_around”, :query => “view marked:’switch'”, :offset => {:x=>2, :y=>0}
record_begin and record_end
irb(main):104:0> record_begin
=> “”
irb(main):105:0> record_end “move_down”
=> “move_down_ios5_iphone.base64”

Location
set_location(options)
:place => “Tower of London”
:latitude => …, :longitude => …

Backdoor
backdoor(sel, arg)
– (NSString *) calabashBackdoor:(NSString *)aIgnorable;
irb(main):002:0> backdoor(“calabashBackdoor:”, “”)
=> “YES”

Screenshot
screenshot(options={:prefix=>nil, :name=>nil})
screenshot({:prefix => “/Users/krukow/tmp”, :name=>”my.png”})
screenshot_embed(options={:prefix=>nil, :name=>nil, :label => nil})
screenshot_embed({:prefix => “/Users/krukow/tmp”, :name=>”my.png”, :label => “Mine”})

Misc

server_version
irb(main):026:0> server_version
=> {“outcome”=>”SUCCESS”, “app_name”=>”LPSimpleExample-cal”, “simulator_device”=>”iPhone”, “iOS_version”=>”5.1”, “app_version”=>”1.0”, “system”=>”x86_64”, “app_id”=>”com.lesspainful.example.LPSimpleExample-cal”, “version”=>”0.9.126”, “simulator”=>”iPhone Simulator 358.4, iPhone OS 5.1 (iPhone/9B176)”}

client_version
irb(main):027:0> client_version
=> “0.9.127.pre1”

calabash_exit
irb(main):028:0> calabash_exit
=> []
irb(main):029:0> server_version
Errno::ECONNREFUSED: Connection refused – connect(2) (http://localhost:37265)

escape_quotes(str)
irb(main):007:0> quoted = escape_quotes(“Karl’s child”)
=> “Karl\’s child”
irb(main):008:0> query(“view marked:’#{quoted}'”)

macro(txt)
macro ‘I touch “Second”‘

lbl = “…….a long text……”
macro %Q[I use a step with “double” quotes and ‘single’ and #{lbl}]

flash(uiquery)
flash(“TableView index:2”)

Font: https://github.com/calabash/calabash-ios/wiki/03.5-Calabash-iOS-Ruby-API

Source: http://azevedorafaela.wordpress.com/2014/08/03/summary-of-calabash-ios-ruby-api-assertions/

Category: Programming, QA, Test and Automation Stuffs, api ruby calabash-ios, assertions calabash ios, assertions calabash ios examples, assertions calabash ios samples, assertions classes calabash ios, assertions cucumber examples, assertions cucumber samples, assertions element_exists calabash-ios, assertions element_exists cucumber, assertions label calabash ios, assertions samples, assertions tag names calabash-ios, assertions tag-name cucumber, assertions tagname calabash ios, assertions wait – calabash ios, assertions wait – cucumber, calabas-ios, calabash-ios ruby, calabash-ios ruby query, cucumber, element_does_not_exist calabash ios, element_does_not_exist cucumber, examples of assertions calabash-ios, uiassertions calabash-ios, uiassertions cucumber, using assertions calabash, using assertions calabash ios, view_with_mark_exists calabash-ios, view_with_mark_exists cucumber

Você também pode querer ler

Comments are off for this post.