Class: FormObjectModel::Form
- Inherits:
-
Object
- Object
- FormObjectModel::Form
- Defined in:
- lib/form_object_model/form.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
-
#initialize(page) {|_self| ... } ⇒ Form
constructor
A new instance of Form.
-
#radio(name, locator) ⇒ Object
Radio button locators should match all buttons in the group.
- #select(name, locator) ⇒ Object
- #submit ⇒ Object
- #submit_button(locator, &after_submit_block) ⇒ Object
- #text_field(name, locator) ⇒ Object
- #within {|_self| ... } ⇒ Object
Constructor Details
#initialize(page) {|_self| ... } ⇒ Form
Returns a new instance of Form.
5 6 7 8 |
# File 'lib/form_object_model/form.rb', line 5 def initialize(page) @page = page yield(self) if block_given? end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
3 4 5 |
# File 'lib/form_object_model/form.rb', line 3 def page @page end |
Instance Method Details
#radio(name, locator) ⇒ Object
Radio button locators should match all buttons in the group
19 20 21 |
# File 'lib/form_object_model/form.rb', line 19 def radio(name, locator) define_field(name, RadioField.new(page, name, locator)) end |
#select(name, locator) ⇒ Object
14 15 16 |
# File 'lib/form_object_model/form.rb', line 14 def select(name, locator) define_field(name, SelectField.new(page, name, locator)) end |
#submit ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/form_object_model/form.rb', line 28 def submit raise "FormObjectModel#submit_button called before submit_button locator was set" unless @submit_button page. @submit_button if @after_submit_block @after_submit_block.call(page) end end |
#submit_button(locator, &after_submit_block) ⇒ Object
23 24 25 26 |
# File 'lib/form_object_model/form.rb', line 23 def (locator, &after_submit_block) @submit_button = locator @after_submit_block = after_submit_block end |
#text_field(name, locator) ⇒ Object
10 11 12 |
# File 'lib/form_object_model/form.rb', line 10 def text_field(name, locator) define_field(name, TextField.new(page, name, locator)) end |
#within {|_self| ... } ⇒ Object
36 37 38 |
# File 'lib/form_object_model/form.rb', line 36 def within yield(self) end |