Class: Webrat::CulerityScope
Instance Attribute Summary collapse
-
#container ⇒ Object
readonly
Returns the value of attribute container.
Instance Method Summary collapse
- #check(id_or_name_or_label, value = true) ⇒ Object
- #choose(id_or_name_or_label) ⇒ Object
- #click_button(value_or_id_or_alt = nil, options = {}) ⇒ Object
- #click_link(text_or_title_or_id, options = {}) ⇒ Object
- #field_by_xpath(xpath) ⇒ Object
- #field_labeled(label) ⇒ Object
- #field_with_id(id) ⇒ Object
- #fill_in(id_or_name_or_label, options = {}) ⇒ Object
-
#initialize(container) ⇒ CulerityScope
constructor
A new instance of CulerityScope.
- #response_body ⇒ Object
- #select(option_text, options = {}) ⇒ Object
- #uncheck(id_or_name_or_label) ⇒ Object
Constructor Details
#initialize(container) ⇒ CulerityScope
Returns a new instance of CulerityScope.
5 6 7 |
# File 'lib/webrat/culerity/scope.rb', line 5 def initialize(container) @container = container end |
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container.
3 4 5 |
# File 'lib/webrat/culerity/scope.rb', line 3 def container @container end |
Instance Method Details
#check(id_or_name_or_label, value = true) ⇒ Object
9 10 11 12 |
# File 'lib/webrat/culerity/scope.rb', line 9 def check(id_or_name_or_label, value = true) elem = element_locator(id_or_name_or_label, :check_box) elem.set(value) end |
#choose(id_or_name_or_label) ⇒ Object
16 17 18 19 |
# File 'lib/webrat/culerity/scope.rb', line 16 def choose(id_or_name_or_label) elem = element_locator(id_or_name_or_label, :radio) elem.set end |
#click_button(value_or_id_or_alt = nil, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/webrat/culerity/scope.rb', line 23 def (value_or_id_or_alt = nil, = {}) = value_or_id_or_alt if value_or_id_or_alt.is_a?(Hash) with_handler .delete(:confirm) do if value_or_id_or_alt elem = element_locator(value_or_id_or_alt, :button, :value, :id, :text, :alt) else elem = container.[0] # celerity should really include Enumerable here end elem.click end end |
#click_link(text_or_title_or_id, options = {}) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/webrat/culerity/scope.rb', line 38 def click_link(text_or_title_or_id, = {}) with_handler .delete(:confirm) do elem = element_locator(text_or_title_or_id, :link, :text, :title, :id) elem.click end end |
#field_by_xpath(xpath) ⇒ Object
47 48 49 |
# File 'lib/webrat/culerity/scope.rb', line 47 def field_by_xpath(xpath) element_locator(xpath, :generic_field, :xpath) end |
#field_labeled(label) ⇒ Object
51 52 53 |
# File 'lib/webrat/culerity/scope.rb', line 51 def field_labeled(label) element_locator(label, :generic_field, :label) end |
#field_with_id(id) ⇒ Object
55 56 57 |
# File 'lib/webrat/culerity/scope.rb', line 55 def field_with_id(id) element_locator(id, :generic_field, :id) end |
#fill_in(id_or_name_or_label, options = {}) ⇒ Object
59 60 61 62 |
# File 'lib/webrat/culerity/scope.rb', line 59 def fill_in(id_or_name_or_label, = {}) elem = element_locator(id_or_name_or_label, :text_field) elem.set([:with]) end |
#response_body ⇒ Object
66 67 68 |
# File 'lib/webrat/culerity/scope.rb', line 66 def response_body container.html end |
#select(option_text, options = {}) ⇒ Object
70 71 72 73 |
# File 'lib/webrat/culerity/scope.rb', line 70 def select(option_text, = {}) elem = element_locator([:from], :select_list) elem.select(option_text) end |
#uncheck(id_or_name_or_label) ⇒ Object
77 78 79 |
# File 'lib/webrat/culerity/scope.rb', line 77 def uncheck(id_or_name_or_label) check(id_or_name_or_label, false) end |