Module: Briar::Alerts_and_Sheets
- Defined in:
- lib/briar/alerts_and_sheets/alert_view.rb,
lib/briar/alerts_and_sheets/action_sheet.rb
Instance Method Summary collapse
- #alert_button_exists?(button_id) ⇒ Boolean
-
#alert_exists?(alert_id = nil) ⇒ Boolean
of interest touch(“view:‘_UIModalItemAlertContentView’ descendant view:‘_UIModalItemTableViewCell’ marked:‘OK’”).
- #dismiss_alert_with_button(button_label) ⇒ Object
- #error_msg_for_sheet_button(button_title, visible, sheet_id = nil) ⇒ Object
- #query_str_for_sheet(sheet_id) ⇒ Object
- #sheet_button_exists?(button_title, sheet_id = nil) ⇒ Boolean
- #sheet_exists?(sheet_id) ⇒ Boolean
- #should_not_see_alert(alert_id = nil) ⇒ Object
- #should_not_see_button_on_sheet(button_title, sheet_id = nil) ⇒ Object
- #should_not_see_sheet(sheet_id) ⇒ Object
- #should_see_alert(alert_id = nil) ⇒ Object
- #should_see_alert_button(button_id) ⇒ Object
- #should_see_alert_with_message(message, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object
- #should_see_alert_with_title(title, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object
- #should_see_button_on_sheet(button_title, sheet_id = nil) ⇒ Object
- #should_see_sheet(sheet_id, button_titles = nil, sheet_title = nil) ⇒ Object
- #should_see_sheet_title(label_title, sheet_id = nil) ⇒ Object
- #touch_alert_button(button_title) ⇒ Object
- #touch_sheet_button(button_title, sheet_id = nil) ⇒ Object
- #touch_sheet_button_and_wait_for_view(button_title, view_id, sheet_id = nil) ⇒ Object
- #wait_for_sheet(sheet_id, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object
- #wait_for_sheet_to_disappear(sheet_id, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object
Instance Method Details
#alert_button_exists?(button_id) ⇒ Boolean
93 94 95 96 97 98 99 100 |
# File 'lib/briar/alerts_and_sheets/alert_view.rb', line 93 def () if uia_available? should_see_alert not uia_query(:view, {:marked => "#{}"}).empty? else query('alertView child button child label', :text).include?() end end |
#alert_exists?(alert_id = nil) ⇒ Boolean
of interest touch(“view:‘_UIModalItemAlertContentView’ descendant view:‘_UIModalItemTableViewCell’ marked:‘OK’”)
10 11 12 13 14 15 16 17 18 19 20 21 |
# 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 |
#dismiss_alert_with_button(button_label) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/briar/alerts_and_sheets/alert_view.rb', line 108 def () () if uia_available? wait_for_view_to_disappear else wait_for_view_to_disappear 'alertView' end end |
#error_msg_for_sheet_button(button_title, visible, sheet_id = nil) ⇒ Object
64 65 66 67 68 |
# File 'lib/briar/alerts_and_sheets/action_sheet.rb', line 64 def (, visible, sheet_id=nil) vis_str = visible ? 'see' : 'not see' sheet_str = sheet_id ? sheet_id : '' "should #{vis_str} button with title '#{}' on sheet '#{sheet_str}'" end |
#query_str_for_sheet(sheet_id) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# 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_button_exists?(button_title, sheet_id = nil) ⇒ Boolean
70 71 72 73 74 75 76 77 |
# File 'lib/briar/alerts_and_sheets/action_sheet.rb', line 70 def (, sheet_id=nil) sheet_query = query_str_for_sheet sheet_id if ios8? || ios9? query("#{query_str_for_sheet sheet_id} descendant view:'_UIAlertControllerActionView' marked:'#{}'") else query("#{sheet_query} child button child label", :text).include?() end end |
#sheet_exists?(sheet_id) ⇒ Boolean
15 16 17 |
# 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) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# 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_button_on_sheet(button_title, sheet_id = nil) ⇒ Object
85 86 87 88 89 |
# File 'lib/briar/alerts_and_sheets/action_sheet.rb', line 85 def (, sheet_id=nil) if , sheet_id screenshot_and_raise , false, sheet_id end end |
#should_not_see_sheet(sheet_id) ⇒ Object
33 34 35 36 37 |
# 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) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# 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_button(button_id) ⇒ Object
102 103 104 105 106 |
# File 'lib/briar/alerts_and_sheets/alert_view.rb', line 102 def () unless screenshot_and_raise "could not find alert view with button '#{}'" end end |
#should_see_alert_with_message(message, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/briar/alerts_and_sheets/alert_view.rb', line 67 def (, timeout=BRIAR_WAIT_TIMEOUT) should_see_alert if uia_available? msg = "expected to see alert with title '#{}'" 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:'#{}'").empty? else not uia_query(:view, {:marked => "#{}"}).empty? end end else qstr = 'alertView child label' msg = "waited for '#{timeout}' for alert with 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?() end end end |
#should_see_alert_with_title(title, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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 '#{}'" 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:'#{}'").empty? else not uia_query(:view, {:marked => "#{}"}).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_button_on_sheet(button_title, sheet_id = nil) ⇒ Object
79 80 81 82 83 |
# File 'lib/briar/alerts_and_sheets/action_sheet.rb', line 79 def (, sheet_id=nil) unless , sheet_id screenshot_and_raise , true, sheet_id end end |
#should_see_sheet(sheet_id, button_titles = nil, sheet_title = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/briar/alerts_and_sheets/action_sheet.rb', line 19 def should_see_sheet(sheet_id, =nil, sheet_title=nil) unless sheet_exists?(sheet_id) screenshot_and_raise "should see sheet marked '#{sheet_id}'" end if .each { |title| 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) ⇒ Object
91 92 93 94 95 96 97 |
# 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 |
#touch_alert_button(button_title) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/briar/alerts_and_sheets/alert_view.rb', line 118 def () should_see_alert if ios8? || ios9? touch("view marked:'#{}' parent view:'_UIAlertControllerCollectionViewCell'") elsif ios7? touch("view marked:'#{}'") else touch("alertView child button marked:'#{}'") end step_pause end |
#touch_sheet_button(button_title, sheet_id = nil) ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'lib/briar/alerts_and_sheets/action_sheet.rb', line 99 def (, sheet_id=nil) sheet_query = query_str_for_sheet sheet_id , sheet_id if ios8? || ios9? touch("#{query_str_for_sheet sheet_id} descendant view:'_UIAlertControllerActionView' marked:'#{}'") else touch("#{sheet_query} child button child label marked:'#{}'") end end |
#touch_sheet_button_and_wait_for_view(button_title, view_id, sheet_id = nil) ⇒ Object
109 110 111 112 |
# File 'lib/briar/alerts_and_sheets/action_sheet.rb', line 109 def (, view_id, sheet_id=nil) , sheet_id wait_for_view view_id end |
#wait_for_sheet(sheet_id, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# 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" = {:timeout => timeout, :retry_frequency => BRIAR_WAIT_RETRY_FREQ, :post_timeout => BRIAR_WAIT_STEP_PAUSE, :timeout_message => msg} wait_for() do not sheet_exists? sheet_id end end |