0

我尝试了一些不同的方法,包括:

 When /^I touch the alertview button marked "(.*?)"$/ do |alert_btn_name|
   touch "view: 'UIAlertButton' marked:'#{alert_btn_name}'"
 end

 When /^I touch the (\d*)(?:st|nd|rd|th)? alert view button$/ do |ordinal|
   ordinal = ordinal.to_i
   touch( "alertView threePartButton tag:#{ordinal}" )
 end

这样做的好方法是什么?

4

1 回答 1

2

您的代码看起来不错,它不起作用吗?

您也可以尝试使用 Frank 预定义的步骤,然后执行以下操作:

When I touch "Cancel"
Then I should not see an alert view

或者,如果您想要“当我触摸 ..”的实际步骤,它将是:

When /^I touch "([^\"]*)"$/ do |mark|
      quote = get_selector_quote(mark)
      selector = "view marked:#{quote}#{mark}#{quote} first"
      if element_exists(selector)
         touch( selector )
      else
         raise "Could not touch [#{mark}], it does not exist."  
      end
      sleep 1
end
于 2013-05-09T08:07:28.017 回答