Any tips regarding steps for deleting a UITableViewCell?

311 views
Skip to first unread message

Adam McDonald

unread,
Mar 23, 2011, 4:11:48 PM3/23/11
to frank-...@googlegroups.com
I'm having a tough time simple deleting an existing UITableViewCell following the standard iOS routine:

1. Tap 'Edit' button
2. Tap red circle minus button inside of the cell you want to delete
3. Tap red 'Delete' button for confirmation

I am able to work my way through the first two steps, but the third is causing me a lot of headache. I will outline what I have so far:

Step 1

When I touch the navigation button marked "Edit"

When /^I touch the navigation button marked "([^\"]*)"$/ do |mark|
  touch( "navigationButton marked:'#{mark}'" )
end

Step 2

And I touch the tableview cell edit control marked "Delete GitHub: raid5"

When /^I touch the tableview cell edit control marked "([^\"]*)"$/ do |mark|
  steps %Q{
    When I touch "#{mark}"
  }
end

Note: An odd issue I found with this step is that the first cell will be marked with "Delete " + the cell label text, therefore "Delete GitHub: raid5". But, all other cells are marked with just "Delete".

Step 3

And I touch the tableview cell delete confirmation marked "Confirm Deletion for GitHub: raid5"

When /^I touch the tableview cell delete confirmation marked "([^\"]*)"$/ do |mark|
  steps %Q{
    When I touch "#{mark}"
  }
end

This view seems to be the view underneath the "Delete" button and I don't see any other valid accessibility labels to actually click the  button. So, this is where I am currently stuck at and I was curious if anyone had any insight into this problem or examples of how they did it.

Thanks!

- Adam

James Moore

unread,
Mar 28, 2011, 9:16:16 PM3/28/11
to frank-...@googlegroups.com, Adam McDonald
Hi Adam, there’s a convenience method in UISpec for doing exactly this. The only problem is that I can’t seem to get it to work. According to the email from the UISpec mailing list you would use it like this:


[app.tableViewCell delete];
or if you know the text in the cell you can do:

[[[app.tableView.label text:@"Some Text in a Cell"] parent].tableViewCell
delete];

In Symbiote I can successfully flash the following selectors

tableViewCell label text:’my text’

tableView label text:’my text' parent tableViewCell

but sending the delete command to either of those selectors returns null.

I too am stumped.

James

Adam McDonald

unread,
Mar 29, 2011, 8:04:16 PM3/29/11
to frank-...@googlegroups.com, Adam McDonald
Dang :/ thanks for looking into it a bit.

Trying to accomplish simple tasks like this should not be this hard :/

Pete Hodgson

unread,
Mar 30, 2011, 12:35:30 AM3/30/11
to frank-...@googlegroups.com
Ah, I think I might know what this is about. Sometimes the convenience methods that UISpec adds get masked by Frank, because of a slightly hacky way we leverage UIQuery. I will try and reproduce this on an app locally and see if I can figure out a solution.

Pete Hodgson

unread,
Mar 30, 2011, 1:20:17 AM3/30/11
to frank-...@googlegroups.com
Try this step:

When /^I delete the table view cell marked "([^"]*)"$/ do |mark|
  raise "no table view cell marked '#{mark}' could be found to delete" unless element_exists("tableViewCell label marked:'#{mark}'")
  frankly_map( "tableViewCell label marked:'#{mark}' parent tableViewCell delete", "tag" ) 
end


Here's a brief description what's going on. Frank does some hackery in the Map operation in order to extract an array of views from the UIQuery object that UISpec generates for a given selector. After that hackery has occurred, we no longer have the UISpec convenience functions available to us. I get around this in the step above by actually performing the delete *inside* of the UIQuery selector (note that the operation part of the map command is just a pointless call to get the 'tag' property).,This means that the actual delete call is done by UIQuery as part of resolving the selector, before the Map operation even starts to apply the work-around which gives it the raw array of views. Essentially I've made the delete operation a side effect of applying the selector.

Phew. In general there isn't much call for the UISpec convenience methods, and I'd argue that if UISpec used categories to add these convenience methods to the standard UIKit classes themselves then life would be easier all around. I do think that the map operation is a fundamentally useful construct for creating custom Frank steps, and I don't want to get rid of it. I would love to solve this in a clean way, but annoyingly it looks like the easiest solution would be to modify our bundled copy of UISpec to use categories rather than custom classes for its convenience methods. Maybe I will ping Brian and see what his thoughts are.

James, Adam, please let me know if my step definition above still doesn't solve your issue!

Cheers,
Pete

Derek Longmuir

unread,
Mar 30, 2011, 11:53:48 AM3/30/11
to frank-...@googlegroups.com
Did anyone get around to adding an "Edit" button to the example app
with a delete?

Thanks, Derek.

Adam McDonald

unread,
Mar 30, 2011, 12:19:28 PM3/30/11
to frank-...@googlegroups.com
Hey Pete, I understand what you are trying to achieve with this step but it doesn't seem to be working correctly in its current version. I'm coming across the good ol' "EOFError"

And I delete the table view cell marked "GitHub: raid5"                   # Tests/Acceptance/features/step_definitions/tableview_steps.rb:54
  end of file reached (EOFError)
  /Users/adam/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:135:in `read_nonblock'
  /Users/adam/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:135:in `rbuf_fill'
  /Users/adam/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:116:in `readuntil'
  /Users/adam/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:126:in `readline'
  /Users/adam/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:2219:in `read_status_line'
  /Users/adam/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:2208:in `read_new'
  /Users/adam/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1191:in `transport_request'
  /Users/adam/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1177:in `request'
  /Users/adam/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:627:in `start'
  ./Tests/Acceptance/features/step_definitions/tableview_steps.rb:56:in `/^I delete the table view cell marked "([^"]*)"$/'
  Tests/Acceptance/features/delete_account.feature:19:in `And I delete the table view cell marked "GitHub: raid5"'

I tried this step directly after setting up the table (creating two rows), in addition to adding the two steps before it to actually show the 'Delete' button in the cell. I wasn't sure which was the correct approach, but neither seemed to work.

Anyone else have any luck with this approach yet?

Pete Hodgson

unread,
Mar 30, 2011, 12:23:40 PM3/30/11
to frank-...@googlegroups.com, Adam McDonald
I wouldn't be surprised if this was because of the colon in "GitHub: raid5". To confirm that, you could try using just "GitHub" or just "raid5". If that is indeed the problem we'll have to look into how to get around it...

Adam McDonald

unread,
Mar 30, 2011, 12:39:13 PM3/30/11
to frank-...@googlegroups.com, Adam McDonald
No go trying to match either of those. I also changed my ObjC code to remove the colon "GitHub raid5" and try matching that, but still getting the same EOFError :/

James Moore

unread,
Mar 30, 2011, 12:43:16 PM3/30/11
to frank-...@googlegroups.com
Works for me. 

Note: you won’t see the normal set of animations when this runs. The cell simply disappears. Judging by what I see happening in the app the same code path is being followed as if I had pressed Delete and then Confirm Delete.

James

Adam McDonald

unread,
Mar 30, 2011, 12:51:18 PM3/30/11
to frank-...@googlegroups.com
Dang :/ I have no clue why I'm getting this error then. Trying to debug it but not having much luck yet.

James Moore

unread,
Mar 30, 2011, 1:05:35 PM3/30/11
to frank-...@googlegroups.com
Followup:

I’m getting the EOF error when I use that step after several other steps that setup the table and open the menu that contains the table. If I do everything manually and then run the delete as a single step in cucumber it works.

Puzzling...

James

James Moore

unread,
Mar 30, 2011, 1:06:44 PM3/30/11
to frank-...@googlegroups.com
I forgot to mention that the cell is deleted even if I receive that error.

James

Adam McDonald

unread,
Mar 30, 2011, 1:09:55 PM3/30/11
to frank-...@googlegroups.com
James, you can see the cell being deleted visually? Or when you relaunch the app, your cell is now gone? I'm using in-memory Core Data storage for my tests, so my cell data doesn't persist across app restarts.

James Moore

unread,
Mar 30, 2011, 2:50:05 PM3/30/11
to frank-...@googlegroups.com
The app exits immediately.

Here’s some more followup:

The table I’m working with has a list of items that can be selected. Selecting an item changes some data elsewhere and dismisses the popup that contains the table. When I reopen the popup the last item that was selected is highlighted. If I try to delete the highlighted item I get the EOF error.

Symbiote says that the highlighted view is a UINavigationItemView and the non-highlighted one is simply a UILabel.

It seems we’ve hit another wall.

James

Adam McDonald

unread,
Mar 31, 2011, 3:39:10 PM3/31/11
to frank-...@googlegroups.com
Yea, all I'm doing is creating two cells via the cucumber scenario and then immediately attempt to delete one of the cells once the data is all setup. Seems odd that it would work sometimes in your case, but not always (depending on the situation/setup).

Pete Hodgson

unread,
Apr 1, 2011, 10:47:54 AM4/1/11
to frank-...@googlegroups.com, James Moore
That EOF error means that the app crashed while trying to follow a Frank command. Obviously that's not ideal; it's due to a bug in the 4.x SDK when running in the simulator.

 It could well be that the helper method that UISpec gives us doesn't lead to the same path through your app's code as the manual user interaction with the app would, leading to a crash. If you can send the app's logs from the crash it might reveal a cause.

Adam McDonald

unread,
May 9, 2011, 10:42:33 PM5/9/11
to frank-...@googlegroups.com, James Moore
Sorry about the long delay to this thread, I've been out of town on vacation. I've attached the crash log associated with trying to use that UISpec delete method.
SocialJournal_2011-05-09-193729_raidfive.crash

Javid

unread,
May 16, 2011, 11:25:39 AM5/16/11
to Frank
Hello Adam,
I am seeing the exact behavior when I try to delete a newly added
cell. And I am using Core Data too.
Were you able to resolve the issue.

Also, on a side note can you share with me your thoughts on how you
use in-memory core data storage so the changes you make during testing
don't persist?

Thanks.
Javid
>  SocialJournal_2011-05-09-193729_raidfive.crash
> 22KViewDownload

Adam McDonald

unread,
May 16, 2011, 3:38:48 PM5/16/11
to frank-...@googlegroups.com
Hey Javid, no I haven't come across a good solution for this yet. I set this project aside for now while I'm busy working on a few client projects.

As for the in-memory store usage, hit me up via email and I can send you some sample code if you want. mcdona...@gmail.com

Pete Hodgson

unread,
May 17, 2011, 1:55:24 AM5/17/11
to frank-...@googlegroups.com
I think I have a fix for the crash that you guys were seeing when deleting a cell row using that UISpec helper method. Turns out there was a slight bug in that method. I've fixed that on our UISpec branch on github. I will update the Frank repo when I get a sec to use the updated UISpec code. 

If you're absolutely chomping at the bit to see if my fix works, you can just patch locally - it's only a couple of lines that needed changing: https://github.com/moredip/UISpec/commit/c0f5d721c996301fca3c8ea2b60999e41bddc4a8

Cheers,
Pete

James Moore

unread,
May 17, 2011, 12:51:43 PM5/17/11
to frank-...@googlegroups.com
Your fix is working for me. No more crash!

--
James

Adam McDonald

unread,
May 20, 2011, 5:36:26 PM5/20/11
to frank-...@googlegroups.com
Excellent! I can't wait to try it. It is good news to hear the fix working for others. I'm going to wait for the update to the Frank repo since I'm not actively developing that app at the moment. Any idea when this fix will be rolled in?

Pete Hodgson

unread,
May 20, 2011, 8:46:31 PM5/20/11
to frank-...@googlegroups.com
Update is in the Frank repo now, if memory serves.
Reply all
Reply to author
Forward
0 new messages