Class: FormObjectModel::Form
- Inherits:
-
Object
- Object
- FormObjectModel::Form
show all
- Defined in:
- lib/form_object_model/form.rb
Defined Under Namespace
Classes: Field, RadioField, SelectField, TextField
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(page) {|_self| ... } ⇒ Form
Returns a new instance of Form.
73
74
75
76
|
# File 'lib/form_object_model/form.rb', line 73
def initialize(page)
@page = page
yield(self) if block_given?
end
|
Instance Attribute Details
#page ⇒ Object
Returns the value of attribute page.
71
72
73
|
# File 'lib/form_object_model/form.rb', line 71
def page
@page
end
|
Instance Method Details
#radio(name, locator) ⇒ Object
Radio button locators should match all buttons in the group
87
88
89
|
# File 'lib/form_object_model/form.rb', line 87
def radio(name, locator)
define_field(name, RadioField.new(page, name, locator))
end
|
#select(name, locator) ⇒ Object
82
83
84
|
# File 'lib/form_object_model/form.rb', line 82
def select(name, locator)
define_field(name, SelectField.new(page, name, locator))
end
|
#submit ⇒ Object
96
97
98
99
100
101
102
|
# File 'lib/form_object_model/form.rb', line 96
def submit
raise "FormObjectModel#submit_button called before submit_button locator was set" unless @submit_button
page.click_button @submit_button
if @after_submit_block
@after_submit_block.call(page)
end
end
|
91
92
93
94
|
# File 'lib/form_object_model/form.rb', line 91
def submit_button(locator, &after_submit_block)
@submit_button = locator
@after_submit_block = after_submit_block
end
|
#text_field(name, locator) ⇒ Object
78
79
80
|
# File 'lib/form_object_model/form.rb', line 78
def text_field(name, locator)
define_field(name, TextField.new(page, name, locator))
end
|
#within {|_self| ... } ⇒ Object
104
105
106
|
# File 'lib/form_object_model/form.rb', line 104
def within
yield(self)
end
|