今のところ、私はこのソリューションを使用しています。誰かが同じ問題に直面している場合は、適切な解決策が得られるまでこれを使用できます。
Then /^I should see empty email alert$/ do
is_alert_exist_with_text("Email cannot be empty.")
sleep(0.5)
touch_alert_button("OK")
end
######## 関数を定義する
def touch_alert_button(button)
btn = query("view:'_UIModalItemTableViewCell' label marked:'#{button}'").first.empty?
if (btn)
screenshot_and_raise "button not found '#{button}'"
else
touch("view:'_UIModalItemTableViewCell' label marked:'#{button}'").first
sleep(0.2)
end
end
def is_alert_exist_with_text(text)
unless query("view:'_UIModalItemRepresentationView' label marked:'#{text}'",).empty?
return true
else
screenshot_and_raise "could not find the text '#{text}' in alert view"
end
end
さらに...
def is_alert_exist_with_title_and_message(title, message)
elements = query("view:'_UIModalItemRepresentationView' label", 'text')
buttons = query("view:'_UIModalItemTableViewCell' label", 'text')
textLabels = elements - buttons
if (textLabels.count == 2)
screenshot_and_raise "Alert Title '#{title}' not found" unless (textLabels[0].eql? title)
screenshot_and_raise "Alert Message '#{message}' not found" unless (textLabels[1].eql? message)
else
screenshot_and_raise "Argument error...isAlertExistWithTitleAndMessage function"
end
end