Module: Briar::Control::Button

Defined in:
lib/briar/control/button.rb

Instance Method Summary collapse

Instance Method Details

#button_exists?(button_id) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/briar/control/button.rb', line 6

def button_exists? (button_id)
  not query("button marked:'#{button_id}'").empty?
end

#button_is_enabled(name) ⇒ Object



18
19
20
21
# File 'lib/briar/control/button.rb', line 18

def button_is_enabled (name)
  enabled = query("button marked:'#{name}' isEnabled:1", AI).first
  enabled.eql? name
end

#should_not_see_button(button_id) ⇒ Object



14
15
16
# File 'lib/briar/control/button.rb', line 14

def should_not_see_button (button_id)
  screenshot_and_raise "i should not see button marked '#{button_id}'" if button_exists?(button_id)
end

#should_see_button(button_id) ⇒ Object



10
11
12
# File 'lib/briar/control/button.rb', line 10

def should_see_button (button_id)
  wait_for_button button_id
end

#should_see_button_with_title(name, title) ⇒ Object



23
24
25
26
27
28
# File 'lib/briar/control/button.rb', line 23

def should_see_button_with_title(name, title)
  should_see_button name
  if query("button marked:'#{name}' child label", :text).empty?
    screenshot_and_raise "i do not see a button marked '#{name}' with title '#{title}'"
  end
end

#touch_button(button_id) ⇒ Object



30
31
32
33
# File 'lib/briar/control/button.rb', line 30

def touch_button (button_id)
  should_see_button button_id
  touch("button marked:'#{button_id}'")
end

#touch_button_and_wait_for_view(button_id, view_id, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object



35
36
37
38
39
40
# File 'lib/briar/control/button.rb', line 35

def touch_button_and_wait_for_view (button_id, view_id, timeout=BRIAR_WAIT_TIMEOUT)
  touch_button(button_id)
  unless view_id.nil?
    wait_for_view view_id, timeout
  end
end

#touch_button_and_wait_for_view_to_disappear(button_id, view_id, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object



42
43
44
45
# File 'lib/briar/control/button.rb', line 42

def touch_button_and_wait_for_view_to_disappear (button_id, view_id, timeout=BRIAR_WAIT_TIMEOUT)
  touch_button button_id
  wait_for_view_to_disappear view_id, timeout
end

#touch_button_with_title(button_id, title, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object



72
73
74
75
# File 'lib/briar/control/button.rb', line 72

def touch_button_with_title(button_id, title, timeout=BRIAR_WAIT_TIMEOUT)
  wait_for_button_with_title button_id, title, timeout
  touch("button marked:'#{button_id}'")
end

#wait_for_button(button_id, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/briar/control/button.rb', line 48

def wait_for_button (button_id, timeout=BRIAR_WAIT_TIMEOUT)
  msg = "waited for '#{timeout}' seconds but did not see button '#{button_id}'"
  wait_for(:timeout => timeout,
           :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
           :post_timeout => BRIAR_WAIT_STEP_PAUSE,
           :timeout_message => msg) do
    button_exists? button_id
  end
end

#wait_for_button_with_title(button_id, title, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/briar/control/button.rb', line 58

def wait_for_button_with_title (button_id, title, timeout=BRIAR_WAIT_TIMEOUT)
  msg = "waited for '#{timeout}' seconds but did not see button '#{button_id}' with title '#{title}'"
  wait_for(:timeout => timeout,
           :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
           :post_timeout => BRIAR_WAIT_STEP_PAUSE,
           :timeout_message => msg) do
    button_exists? button_id
  end
  res = query("button descendant view {text LIKE '#{title}'")
  if res.empty?
    screenshot_and_raise "expected button '#{button_id}' to have title '#{title}'"
  end
end