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

 

So,

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 
end

Finally:

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}'" 
  end 
 end 
end

 

Thank you ! See you 🙂

 

Source: http://stackoverflow.com/questions/16351791/how-do-i-read-text-from-an-alertios-in-calabash

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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.