Module: Briar::TextField

Defined in:
lib/briar/text_field.rb

Instance Method Summary collapse

Instance Method Details

#button_in_text_field_is_clear?(text_field_id) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
32
# File 'lib/briar/text_field.rb', line 23

def button_in_text_field_is_clear? (text_field_id)
  ht = query("textField marked:'#{text_field_id}' child button child imageView", :frame).first
  return false if ht.nil?

  if ios7?
    ht['X'] == 2.5 and ht['Y'] == 2.5 and ht['Width'] == 14 and ht['Height'] == 14
  else
    ht['X'] == 0 and ht['Y'] == 0 and ht['Width'] == 19 and ht['Height'] == 19
  end
end

#clear_text_field_with_button(text_field_id) ⇒ Object



34
35
36
37
# File 'lib/briar/text_field.rb', line 34

def clear_text_field_with_button(text_field_id)
  should_see_clear_button_in_text_field text_field_id
  touch("textField marked:'#{text_field_id}' child button")
end

#should_not_see_clear_button_in_text_field(text_field_id) ⇒ Object



45
46
47
48
49
# File 'lib/briar/text_field.rb', line 45

def should_not_see_clear_button_in_text_field (text_field_id)
  if button_in_text_field_is_clear? text_field_id
    screenshot_and_raise "did NOT expected to see clear button in text field #{text_field_id}"
  end
end

#should_not_see_text_field(name) ⇒ Object



16
17
18
19
20
21
# File 'lib/briar/text_field.rb', line 16

def should_not_see_text_field (name)
  res = text_field_exists? name
  if res
    screenshot_and_raise "i should not see text field with name #{name}"
  end
end

#should_see_clear_button_in_text_field(text_field_id) ⇒ Object



39
40
41
42
43
# File 'lib/briar/text_field.rb', line 39

def should_see_clear_button_in_text_field (text_field_id)
  unless button_in_text_field_is_clear? text_field_id
    screenshot_and_raise "expected to see clear button in text field #{text_field_id}"
  end
end

#should_see_text_field(name) ⇒ Object



9
10
11
12
13
14
# File 'lib/briar/text_field.rb', line 9

def should_see_text_field (name)
  res = text_field_exists? name
  unless res
    screenshot_and_raise "could not find text field with name #{name}"
  end
end

#should_see_text_field_with_text(text_field, text) ⇒ Object



56
57
58
59
60
61
# File 'lib/briar/text_field.rb', line 56

def should_see_text_field_with_text (text_field, text)
  unless text_field_exists_with_text? text_field, text
    actual = query("textField marked:'#{text_field}'", :text).first
    screenshot_and_raise "i expected to see text field named '#{text_field}' with text '#{text}' but found '#{actual}'"
  end
end

#text_field_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/briar/text_field.rb', line 5

def text_field_exists? (name)
  !query("textField marked:'#{name}'").empty?
end

#text_field_exists_with_text?(text_field, text) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/briar/text_field.rb', line 51

def text_field_exists_with_text?(text_field, text)
  actual = query("textField marked:'#{text_field}'", :text).first
  actual.eql? text
end