我尝试了一些不同的东西,包括:
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
这样做的好方法是什么?
答案 0 :(得分: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