Skip to content

Instantly share code, notes, and snippets.

@monfresh
Created August 8, 2012 19:17
Show Gist options
  • Select an option

  • Save monfresh/3297785 to your computer and use it in GitHub Desktop.

Select an option

Save monfresh/3297785 to your computer and use it in GitHub Desktop.
Custom Calabash iOS step definition to swipe to delete all cells in a Table View
Then /^I swipe to delete all cells in "([^\"]*)"$/ do |orientation|
total_rows = query("tableView index:0",numberOfRowsInSection:0) #this returns an array
end_of_range = total_rows[0] - 1
(0..end_of_range).each do
scroll_to_row "tableView index:0", 0
sleep(STEP_PAUSE)
macro %Q[I swipe on cell number 1 in "#{orientation}"] #requires this custom step definition: https://gist.github.com/3298026
sleep(STEP_PAUSE)
touch "TableViewCellDeleteConfirmationControl"
end
final_count = query("tableView index:0",numberOfRowsInSection:0)
if final_count[0] == total_rows[0]
screenshot_and_raise "None of the cells were deleted!"
elsif final_count[0] != 0
screenshot_and_raise "Some of the cells were not deleted!"
end
end
@monfresh
Copy link
Copy Markdown
Author

monfresh commented Aug 8, 2012

The macro in line 7 makes use of this custom step definition: https://gist.github.com/3298026

@monfresh
Copy link
Copy Markdown
Author

monfresh commented Aug 9, 2012

This step assumes that after you have deleted all cells, the total number of rows/cells equals zero. If your app always leaves one UITableViewCell visible with some hint text for example, then you should use this step definition: https://gist.github.com/3308163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment