Created
August 9, 2012 21:20
-
-
Save monfresh/3308163 to your computer and use it in GitHub Desktop.
Calabash iOS step that verifies that all cells have been deleted after swiping
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
| def check_cell(prefix) | |
| if @final_count[0] == 1 | |
| final_cell = query "TableViewCell index:0" | |
| if final_cell.first["class"] == "UITableViewCell" | |
| sleep(STEP_PAUSE) | |
| else | |
| screenshot_and_raise "#{prefix} of the cells were deleted!" | |
| end | |
| else | |
| screenshot_and_raise "#{prefix} of the cells were deleted!" | |
| end | |
| end | |
| Then /^I swipe to delete all cells in "([^\"]*)"$/ do |orientation| | |
| total_rows = query("tableView index:0",numberOfRowsInSection:0) | |
| 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}"] | |
| sleep(STEP_PAUSE) | |
| touch "TableViewCellDeleteConfirmationControl" | |
| end | |
| @final_count = query("tableView index:0",numberOfRowsInSection:0) | |
| if @final_count[0] == total_rows[0] | |
| check_cell("None") | |
| else | |
| check_cell("Only some") | |
| end | |
| end |
Author
Author
You can read more info about this step definition on my blog: http://www.moncefbelyamani.com/a-calabash-custom-step-to-swipe-to-delete-all-cells-in-a-table-view/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The macro in line 20 is defined here: http://gist.github.com/3298026