Module: Briar::TextView

Defined in:
lib/briar/text_view.rb

Instance Method Summary collapse

Instance Method Details

#should_not_see_text_view(view_id, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object



33
34
35
# File 'lib/briar/text_view.rb', line 33

def should_not_see_text_view (view_id, timeout=BRIAR_WAIT_TIMEOUT)
  wait_for_text_view_to_disappear(view_id, timeout)
end

#should_see_text_view(view_id, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object



29
30
31
# File 'lib/briar/text_view.rb', line 29

def should_see_text_view (view_id, timeout=BRIAR_WAIT_TIMEOUT)
  wait_for_text_view(view_id, timeout)
end

#should_see_text_view_with_text(view_id, text = @text_entered_by_keyboard) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/briar/text_view.rb', line 37

def should_see_text_view_with_text(view_id, text=@text_entered_by_keyboard)
  should_see_text_view view_id
  actual = query("textView marked:'#{view_id}'", :text).first
  unless text.eql?(actual)
    screenshot_and_raise "i expected to see '#{text}' in text view '#{view_id}' but found '#{actual}'"
  end
end

#text_view_exists?(view_id) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/briar/text_view.rb', line 4

def text_view_exists? (view_id)
  !query("textView marked:'#{view_id}'").empty?
end

#wait_for_text_view(view_id, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/briar/text_view.rb', line 8

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

#wait_for_text_view_to_disappear(view_id, timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/briar/text_view.rb', line 18

def wait_for_text_view_to_disappear(view_id, timeout=BRIAR_WAIT_TIMEOUT)
  msg = "waited for '#{timeout}' seconds for '#{view_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 text_view_exists? view_id
  end
end