watir 3.0.0.rc2 → 3.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/CHANGES +19 -0
  2. data/VERSION +1 -1
  3. data/lib/watir/close_all.rb +2 -2
  4. data/lib/watir/container.rb +6 -4
  5. data/lib/watir/cookies.rb +80 -0
  6. data/lib/watir/core.rb +7 -3
  7. data/lib/watir/dialogs/file_field.rb +0 -4
  8. data/lib/watir/drag_and_drop_helper.rb +68 -0
  9. data/lib/watir/element.rb +58 -156
  10. data/lib/watir/element_collection.rb +109 -0
  11. data/lib/watir/form.rb +7 -14
  12. data/lib/watir/frame.rb +11 -26
  13. data/lib/watir/ie-class.rb +17 -307
  14. data/lib/watir/ie.rb +0 -9
  15. data/lib/watir/image.rb +8 -25
  16. data/lib/watir/input_elements.rb +32 -81
  17. data/lib/watir/link.rb +2 -17
  18. data/lib/watir/locator.rb +29 -25
  19. data/lib/watir/modal_dialog.rb +26 -40
  20. data/lib/watir/non_control_elements.rb +111 -79
  21. data/lib/watir/page-container.rb +12 -1
  22. data/lib/watir/supported_elements.rb +172 -0
  23. data/lib/watir/table.rb +61 -89
  24. data/lib/watir/win32ole.rb +2 -3
  25. data/lib/watir/win32ole/1.9.3/win32ole.so +0 -0
  26. data/lib/watir/xpath_locator.rb +52 -0
  27. data/rakefile.rb +1 -1
  28. data/unittests/checkbox_test.rb +22 -32
  29. data/unittests/css_selector_test.rb +1 -6
  30. data/unittests/css_test.rb +1 -4
  31. data/unittests/div_test.rb +3 -21
  32. data/unittests/document_standards.rb +0 -4
  33. data/unittests/element_collections_test.rb +2 -2
  34. data/unittests/element_test.rb +1 -1
  35. data/unittests/form_test.rb +0 -30
  36. data/unittests/frame_test.rb +8 -49
  37. data/unittests/ie_test.rb +5 -9
  38. data/unittests/images_test.rb +6 -6
  39. data/unittests/index_specifier_test.rb +0 -1
  40. data/unittests/js_events_test.rb +1 -1
  41. data/unittests/links_multi_test.rb +0 -14
  42. data/unittests/links_test.rb +8 -51
  43. data/unittests/lists_test.rb +0 -9
  44. data/unittests/navigate_test.rb +1 -1
  45. data/unittests/nbsp_xpath_test.rb +1 -1
  46. data/unittests/no_wait_test.rb +3 -3
  47. data/unittests/parent_child_test.rb +0 -17
  48. data/unittests/pre_test.rb +0 -3
  49. data/unittests/radios_test.rb +31 -42
  50. data/unittests/selectbox_test.rb +18 -21
  51. data/unittests/selectbox_xpath_test.rb +11 -26
  52. data/unittests/table_test.rb +14 -79
  53. data/unittests/textfields_test.rb +8 -47
  54. data/unittests/windows/attach_to_new_window_test.rb +0 -8
  55. data/unittests/windows/frame_links_test.rb +5 -5
  56. data/unittests/windows/ie-each_test.rb +1 -1
  57. data/unittests/windows/modal_dialog_test.rb +2 -2
  58. data/watir.gemspec +3 -3
  59. metadata +81 -126
  60. data/lib/watir/camel_case.rb +0 -67
  61. data/lib/watir/collections.rb +0 -48
  62. data/lib/watir/cookiemanager.rb +0 -56
  63. data/lib/watir/element_collections.rb +0 -81
  64. data/lib/watir/html_element.rb +0 -30
  65. data/unittests/defer_test.rb +0 -47
  66. data/unittests/multiple_specifiers_test.rb +0 -29
  67. data/unittests/table_and_tablerow_to_a_test.rb +0 -117
  68. data/unittests/windows/iedialog_test.rb +0 -53
data/CHANGES CHANGED
@@ -1,3 +1,22 @@
1
+ == 3.0.0.rc3 - 2012/03/18
2
+
3
+ * all html elements are now supported (even html5 ones)
4
+ * CookieManager removed
5
+ * cookies API support added (https://github.com/watir/watirspec/blob/master/cookies_spec.rb)
6
+ * drag and drop API support added (https://github.com/watir/watirspec/blob/master/drag_and_drop_spec.rb)
7
+ * Element#(before|after)? removed
8
+ * Element#(before|after)_text removed
9
+ * Browser#cell(s) and Browser#row(s) removed
10
+ * Browser#Element camelCase methods removed, use under_score methods instead
11
+ * Browser#element(s) supports only general attributes like :id, :title, :class_name, :text, :html and such
12
+ * Browser#modal_dialog improved
13
+ * Browser#send_keys and Element#send_keys have now same syntax as specified in WatirSpec
14
+ * Element#style returns internal styles only for IE9, inline style will be returned for IE8
15
+ * Table#each removed - use Table#(trs|rows).each instead
16
+ * Table#row(s) and Table#cell(s) added which ignore inner tables - use #td/#tr for all.
17
+ * raise an Exception if more locators are specified with :xpath/:css
18
+ * searching by :xpath and :css code rewritten
19
+
1
20
  == 3.0.0.rc2 - 2012/02/04
2
21
 
3
22
  * Browser#textarea(s) method for searching <textarea> elements
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.0.rc2
1
+ 3.0.0.rc3
@@ -23,9 +23,9 @@ module Watir
23
23
  # to appear and does not raise exception if no window is found.
24
24
  # returns true if modal was found and close, otherwise false
25
25
  def close_modal
26
- while self.modal_dialog.exists?(0) do
26
+ while self.modal_dialog.exists? do
27
27
  self.modal_dialog.close
28
28
  end
29
29
  end
30
30
  end
31
- end
31
+ end
@@ -57,6 +57,10 @@ module Watir
57
57
 
58
58
  public
59
59
 
60
+ def modal_dialog
61
+ ModalDialog.new(self)
62
+ end
63
+
60
64
  # Searching for Page Elements
61
65
  # Not for external consumption
62
66
  #
@@ -98,10 +102,8 @@ module Watir
98
102
  # Not for external use, but cannot set to private due to usages in Element
99
103
  # classes.
100
104
 
101
- def locator_for(locator_class, tags, how, what, klass)
102
- locator = locator_class.new self, tags, klass
103
- locator.set_specifier how, what
104
- locator
105
+ def locator_for(locator_class, specifiers, klass)
106
+ locator_class.new self, specifiers, klass
105
107
  end
106
108
 
107
109
  end # module
@@ -0,0 +1,80 @@
1
+ require "uri"
2
+
3
+ module Watir
4
+ class Cookies
5
+ include Enumerable
6
+
7
+ def initialize(page_container)
8
+ @page_container = page_container
9
+ end
10
+
11
+ def each
12
+ @page_container.document.cookie.split(";").each do |cookie|
13
+ name, value = cookie.strip.split("=")
14
+ yield({:name => name, :value => value})
15
+ end
16
+ end
17
+
18
+ def add name, value, options={}
19
+ options = options.map do |option|
20
+ k, v = option
21
+ if k == :expires
22
+ "#{k}=#{v.gmtime.strftime("%a, %d %b %Y %H:%M:%S UTC")}"
23
+ elsif k == :secure
24
+ "secure" if v
25
+ else
26
+ "#{k}=#{v}"
27
+ end
28
+ end.compact.join("; ")
29
+
30
+ options = "; #{options}" unless options.empty?
31
+ @page_container.document.cookie = "#{name}=#{value}#{options}"
32
+ end
33
+
34
+ def delete name
35
+ options = {:expires => ::Time.now - 60 * 60 * 24}
36
+ delete_with_options name, options
37
+
38
+ # make sure that the cookie gets deleted
39
+ # there's got to be some easier way to do this
40
+ uri = URI.parse(@page_container.url)
41
+ domain = uri.host
42
+
43
+ paths = uri.path.split("/").reduce([]) do |paths, path|
44
+ paths << "#{paths.last}/#{path}".squeeze("/")
45
+ end << "/"
46
+
47
+ subdomains = domain.split(".").reverse.reduce([]) do |subdomains, part|
48
+ subdomain = "#{part}#{subdomains.last}"
49
+ subdomain = "." + subdomain unless subdomain == domain
50
+ subdomains << subdomain
51
+ end
52
+
53
+ subdomains.each do |subdomain|
54
+ domain_options = options.merge :domain => subdomain
55
+ delete_with_options name, domain_options
56
+ delete_with_options name, domain_options.merge(:secure => true)
57
+
58
+ paths.each do |path|
59
+ path_options = options.merge :path => path
60
+ delete_with_options name, path_options
61
+ delete_with_options name, path_options.merge(:secure => true)
62
+
63
+ path_domain_options = domain_options.merge :path => path
64
+ delete_with_options name, path_domain_options
65
+ delete_with_options name, path_domain_options.merge(:secure => true)
66
+ end
67
+ end
68
+ end
69
+
70
+ def clear
71
+ each {|cookie| delete cookie[:name]}
72
+ end
73
+
74
+ def delete_with_options name, options={}
75
+ add name, nil, options
76
+ end
77
+
78
+ private :delete_with_options
79
+ end
80
+ end
@@ -14,20 +14,22 @@ require 'watir/element_extensions'
14
14
  require 'logger'
15
15
  require 'watir/logger'
16
16
  require 'watir/container'
17
+ require 'watir/xpath_locator'
17
18
  require 'watir/locator'
18
19
  require 'watir/page-container'
19
20
  require 'watir/ie-class'
21
+ require 'watir/drag_and_drop_helper'
20
22
  require 'watir/element'
21
- require 'watir/element_collections'
23
+ require 'watir/element_collection'
22
24
  require 'watir/form'
23
25
  require 'watir/frame'
24
- require 'watir/non_control_elements'
25
26
  require 'watir/input_elements'
27
+ require 'watir/non_control_elements'
26
28
  require 'watir/table'
27
29
  require 'watir/image'
28
30
  require 'watir/link'
29
- require 'watir/html_element'
30
31
  require 'watir/window'
32
+ require 'watir/cookies'
31
33
 
32
34
  require 'watir/win32'
33
35
  require 'watir/modal_dialog'
@@ -37,3 +39,5 @@ require 'watir/module'
37
39
  require 'rautomation'
38
40
  require 'watir/dialogs/file_field'
39
41
  require 'watir/dialogs/javascript'
42
+
43
+ require 'watir/supported_elements'
@@ -1,9 +1,5 @@
1
1
  module Watir
2
2
  class FileField < InputElement
3
- #:stopdoc:
4
- INPUT_TYPES = ["file"]
5
- #:startdoc:
6
-
7
3
  def set(file_path)
8
4
  assert_file_exists(file_path)
9
5
  assert_exists
@@ -0,0 +1,68 @@
1
+ module Watir
2
+ module DragAndDropHelper
3
+
4
+ def drag_and_drop_on(target)
5
+ perform_action do
6
+ assert_target target
7
+ drop_x, drop_y = target.send :source_x_y
8
+ drag_to drop_x, drop_y
9
+ end
10
+ end
11
+
12
+ def drag_and_drop_by(distance_x, distance_y)
13
+ perform_action do
14
+ drag_x, drag_y = source_x_y
15
+ drag_to drag_x + distance_x, drag_y + distance_y
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def drag_to(drop_x, drop_y)
22
+ drag_x, drag_y = source_x_y
23
+ mouse = page_container.rautomation.mouse
24
+ mouse.move :x => drag_x , :y => drag_y
25
+ mouse.press
26
+ mouse.move :x => drop_x, :y => drop_y
27
+ mouse.release
28
+ end
29
+
30
+ def source_x_y
31
+ center_x_y_absolute left_edge_absolute, top_edge_absolute
32
+ end
33
+
34
+ def assert_target(target)
35
+ target.assert_exists
36
+ target.assert_enabled
37
+ end
38
+
39
+ def top_edge
40
+ ole_object.getBoundingClientRect.top.to_i
41
+ end
42
+
43
+ def top_edge_absolute
44
+ top_edge + page_container.document.parentWindow.screenTop.to_i
45
+ end
46
+
47
+ def left_edge
48
+ ole_object.getBoundingClientRect.left.to_i
49
+ end
50
+
51
+ def left_edge_absolute
52
+ left_edge + page_container.document.parentWindow.screenLeft.to_i
53
+ end
54
+
55
+ def right_edge
56
+ ole_object.getBoundingClientRect.right.to_i
57
+ end
58
+
59
+ def bottom_edge
60
+ ole_object.getBoundingClientRect.bottom.to_i
61
+ end
62
+
63
+ def center_x_y_absolute x, y
64
+ return (right_edge - left_edge) / 2 + x, (bottom_edge - top_edge) / 2 + y
65
+ end
66
+
67
+ end
68
+ end
@@ -2,42 +2,35 @@ module Watir
2
2
  # Base class for html elements.
3
3
  # This is not a class that users would normally access.
4
4
  class Element # Wrapper
5
+ include Comparable
5
6
  include ElementExtensions
6
7
  include Exception
7
8
  include Container # presumes @container is defined
9
+ include DragAndDropHelper
10
+
8
11
  attr_accessor :container
9
12
 
10
13
  # number of spaces that separate the property from the value in the to_s method
11
14
  TO_S_SIZE = 14
12
15
 
13
- def self.inherited subclass
14
- class_name = Watir::Util.demodulize(subclass.to_s)
15
- method_name = Watir::Util.underscore(class_name)
16
- Watir::Container.module_eval <<-RUBY
17
- def #{method_name}(how={}, what=nil)
18
- #{class_name}.new(self, how, what)
19
- end
16
+ def initialize(container, specifiers)
17
+ set_container container
18
+ raise ArgumentError, "#{specifiers.inspect} has to be Hash" unless specifiers.is_a?(Hash)
20
19
 
21
- def #{method_name}s(how={}, what=nil)
22
- #{class_name}s.new(self, how, what)
23
- end
24
- RUBY
20
+ @o = specifiers[:ole_object]
21
+ @specifiers = specifiers
25
22
  end
26
23
 
27
- # ole_object - the ole object for the element being wrapped
28
- def initialize(ole_object)
29
- @o = ole_object
30
- @original_color = nil
24
+ def <=> other
25
+ assert_exists
26
+ other.assert_exists
27
+ ole_object.sourceindex <=> other.ole_object.sourceindex
31
28
  end
32
29
 
33
- def locate
34
- return if self.class == Element
30
+ alias_method :eql?, :==
35
31
 
36
- tags = @how.is_a?(Hash) && @how[:tag_name] ? [@how[:tag_name].upcase] :
37
- self.class.const_defined?(:TAG) ? [self.class::TAG] :
38
- self.class.const_defined?(:TAGS) ? self.class::TAGS :
39
- [self.class.name.split("::").last.upcase]
40
- @o = @container.locator_for(TaggedElementLocator, tags, @how, @what, self.class).locate
32
+ def locate
33
+ @o = @container.locator_for(TaggedElementLocator, @specifiers, self.class).locate
41
34
  end
42
35
 
43
36
  # Return the ole object, allowing any methods of the DOM that Watir doesn't support to be used.
@@ -50,94 +43,45 @@ module Watir
50
43
  end
51
44
 
52
45
  def inspect
53
- '#<%s:0x%x located=%s how=%s what=%s>' % [self.class, hash*2, !!ole_object, @how.inspect, @what.inspect]
46
+ '#<%s:0x%x located=%s specifiers=%s>' % [self.class, hash*2, !!ole_object, @specifiers.inspect]
54
47
  end
55
48
 
56
49
  private
57
- def self.def_wrap(method_name, ole_method_name=nil)
58
- class_eval "def #{method_name}
59
- assert_exists
60
- ole_object.invoke('#{ole_method_name || method_name}')
61
- end"
62
- end
63
50
 
64
- def self.def_wrap_guard(method_name, ole_method_name = nil)
65
- class_eval "def #{method_name}
66
- assert_exists
67
- begin
68
- ole_object.invoke('#{ole_method_name || method_name}')
69
- rescue
70
- begin
71
- ole_object.getAttribute('#{ole_method_name || method_name}') || ''
72
- rescue
73
- ''
74
- end
75
- end
76
- end"
51
+ def self.attr_ole(method_name, ole_method_name=nil)
52
+ class_eval %Q[
53
+ def #{method_name}
54
+ assert_exists
55
+ ole_method_name = '#{ole_method_name || method_name.to_s.gsub(/\?$/, '')}'
56
+ ole_object.invoke(ole_method_name) rescue attribute_value(ole_method_name) || '' rescue ''
57
+ end]
77
58
  end
78
59
 
79
-
80
60
  public
61
+
81
62
  def assert_exists
82
63
  locate
83
64
  unless ole_object
84
- if self.is_a?(Frame)
85
- raise UnknownFrameException.new(Watir::Exception.message_for_unable_to_locate(@how, @what))
86
- else
87
- raise UnknownObjectException.new(
88
- Watir::Exception.message_for_unable_to_locate(@how, @what))
89
- end
65
+ exception_class = self.is_a?(Frame) ? UnknownFrameException : UnknownObjectException
66
+ raise exception_class.new(Watir::Exception.message_for_unable_to_locate(@specifiers))
90
67
  end
91
68
  end
92
69
 
93
70
  def assert_enabled
94
- unless enabled?
95
- raise ObjectDisabledException, "object #{@how} and #{@what} is disabled"
96
- end
71
+ raise ObjectDisabledException, "object #{@specifiers.inspect} is disabled" unless enabled?
97
72
  end
98
73
 
99
- # return the name of the element (as defined in html)
100
- def_wrap_guard :name
101
74
  # return the id of the element
102
- def_wrap_guard :id
103
- # return whether the element is disabled
104
- def_wrap :disabled
105
- alias disabled? disabled
106
- # return the value of the element
107
- def_wrap_guard :value
75
+ attr_ole :id
108
76
  # return the title of the element
109
- def_wrap_guard :title
110
-
111
- def_wrap_guard :alt
112
- def_wrap_guard :src
113
-
114
- # return the type of the element
115
- def_wrap_guard :type # input elements only
116
- # return the url the link points to
117
- def_wrap :href # link only
77
+ attr_ole :title
118
78
  # return the class name of the element
119
79
  # raise an ObjectNotFound exception if the object cannot be found
120
- def_wrap :class_name, :className
80
+ attr_ole :class_name, :className
121
81
  # return the unique COM number for the element
122
- def_wrap :unique_number, :uniqueNumber
82
+ attr_ole :unique_number, :uniqueNumber
123
83
  # Return the outer html of the object - see http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/outerhtml.asp?frame=true
124
- def_wrap :html, :outerHTML
125
- # Return the "for" attribute for label
126
- def_wrap_guard :for, :htmlFor
127
- # Return the content attribute for meta tag
128
- def_wrap_guard :content
129
- # Return the http-equiv attribute for meta tag
130
- def_wrap_guard :http_equiv, :httpEquiv
131
- # Return font tag attributes
132
- def_wrap_guard :color
133
- def_wrap_guard :face
134
- def_wrap_guard :size
135
- # Return option label attribute
136
- def_wrap_guard :label
137
- # Return table rules attribute
138
- def_wrap_guard :rules
139
- # Return td headers attribute
140
- def_wrap_guard :headers
84
+ attr_ole :html, :outerHTML
141
85
 
142
86
  def tag_name
143
87
  assert_exists
@@ -150,50 +94,33 @@ module Watir
150
94
 
151
95
  tag = tag_name
152
96
  if tag == "html"
153
- html_element(:ole_object, ole_object)
97
+ element(:ole_object => ole_object)
154
98
  elsif tag == "input"
155
- self.send(ole_object.invoke('type'), :ole_object, ole_object)
99
+ send(ole_object.invoke('type'), :ole_object => ole_object)
156
100
  elsif tag == "select"
157
- self.select_list(:ole_object, ole_object)
158
- elsif self.respond_to?(tag.downcase)
159
- self.send(tag.downcase, :ole_object, ole_object)
101
+ select_list(:ole_object => ole_object)
102
+ elsif respond_to?(tag.downcase)
103
+ send(tag.downcase, :ole_object => ole_object)
160
104
  else
161
105
  self
162
106
  end
163
107
  end
164
108
 
165
109
  # send keys to element
166
- def send_keys(key_string)
110
+ def send_keys(*keys)
167
111
  focus
168
- page_container.send_keys key_string
112
+ page_container.send_keys *keys
169
113
  end
170
114
 
171
115
  # return the css style as a string
172
116
  def style
173
117
  assert_exists
118
+ # this works for IE9
119
+ ole_object.currentStyle.cssText
120
+ rescue WIN32OLERuntimeError
174
121
  ole_object.style.cssText
175
122
  end
176
123
 
177
- # return the text before the element
178
- def before_text # label only
179
- assert_exists
180
- begin
181
- ole_object.getAdjacentText("afterEnd").strip
182
- rescue
183
- ''
184
- end
185
- end
186
-
187
- # return the text after the element
188
- def after_text # label only
189
- assert_exists
190
- begin
191
- ole_object.getAdjacentText("beforeBegin").strip
192
- rescue
193
- ''
194
- end
195
- end
196
-
197
124
  # Return the innerText of the object or an empty string if the object is
198
125
  # not visible
199
126
  # Raise an ObjectNotFound exception if the object cannot be found
@@ -202,20 +129,14 @@ module Watir
202
129
  visible? ? ole_object.innerText.strip : ""
203
130
  end
204
131
 
205
- # IE9 only returns empty string for ole_object.name for non-input elements
206
- # so get at it through the attribute which will make the matchers work
207
- def name
208
- attribute_value('name') || ''
209
- end
210
-
211
132
  def __ole_inner_elements
212
133
  assert_exists
213
- return ole_object.all
134
+ ole_object.all
214
135
  end
215
136
 
216
137
  def document
217
138
  assert_exists
218
- return ole_object
139
+ ole_object
219
140
  end
220
141
 
221
142
  # Return the element immediately containing self.
@@ -223,33 +144,15 @@ module Watir
223
144
  assert_exists
224
145
  parent_element = ole_object.parentelement
225
146
  return unless parent_element
226
- result = Element.new(parent_element).to_subtype
227
- result.set_container self
228
- result
147
+ Element.new(self, :ole_object => parent_element).to_subtype
229
148
  end
230
149
 
231
- include Comparable
232
-
233
- def <=> other
234
- assert_exists
235
- other.assert_exists
236
- ole_object.sourceindex <=> other.ole_object.sourceindex
237
- end
238
-
239
- alias_method :eql?, :==
240
-
241
- # Return true if self is contained earlier in the html than other.
242
- alias :before? :<
243
- # Return true if self is contained later in the html than other.
244
- alias :after? :>
245
-
246
150
  def typingspeed
247
151
  @container.typingspeed
248
152
  end
249
153
 
250
154
  def type_keys
251
- return @container.type_keys if @type_keys.nil?
252
- @type_keys
155
+ @type_keys || @container.type_keys
253
156
  end
254
157
 
255
158
  def activeObjectHighLightColor
@@ -259,11 +162,7 @@ module Watir
259
162
  # Return an array with many of the properties, in a format to be used by the to_s method
260
163
  def string_creator
261
164
  n = []
262
- n << "type:".ljust(TO_S_SIZE) + self.type
263
165
  n << "id:".ljust(TO_S_SIZE) + self.id.to_s
264
- n << "name:".ljust(TO_S_SIZE) + self.name.to_s
265
- n << "value:".ljust(TO_S_SIZE) + self.value.to_s
266
- n << "disabled:".ljust(TO_S_SIZE) + self.disabled.to_s
267
166
  return n
268
167
  end
269
168
 
@@ -344,11 +243,13 @@ module Watir
344
243
  private :build_method
345
244
 
346
245
  def generate_ruby_code(element, method_name, *args)
347
- element = "#{self.class}.new(#{@page_container.attach_command}, :unique_number, #{self.unique_number})"
246
+ # needs to be done like this to avoid segfault on ruby 1.9.3
247
+ tag_name = @specifiers[:tag_name].join("' << '")
248
+ element = "#{self.class}.new(#{@page_container.attach_command}, :tag_name => Array.new << '#{tag_name}', :unique_number => #{unique_number})"
348
249
  method = build_method(method_name, *args)
349
250
  ruby_code = "$:.unshift(#{$LOAD_PATH.map {|p| "'#{p}'" }.join(").unshift(")});" <<
350
251
  "require '#{File.expand_path(File.dirname(__FILE__))}/core';#{element}.#{method};"
351
- return ruby_code
252
+ ruby_code
352
253
  end
353
254
 
354
255
  private :generate_ruby_code
@@ -400,12 +301,8 @@ module Watir
400
301
  def dispatch_event(event)
401
302
  assert_exists
402
303
 
403
- if IE.version_parts.first.to_i >= 9
404
- if @container.page_container.document_mode.to_i >= 9
405
- ole_object.dispatchEvent(create_event(event))
406
- else
407
- ole_object.fireEvent(event)
408
- end
304
+ if IE.version_parts.first.to_i >= 9 && container.page_container.document.documentMode.to_i >= 9
305
+ ole_object.dispatchEvent(create_event(event))
409
306
  else
410
307
  ole_object.fireEvent(event)
411
308
  end
@@ -477,7 +374,12 @@ module Watir
477
374
  # raises: UnknownObjectException if the object is not found
478
375
  def enabled?
479
376
  assert_exists
480
- !disabled
377
+ !disabled?
378
+ end
379
+
380
+ def disabled?
381
+ assert_exists
382
+ false
481
383
  end
482
384
 
483
385
  # If any parent element isn't visible then we cannot write to the