Created
August 8, 2012 19:17
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Author
Author
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
The macro in line 7 makes use of this custom step definition: https://gist.github.com/3298026