How to read the text from an Alert(ios) in calabash ?

Hi guys,

It’s been a long time that I don’t post anything about calabash and mobile automation, but I found this in my favorites and I realized that could be useful for someone. I am not sure if doesn’t exist another way to read a text inside an Alert, but this is one of the solutions:

Example of step:

Then I see a popup with latitude 10 and longitude 20



Then /^I see a popup with latitude (\d+) and longitude (\d+)$/ do |lat, lon| 
  msg = "Latitude:#{lat}\nLongitude:#{lon}" 
  should_see_alert_with_text msg 


def should_see_alert_with_text (text) 
wait_poll(:until_exists => 'alertView', :timeout => 5) do
  actual = query('alertView child label', :text).first
  unless actual.eql? text 
    screenshot_and_raise "should see alert view with message '#{text}' 
but found '#{actual}'" 


Thank you ! See you 🙂



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.