watir 3.0.0.rc1 → 3.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,4 +1,12 @@
1
- == 3.0.0 - 2012/01/13 - more conformance with WatirSpec
1
+ == 3.0.0.rc2 - 2012/02/04
2
+
3
+ * Browser#textarea(s) method for searching <textarea> elements
4
+ * Element#focus works with IE9
5
+ * Element#focused? returns the state of focus on that element
6
+ * Element#to_subtype returns Element if non-supported tag found instead of crashing
7
+ * searching by :class will match now partially like other tools behave (e.g. jQuery)
8
+
9
+ == 3.0.0.rc1 - 2012/01/13 - more conformance with WatirSpec
2
10
 
3
11
  * Button#text returns value if exists instead of text
4
12
  * Browser#goto prepends url automatically with http:// if scheme is missing
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.0.rc1
1
+ 3.0.0.rc2
@@ -23,7 +23,7 @@ module Watir
23
23
  def element_tag; 'SELECT'; end
24
24
  end
25
25
 
26
- %w[Button FileField Radio TextField Hidden].each do |element|
26
+ %w[Button FileField Radio TextField TextArea Hidden].each do |element|
27
27
  module_eval %Q{
28
28
  class #{element}s < InputElementCollections; end
29
29
  }
@@ -56,20 +56,24 @@ module Watir
56
56
  private
57
57
  def self.def_wrap(method_name, ole_method_name=nil)
58
58
  class_eval "def #{method_name}
59
- assert_exists
60
- ole_object.invoke('#{ole_method_name || method_name}')
61
- end"
59
+ assert_exists
60
+ ole_object.invoke('#{ole_method_name || method_name}')
61
+ end"
62
62
  end
63
63
 
64
64
  def self.def_wrap_guard(method_name, ole_method_name = nil)
65
65
  class_eval "def #{method_name}
66
- assert_exists
67
- begin
68
- ole_object.invoke('#{ole_method_name || method_name}')
69
- rescue
70
- ''
71
- end
72
- end"
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"
73
77
  end
74
78
 
75
79
 
@@ -151,8 +155,10 @@ module Watir
151
155
  self.send(ole_object.invoke('type'), :ole_object, ole_object)
152
156
  elsif tag == "select"
153
157
  self.select_list(:ole_object, ole_object)
154
- else
158
+ elsif self.respond_to?(tag.downcase)
155
159
  self.send(tag.downcase, :ole_object, ole_object)
160
+ else
161
+ self
156
162
  end
157
163
  end
158
164
 
@@ -416,6 +422,10 @@ module Watir
416
422
  event_name = :initEvent
417
423
  event_type = 'HTMLEvents'
418
424
  event_args = [event, true, true]
425
+ when 'select'
426
+ event_name = :initUIEvent
427
+ event_type = 'UIEvent'
428
+ event_args = [event, true, true, @container.page_container.document.parentWindow.window,0]
419
429
  when 'keydown', 'keypress', 'keyup'
420
430
  event_name = :initKeyboardEvent
421
431
  event_type = 'KeyboardEvent'
@@ -442,7 +452,13 @@ module Watir
442
452
  assert_exists
443
453
  assert_enabled
444
454
  @page_container.focus
445
- ole_object.focus
455
+ ole_object.focus(0)
456
+ end
457
+
458
+ def focused?
459
+ assert_exists
460
+ assert_enabled
461
+ @page_container.document.activeElement.uniqueNumber == unique_number
446
462
  end
447
463
 
448
464
  # Returns whether this element actually exists.
@@ -41,7 +41,7 @@ module Watir
41
41
  # Submit the data -- equivalent to pressing Enter or Return to submit a form.
42
42
  def submit
43
43
  assert_exists
44
- @o.submit if dispatch_event "onSubmit"
44
+ @o.submit(0) if dispatch_event "onSubmit"
45
45
  @container.wait
46
46
  end
47
47
 
@@ -55,9 +55,7 @@ module Watir
55
55
  wrapper = "_watir_helper_div_#{Time.now.to_i}"
56
56
  cmd = "var e = document.createElement('DIV'); e.style.display = 'none'; e.id='#{wrapper}'; e.innerHTML = eval('#{escaped_src}'); document.body.appendChild(e);"
57
57
  document.parentWindow.execScript(cmd)
58
- wrapper_obj = document.getElementById(wrapper)
59
- result_value = wrapper_obj.innerHTML
60
- result_value
58
+ document.getElementById(wrapper).wrapper_obj.innerHTML
61
59
  end
62
60
 
63
61
  end
@@ -417,12 +417,9 @@ module Watir
417
417
  rescue WIN32OLERuntimeError, NoMethodError #if eval fails we need to use execScript(source.to_s) which does not return a value, hence the workaround
418
418
  escaped_src = source.to_s.gsub(/[\r\n']/) {|m| "\\#{m}"}
419
419
  wrapper = "_watir_helper_div_#{rand(100000)}"
420
- cmd = "var e = document.createElement('DIV'); e.id='#{wrapper}'; e.innerHTML = eval('#{escaped_src}'); document.body.appendChild(e);"
420
+ cmd = "var e = document.createElement('DIV'); e.style.display='none'; e.id='#{wrapper}'; e.innerHTML = eval('#{escaped_src}'); document.body.appendChild(e);"
421
421
  document.parentWindow.execScript(cmd)
422
- wrapper_obj = document.getElementById(wrapper)
423
- result_value = wrapper_obj.innerHTML
424
- wrapper_obj.style.display = 'none'
425
- result_value
422
+ document.getElementById(wrapper).innerHTML
426
423
  end
427
424
 
428
425
  # clear the list of urls that we have visited
@@ -6,7 +6,8 @@ module Watir
6
6
  def self.start
7
7
  program_files = ENV['ProgramFiles'] || "c:\\Program Files"
8
8
  startup_command = "#{program_files}\\Internet Explorer\\iexplore.exe"
9
- startup_command << " -nomerge" if IE.version_parts.first.to_i >= 8
9
+ startup_command << " -nomerge" if IE.version_parts.first.to_i == 8
10
+ startup_command << " -noframemerging" if IE.version_parts.first.to_i >= 9
10
11
  process_info = ::Process.create('app_name' => "#{startup_command} about:blank")
11
12
  process_id = process_info.process_id
12
13
  new process_id
@@ -237,8 +237,8 @@ module Watir
237
237
  raise UnknownObjectException, "Unable to locate destination using #{destination_how } and #{destination_what } "
238
238
  end
239
239
 
240
- @o.focus
241
- @o.select
240
+ @o.focus(0)
241
+ @o.select(0)
242
242
  value = self.value
243
243
 
244
244
  dispatch_event("onSelect")
@@ -265,8 +265,8 @@ module Watir
265
265
  highlight(:set)
266
266
 
267
267
  @o.scrollIntoView
268
- @o.focus
269
- @o.select
268
+ @o.focus(0)
269
+ @o.select(0)
270
270
  dispatch_event("onSelect")
271
271
  @o.value = ""
272
272
  dispatch_event("onKeyPress")
@@ -286,7 +286,7 @@ module Watir
286
286
 
287
287
  highlight(:set)
288
288
  @o.scrollIntoView
289
- @o.focus
289
+ @o.focus(0)
290
290
  type_by_character(value)
291
291
  highlight(:clear)
292
292
  end
@@ -303,8 +303,8 @@ module Watir
303
303
  highlight(:set)
304
304
  @o.scrollIntoView
305
305
  if type_keys
306
- @o.focus
307
- @o.select
306
+ @o.focus(0)
307
+ @o.select(0)
308
308
  dispatch_event("onSelect")
309
309
  dispatch_event("onKeyPress")
310
310
  @o.value = ""
@@ -335,6 +335,10 @@ module Watir
335
335
  self
336
336
  end
337
337
 
338
+ def label
339
+ @container.label(:for => name).text
340
+ end
341
+
338
342
  private
339
343
 
340
344
  # Type the characters in the specified string (value) one by one.
@@ -375,8 +379,19 @@ module Watir
375
379
  value
376
380
  end
377
381
 
378
- def label
379
- @container.label(:for => name).text
382
+ end
383
+
384
+ class TextArea < TextField
385
+ INPUT_TYPES = ["textarea"]
386
+
387
+ Watir::Container.module_eval do
388
+ def textareas(how={}, what=nil)
389
+ TextAreas.new(self, how, what)
390
+ end
391
+
392
+ def textarea(how={}, what=nil)
393
+ TextArea.new(self, how, what)
394
+ end
380
395
  end
381
396
  end
382
397
 
@@ -54,11 +54,28 @@ module Watir
54
54
  return true if has_excluding_specifiers?
55
55
  @specifiers.all? do |how, what|
56
56
  how == :index ||
57
- (how.to_s =~ /^data_.*/ && element.send(how) == what) ||
58
- match?(element, how, what)
57
+ (how == :class_name && match_class?(element, what)) ||
58
+ match?(element, how, what)
59
59
  end
60
60
  end
61
61
 
62
+ def match_class? element, what
63
+ classes = element.class_name.split(/\s+/)
64
+ classes.any? {|clazz| what.matches(clazz)}
65
+ end
66
+
67
+ # return true if the element matches the provided how and what
68
+ def match? element, how, what
69
+ begin
70
+ attribute = element.send(how)
71
+ rescue NoMethodError
72
+ raise MissingWayOfFindingObjectException,
73
+ "#{how} is an unknown way of finding a <#{@tags.join(", ")}> element (#{what})"
74
+ end
75
+
76
+ what.matches(attribute)
77
+ end
78
+
62
79
  def has_excluding_specifiers?
63
80
  @specifiers.keys.any? {|specifier| [:css, :xpath, :ole_object].include? specifier}
64
81
  end
@@ -140,25 +157,6 @@ module Watir
140
157
  end # elements
141
158
  nil
142
159
  end
143
-
144
- def match?(element, how, what)
145
- begin
146
- method = element.method(how)
147
- rescue NameError
148
- raise MissingWayOfFindingObjectException,
149
- "#{how} is an unknown way of finding a <#{@tags.join(", ")}> element (#{what})"
150
- end
151
- case method.arity
152
- when 0
153
- what.matches method.call
154
- when 1
155
- method.call(what)
156
- else
157
- raise MissingWayOfFindingObjectException,
158
- "#{how} is an unknown way of finding a <#{@tags.join(", ")}> element (#{what})"
159
- end
160
- end
161
-
162
160
  end
163
161
 
164
162
  class FrameLocator < TaggedElementLocator
@@ -227,18 +225,6 @@ module Watir
227
225
  nil
228
226
  end
229
227
 
230
- # return true if the element matches the provided how and what
231
- def match? element, how, what
232
- begin
233
- attribute = element.send(how)
234
- rescue NoMethodError
235
- raise MissingWayOfFindingObjectException,
236
- "#{how} is an unknown way of finding an <INPUT> element (#{what})"
237
- end
238
-
239
- what.matches(attribute)
240
- end
241
-
242
228
  private
243
229
 
244
230
  def locate_by_name
@@ -14,7 +14,7 @@ module Watir
14
14
  @o.rows.each do |row|
15
15
  cells_memo = []
16
16
  row.cells.each do |cell|
17
- cells_memo << TableCell.new(self, :ole_object, cell).text
17
+ cells_memo << TableCell.new(self, :ole_object, cell).text.gsub("\r\n","")
18
18
  end
19
19
  rows_memo << cells_memo
20
20
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424119
4
+ hash: 15424113
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
9
  - 0
10
10
  - rc
11
- - 1
12
- version: 3.0.0.rc1
11
+ - 2
12
+ version: 3.0.0.rc2
13
13
  platform: ruby
14
14
  authors:
15
15
  - Bret Pettichord
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-01-13 00:00:00 Z
20
+ date: 2012-02-04 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: win32-process
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "="
61
61
  - !ruby/object:Gem::Version
62
- hash: 15424119
62
+ hash: 15424113
63
63
  segments:
64
64
  - 3
65
65
  - 0
66
66
  - 0
67
67
  - rc
68
- - 1
69
- version: 3.0.0.rc1
68
+ - 2
69
+ version: 3.0.0.rc2
70
70
  type: :runtime
71
71
  version_requirements: *id003
72
72
  - !ruby/object:Gem::Dependency