2013-04-26 63 views
0

我已經嘗試了一些不同的東西,包括這樣的:如何使用Frank觸摸UIAlertView的'OK'或'Cancel'按鈕?

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 

什麼是去這樣做的好辦法?

回答

2

你的代碼看起來不錯,它不工作?

您也可以嘗試使用預定義弗蘭克步驟,只是做:

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 
+0

這種查找視圖的方法似乎不再適用於iOS10上的「UIAlertController」上顯示的標籤 – gardenofwine 2017-04-17 07:19:27