Class: Watir::Element
- Inherits:
-
Object
- Object
- Watir::Element
- Defined in:
- lib/patches/watir.rb
Instance Method Summary collapse
- #attribute_values ⇒ Object
- #bottom_edge ⇒ Object
- #bounding_rectangle_offsets ⇒ Object
- #client_center ⇒ Object
- #client_lower_right ⇒ Object
- #client_offset ⇒ Object
- #dimensions ⇒ Object
- #fetch_attributes ⇒ Object
-
#get_attributes ⇒ Object
for watir element returns array of arrays where each element is a [name, value] as long as value is other than null or blank.
- #left_edge ⇒ Object
- #left_edge_absolute ⇒ Object
- #right_edge ⇒ Object
- #screen_center ⇒ Object
- #screen_lower_right ⇒ Object
- #screen_offset ⇒ Object
- #top_edge ⇒ Object
- #top_edge_absolute ⇒ Object
Instance Method Details
#attribute_values ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/patches/watir.rb', line 28 def attribute_values hash = Hash.new ['id', # 'offsetParent', 'style', 'currentstyle', 'offsetHeight', 'offsetWidth', 'offsetLeft', 'offsetTop', 'clientHeight', 'clientWidth', 'clientLeft', 'clientTop', 'scrollHeight', 'scrollWidth', 'scrollLeft', 'scrollTop', 'className', 'resizable', 'visible', 'sourceIndex'].each do |attr| value = attribute_value(attr) myClass = value.class if myClass =~ /WIN32OLE/i or value.is_a?(WIN32OLE) meths = Hash.new value.ole_methods.each do |m| meths[m.name] = m.helpstring end hash[attr] = meths.sort else hash[attr] = value end end hash end |
#bottom_edge ⇒ Object
65 66 67 68 69 |
# File 'lib/patches/watir.rb', line 65 def bottom_edge assert_exists assert_enabled ole_object.getBoundingClientRect.bottom.to_i end |
#bounding_rectangle_offsets ⇒ Object
159 160 161 162 163 164 |
# File 'lib/patches/watir.rb', line 159 def bounding_rectangle_offsets l, t = client_offset r = ole_object.getBoundingClientRect.right.to_i b = ole_object.getBoundingClientRect.bottom.to_i [t, b, l, r] end |
#client_center ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/patches/watir.rb', line 122 def client_center client_offset + dimensions.map { |dim| dim/2 } # x, y = client_offset # w, h = dimensions # cx = x + ( w / 2 ).to_i # cy = y + ( h / 2 ).to_i # [cx, cy] end |
#client_lower_right ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/patches/watir.rb', line 141 def client_lower_right x, y = client_offset w, h = dimensions lrx = x + w lry = y + h [lrx, lry] end |
#client_offset ⇒ Object
117 118 119 |
# File 'lib/patches/watir.rb', line 117 def client_offset [left_edge, top_edge] end |
#dimensions ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/patches/watir.rb', line 103 def dimensions assert_exists assert_enabled x = ole_object.getBoundingClientRect.right.to_i - left_edge y = ole_object.getBoundingClientRect.bottom.to_i - top_edge [x, y] end |
#fetch_attributes ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/patches/watir.rb', line 52 def fetch_attributes assert_exists assert_enabled obj = ole_object hash = Hash.new methods = obj.ole_methods methods.each do |m| hash[m.name] = "visible: #{m.visible?}: #{m.helpstring}: #{m.invoke_kind}: #{m.params}: #{m.return_type}: #{m.return_type_detail}" end hash.sort.to_yaml end |
#get_attributes ⇒ Object
for watir element returns array of arrays where each element is a [name, value] as long as value is other than null or blank
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/patches/watir.rb', line 16 def get_attributes attrs = [] self.document.attributes.each do |atr| k= [] next if (atr.value == 'null') || (atr.value == '') k << atr.name << atr.value attrs << k end attrs.sort end |
#left_edge ⇒ Object
84 85 86 87 88 |
# File 'lib/patches/watir.rb', line 84 def left_edge assert_exists assert_enabled ole_object.getBoundingClientRect.left.to_i end |
#left_edge_absolute ⇒ Object
98 99 100 |
# File 'lib/patches/watir.rb', line 98 def left_edge_absolute left_edge + page_container.document.parentWindow.screenLeft.to_i end |
#right_edge ⇒ Object
91 92 93 94 95 |
# File 'lib/patches/watir.rb', line 91 def right_edge assert_exists assert_enabled ole_object.getBoundingClientRect.right.to_i end |
#screen_center ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/patches/watir.rb', line 132 def screen_center x, y = screen_offset w, h = dimensions cx = x + (w / 2).to_i cy = y + (h / 2).to_i [cx, cy] end |
#screen_lower_right ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/patches/watir.rb', line 150 def screen_lower_right x, y = screen_offset w, h = dimensions lrx = x + w lry = y + h [lrx, lry] end |
#screen_offset ⇒ Object
112 113 114 |
# File 'lib/patches/watir.rb', line 112 def screen_offset [left_edge_absolute, top_edge_absolute] end |
#top_edge ⇒ Object
72 73 74 75 76 |
# File 'lib/patches/watir.rb', line 72 def top_edge assert_exists assert_enabled ole_object.getBoundingClientRect.top.to_i end |
#top_edge_absolute ⇒ Object
79 80 81 |
# File 'lib/patches/watir.rb', line 79 def top_edge_absolute top_edge + page_container.document.parentWindow.screenTop.to_i end |