module Briar::Alerts_and_Sheets
Public Instance Methods
alert_exists?(alert_id=nil)
click to toggle source
of interest touch(“view:'_UIModalItemAlertContentView' descendant view:'_UIModalItemTableViewCell' marked:'OK'”)
# File lib/briar/alerts_and_sheets/alert_view.rb, line 10 def alert_exists? (alert_id=nil) if uia_available? res = uia('uia.alert() != null') res['value'] else if alert_id.nil? !query('alertView').empty? else !query("alertView marked:'#{alert_id}'").empty? end end end
query_str_for_sheet(sheet_id)
click to toggle source
# File lib/briar/alerts_and_sheets/action_sheet.rb, line 5 def query_str_for_sheet(sheet_id) # Ignoring argument because iOS 8 sheets do not retain their accessibilityIdentifier return "view:'_UIAlertControllerView'" if ios8? or ios9? if sheet_id "actionSheet marked:'#{sheet_id}'" else 'actionSheet' end end
sheet_exists?(sheet_id)
click to toggle source
# File lib/briar/alerts_and_sheets/action_sheet.rb, line 15 def sheet_exists?(sheet_id) !query(query_str_for_sheet sheet_id).empty? end
should_not_see_alert(alert_id=nil)
click to toggle source
# File lib/briar/alerts_and_sheets/alert_view.rb, line 33 def should_not_see_alert (alert_id=nil) if alert_exists? alert_id if alert_id.nil? screenshot_and_raise 'should not see alert view' else screenshot_and_raise "should not see alert view marked '#{alert_id}'" end end end
should_not_see_sheet(sheet_id)
click to toggle source
# File lib/briar/alerts_and_sheets/action_sheet.rb, line 33 def should_not_see_sheet(sheet_id) if sheet_exists?(sheet_id) screenshot_and_raise "should not see sheet marked '#{sheet_id}'" end end
should_see_alert(alert_id=nil)
click to toggle source
# File lib/briar/alerts_and_sheets/alert_view.rb, line 23 def should_see_alert (alert_id=nil) unless alert_exists? alert_id if alert_id.nil? screenshot_and_raise 'should see alert view' else screenshot_and_raise "should see alert view marked '#{alert_id}'" end end end
should_see_alert_with_message(message, timeout=BRIAR_WAIT_TIMEOUT)
click to toggle source
# File lib/briar/alerts_and_sheets/alert_view.rb, line 67 def should_see_alert_with_message (message, timeout=BRIAR_WAIT_TIMEOUT) should_see_alert if uia_available? msg = "expected to see alert with title '#{message}'" wait_for(:timeout => timeout, :retry_frequency => BRIAR_WAIT_RETRY_FREQ, :post_timeout => BRIAR_WAIT_STEP_PAUSE, :timeout_message => msg) do if ios8? || ios9? not query("view:'_UIAlertControllerView' marked:'#{message}'").empty? else not uia_query(:view, {:marked => "#{message}"}).empty? end end else qstr = 'alertView child label' msg = "waited for '#{timeout}' for alert with message '#{message}'" wait_for(:timeout => timeout, :retry_frequency => BRIAR_WAIT_RETRY_FREQ, :post_timeout => BRIAR_WAIT_STEP_PAUSE, :timeout_message => msg) do query(qstr, :text).include?(message) end end end
should_see_alert_with_title(title, timeout=BRIAR_WAIT_TIMEOUT)
click to toggle source
# File lib/briar/alerts_and_sheets/alert_view.rb, line 43 def should_see_alert_with_title (title, timeout=BRIAR_WAIT_TIMEOUT) should_see_alert if uia_available? msg = "expected to see alert with title '#{message}'" wait_for(:timeout => timeout, :retry_frequency => BRIAR_WAIT_RETRY_FREQ, :post_timeout => BRIAR_WAIT_STEP_PAUSE, :timeout_message => msg) do if ios8? || ios9? not query("view:'_UIAlertControllerView' marked:'#{message}'").empty? else not uia_query(:view, {:marked => "#{message}"}).empty? end end else qstr = 'alertView child label' msg = "waited for '#{timeout}' for alert with title '#{title}'" opts = wait_opts(msg, timeout) wait_for(opts) do query(qstr, :text).include?(title) end end end
should_see_sheet(sheet_id, button_titles=nil, sheet_title=nil)
click to toggle source
# File lib/briar/alerts_and_sheets/action_sheet.rb, line 19 def should_see_sheet(sheet_id, button_titles=nil, sheet_title=nil) unless sheet_exists?(sheet_id) screenshot_and_raise "should see sheet marked '#{sheet_id}'" end if button_titles button_titles.each { |title| should_see_button_on_sheet title, sheet_id } end if sheet_title should_see_sheet_title sheet_title, sheet_id end end
should_see_sheet_title(label_title, sheet_id=nil)
click to toggle source
# File lib/briar/alerts_and_sheets/action_sheet.rb, line 91 def should_see_sheet_title(label_title, sheet_id=nil) sheet_query = query_str_for_sheet sheet_id res = query("#{sheet_query} child label", :text).include?(label_title) unless res "should see sheet #{sheet_id ? "'#{sheet_id}'" : ''} with title '#{label_title}'" end end
wait_for_sheet(sheet_id, timeout=BRIAR_WAIT_TIMEOUT)
click to toggle source
# File lib/briar/alerts_and_sheets/action_sheet.rb, line 39 def wait_for_sheet (sheet_id, timeout=BRIAR_WAIT_TIMEOUT) if sheet_id msg = "waited for '#{timeout}' seconds but did not see '#{sheet_id}'" else msg = "waited for '#{timeout}' seconds but did not see UIActionSheet" end wait_for(:timeout => timeout, :retry_frequency => BRIAR_WAIT_RETRY_FREQ, :post_timeout => BRIAR_WAIT_STEP_PAUSE, :timeout_message => msg) do sheet_exists? sheet_id end end
wait_for_sheet_to_disappear(sheet_id, timeout=BRIAR_WAIT_TIMEOUT)
click to toggle source
# File lib/briar/alerts_and_sheets/action_sheet.rb, line 53 def wait_for_sheet_to_disappear(sheet_id, timeout=BRIAR_WAIT_TIMEOUT) msg = "waited for '#{timeout}' seconds for '#{sheet_id}' to disappear but it is still visible" options = {:timeout => timeout, :retry_frequency => BRIAR_WAIT_RETRY_FREQ, :post_timeout => BRIAR_WAIT_STEP_PAUSE, :timeout_message => msg} wait_for(options) do not sheet_exists? sheet_id end end