Module: WatirRobot::Form

Included in:
KeywordLibrary
Defined in:
lib/watir_robot/keywords/form.rb

Overview

Functionality related to HTML forms as a whole

Instance Method Summary collapse

Instance Method Details

#form_should_contain_button(form_loc, field_loc) ⇒ Object

Verify that a form contains a specific button

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



14
15
16
17
# File 'lib/watir_robot/keywords/form.rb', line 14

def form_should_contain_button(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The button described by #{field_loc} was not located in the form described by #{form_loc}.") unless
    @browser.form(parse_location(form_loc)).button(parse_location(field_loc)).exists?
end

#form_should_contain_checkbox(form_loc, field_loc) ⇒ Object

Verify that a form contains a specific checkbox

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



36
37
38
39
# File 'lib/watir_robot/keywords/form.rb', line 36

def form_should_contain_checkbox(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The checkbox described by #{field_loc} was not located in the form described by #{form_loc}.") unless
    @browser.form(parse_location(form_loc)).checkbox(parse_location(field_loc)).exists?
end

#form_should_contain_element(form_loc, field_loc) ⇒ Object

Verify that a form contains a specific element

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



58
59
60
61
# File 'lib/watir_robot/keywords/form.rb', line 58

def form_should_contain_element(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The element described by #{field_loc} was not located in the form described by #{form_loc}.") unless
    @browser.form(parse_location(form_loc)).checkbox(parse_location(field_loc)).exists?
end

#form_should_contain_filefield(form_loc, field_loc) ⇒ Object

Verify that a form contains a specific file-field

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



80
81
82
83
# File 'lib/watir_robot/keywords/form.rb', line 80

def form_should_contain_filefield(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The file-field described by #{field_loc} was not located in the form described by #{form_loc}.") unless
    @browser.form(parse_location(form_loc)).file_field(parse_location(field_loc)).exists?
end

#form_should_contain_radio_button(form_loc, field_loc) ⇒ Object

Verify that a form contains a specific radio button

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



102
103
104
105
# File 'lib/watir_robot/keywords/form.rb', line 102

def form_should_contain_radio_button(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The radio button described by #{field_loc} was not located in the form described by #{form_loc}.") unless
    @browser.form(parse_location(form_loc)).radio(parse_location(field_loc)).exists?
end

#form_should_contain_select_list(form_loc, field_loc) ⇒ Object

Verify that a form contains a specific select list

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



124
125
126
127
# File 'lib/watir_robot/keywords/form.rb', line 124

def form_should_contain_select_list(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The select list described by #{field_loc} was not located in the form described by #{form_loc}.") unless
    @browser.form(parse_location(form_loc)).select(parse_location(field_loc)).exists?
end

#form_should_contain_textfield(form_loc, field_loc) ⇒ Object

Verify that a form contains a specific text field

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



146
147
148
149
# File 'lib/watir_robot/keywords/form.rb', line 146

def form_should_contain_textfield(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The textfield described by #{field_loc} was not located in the form described by #{form_loc}.") unless
    @browser.form(parse_location(form_loc)).text_field(parse_location(field_loc)).exists?
end

#form_should_not_contain_button(form_loc, field_loc) ⇒ Object

Verify that a form does not contain a specific button

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



25
26
27
28
# File 'lib/watir_robot/keywords/form.rb', line 25

def form_should_not_contain_button(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The button described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
    @browser.form(parse_location(form_loc)).button(parse_location(field_loc)).exists?
end

#form_should_not_contain_checkbox(form_loc, field_loc) ⇒ Object

Verify that a form does not contain a specific checkbox

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



47
48
49
50
# File 'lib/watir_robot/keywords/form.rb', line 47

def form_should_not_contain_checkbox(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The checkbox described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
    @browser.form(parse_location(form_loc)).checkbox(parse_location(field_loc)).exists?
end

#form_should_not_contain_element(form_loc, field_loc) ⇒ Object

Verify that a form does not contain a specific element

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



69
70
71
72
# File 'lib/watir_robot/keywords/form.rb', line 69

def form_should_not_contain_element(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The element described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
    @browser.form(parse_location(form_loc)).checkbox(parse_location(field_loc)).exists?
end

#form_should_not_contain_filefield(form_loc, field_loc) ⇒ Object

Verify that a form does not contain a specific file-field

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



91
92
93
94
# File 'lib/watir_robot/keywords/form.rb', line 91

def form_should_not_contain_filefield(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The file-field described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
    @browser.form(parse_location(form_loc)).file_field(parse_location(field_loc)).exists?
end

#form_should_not_contain_radio_button(form_loc, field_loc) ⇒ Object

Verify that a form does not contain a specific radio button

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



113
114
115
116
# File 'lib/watir_robot/keywords/form.rb', line 113

def form_should_not_contain_radio_button(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The radio button described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
    @browser.form(parse_location(form_loc)).radio(parse_location(field_loc)).exists?
end

#form_should_not_contain_select_list(form_loc, field_loc) ⇒ Object

Verify that a form does not contain a specific select list

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



135
136
137
138
# File 'lib/watir_robot/keywords/form.rb', line 135

def form_should_not_contain_select_list(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The select list described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
    @browser.form(parse_location(form_loc)).select(parse_location(field_loc)).exists?
end

#form_should_not_contain_textfield(form_loc, field_loc) ⇒ Object

Verify that a form does not contain a specific text field

Parameters:

  • form_loc (String)

    attribute/value pairs that match an HTML element

  • field_loc (String)

    attribute/value pairs that match an HTML element

Raises:



157
158
159
160
# File 'lib/watir_robot/keywords/form.rb', line 157

def form_should_not_contain_textfield(form_loc, field_loc)
  raise(Exception::ElementMatchError, "The textfield described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
    @browser.form(parse_location(form_loc)).text_field(parse_location(field_loc)).exists?
end