Class: Watirmark::KeyedElement
- Defined in:
- lib/watirmark/page/keyed_element.rb
Instance Attribute Summary collapse
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#process_page ⇒ Object
readonly
Returns the value of attribute process_page.
Instance Method Summary collapse
- #get(*args) ⇒ Object
-
#initialize(context, options) ⇒ KeyedElement
constructor
A new instance of KeyedElement.
- #populate_allowed? ⇒ Boolean
- #set(val) ⇒ Object
- #verify_allowed? ⇒ Boolean
Constructor Details
#initialize(context, options) ⇒ KeyedElement
Returns a new instance of KeyedElement.
12 13 14 15 16 17 18 19 |
# File 'lib/watirmark/page/keyed_element.rb', line 12 def initialize(context, ) @context = context @keyword = [:keyword] @block = [:block] @process_page = [:process_page] = [:permissions] || {} @map = Watirmark::RadioMap.new([:map]) if [:map] end |
Instance Attribute Details
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
10 11 12 |
# File 'lib/watirmark/page/keyed_element.rb', line 10 def keyword @keyword end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
10 11 12 |
# File 'lib/watirmark/page/keyed_element.rb', line 10 def end |
#process_page ⇒ Object (readonly)
Returns the value of attribute process_page.
10 11 12 |
# File 'lib/watirmark/page/keyed_element.rb', line 10 def process_page @process_page end |
Instance Method Details
#get(*args) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/watirmark/page/keyed_element.rb', line 21 def get *args @process_page.activate watir_object = @context.instance_exec(*args, &@block) return if watir_object.nil? watir_object.extend(KeywordMethods) watir_object.radio_map = @map if @map watir_object.keyword = @keyword watir_object end |
#populate_allowed? ⇒ Boolean
54 55 56 |
# File 'lib/watirmark/page/keyed_element.rb', line 54 def populate_allowed? [:populate] end |
#set(val) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/watirmark/page/keyed_element.rb', line 31 def set val return if val.nil? element = get val = @map.lookup(val) if @map case val when 'nil' element.clear # workaround to empty element values else case element when Watir::Radio element.set val when Watir::CheckBox val ? element.set : element.clear when Watir::Select element.select val when Watir::Button element.click else element.value = val end end end |
#verify_allowed? ⇒ Boolean
58 59 60 |
# File 'lib/watirmark/page/keyed_element.rb', line 58 def verify_allowed? [:verify] end |