Skip to content

Instantly share code, notes, and snippets.

@monfresh
Created August 9, 2012 21:20
Show Gist options
  • Select an option

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

Select an option

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
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
@monfresh
Copy link
Copy Markdown
Author

monfresh commented Aug 9, 2012

The macro in line 20 is defined here: http://gist.github.com/3298026

@monfresh
Copy link
Copy Markdown
Author

monfresh commented Aug 9, 2012

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