How do I touch on an icon in navigation bar

390 views
Skip to first unread message

Nabanita

unread,
Aug 31, 2012, 5:44:40 AM8/31/12
to calaba...@googlegroups.com
Hi jjm,

I our application there is an settings icon at the right corner of navigation bar, I want to touch it to navigate to settings screen. 
There is only icon the button has no name. So how do I touch on that icon?

Following is my predefined step:
Then I touch on the settings icon

Thanks,
Nabanita

Joshua Moody

unread,
Aug 31, 2012, 12:19:53 PM8/31/12
to calaba...@googlegroups.com
the way i do it is to set the accessibilityLabel of the button:

ex.

 UIImage *sumIm = [UIImage imageNamed:@"259-list.png"];
 UIBarButtonItem *summaryBtn = [[UIBarButtonItem alloc]
                                 initWithImage:sumIm
                                 style:UIBarButtonItemStyleBordered
                                 target:self
                                 action:@selector(buttonTouchedSummary:)];
 summaryBtn.accessibilityLabel = @"checkin summary";
 [self.navigationItem setRightBarButtonItem:summaryBtn animated:YES];

then i use the following navigation bar steps (that i wrote):

# will not work to detect left/right buttons
def index_of_navbar_button (name)
  titles = query("navigationButton", :accessibilityLabel)
  titles.index(name)
end

def should_see_navbar_button (name)
  idx = index_of_navbar_button name
  if idx.nil?
    screenshot_and_raise "there should be a navbar button named #{name}"
  end
end

def should_not_see_navbar_button (name)
  idx = index_of_navbar_button name
  unless idx.nil?
    screenshot_and_raise "i should not see a navbar button named #{name}"
  end
end

Then /^I should (not see|see) (?:the|an?) "([^"]*)" button in the navbar$/ do |visibility, name|
  if visibility.eql? "see"
    should_see_navbar_button name
  else
    should_not_see_navbar_button name
  end
end

ex.  

Then I should not see the "summary" button in the navbar
Then I should see a "export" button in the navbar

i hope this helps.

jjm


Reply all
Reply to author
Forward
0 new messages