watir 1.5.4 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/bin/watir-console +1 -0
  2. data/changes.rb +16 -2
  3. data/readme.rb +2 -16
  4. data/unittests/buttons_test.rb +74 -101
  5. data/unittests/buttons_xpath_test.rb +3 -3
  6. data/unittests/checkbox_test.rb +3 -3
  7. data/unittests/checkbox_xpath_test.rb +3 -3
  8. data/unittests/core_tests.rb +1 -1
  9. data/unittests/css_test.rb +2 -7
  10. data/unittests/defer_test.rb +2 -2
  11. data/unittests/dialog_test.rb +2 -2
  12. data/unittests/div2_xpath_test.rb +1 -1
  13. data/unittests/div_test.rb +122 -121
  14. data/unittests/div_xpath_test.rb +3 -3
  15. data/unittests/errorchecker_test.rb +3 -8
  16. data/unittests/filefield_test.rb +4 -7
  17. data/unittests/filefield_xpath_test.rb +3 -5
  18. data/unittests/form_test.rb +7 -7
  19. data/unittests/form_xpath_test.rb +6 -6
  20. data/unittests/frame_test.rb +8 -9
  21. data/unittests/google_form_test.rb +1 -2
  22. data/unittests/html/div.html +7 -1
  23. data/unittests/html/lists.html +1 -1
  24. data/unittests/ie_mock.rb +4 -2
  25. data/unittests/ie_test.rb +2 -2
  26. data/unittests/images_test.rb +2 -2
  27. data/unittests/images_xpath_test.rb +2 -2
  28. data/unittests/links_multi_test.rb +23 -9
  29. data/unittests/links_test.rb +7 -7
  30. data/unittests/links_xpath_test.rb +2 -3
  31. data/unittests/lists_test.rb +6 -3
  32. data/unittests/map_test.rb +1 -2
  33. data/unittests/minmax_test.rb +4 -5
  34. data/unittests/navigate_test.rb +18 -23
  35. data/unittests/nbsp_xpath_test.rb +4 -5
  36. data/unittests/{screen_capture_test.rb → other/screen_capture_test.rb} +1 -1
  37. data/unittests/pagecontainstext_test.rb +3 -4
  38. data/unittests/parent_child_test.rb +1 -1
  39. data/unittests/pre_test.rb +2 -3
  40. data/unittests/radios_test.rb +13 -17
  41. data/unittests/radios_xpath_test.rb +3 -3
  42. data/unittests/selectbox_test.rb +6 -14
  43. data/unittests/selectbox_xpath_test.rb +3 -3
  44. data/unittests/setup.rb +30 -10
  45. data/unittests/speed_settings_test.rb +2 -3
  46. data/unittests/table_cell_using_xpath_test.rb +2 -7
  47. data/unittests/table_test.rb +144 -136
  48. data/unittests/table_xpath_test.rb +5 -9
  49. data/unittests/textarea_test.rb +3 -7
  50. data/unittests/textarea_xpath_test.rb +5 -9
  51. data/unittests/textfield_for_ch_char_test.rb +1 -1
  52. data/unittests/textfields_test.rb +3 -4
  53. data/unittests/textfields_xpath_test.rb +3 -3
  54. data/unittests/windows/attach_to_existing_window_test.rb +2 -2
  55. data/unittests/windows/attach_to_new_window_test.rb +2 -2
  56. data/unittests/windows/close_window_test.rb +2 -3
  57. data/unittests/windows/frame_links_test.rb +1 -1
  58. data/unittests/windows/iedialog_test.rb +3 -3
  59. data/unittests/windows/js_events_test.rb +2 -4
  60. data/unittests/windows/modal_dialog_test.rb +2 -2
  61. data/unittests/windows/send_keys_test.rb +2 -4
  62. data/watir.rb +4 -13
  63. data/watir/assertions.rb +9 -1
  64. data/watir/collections.rb +6 -11
  65. data/watir/container.rb +9 -99
  66. data/watir/cookiemanager.rb +4 -1
  67. data/watir/element.rb +8 -1
  68. data/watir/ie.rb +2 -2
  69. data/watir/input_elements.rb +2 -2
  70. data/watir/non_control_elements.rb +39 -2
  71. data/watir/page-container.rb +1 -1
  72. data/watir/table.rb +25 -23
  73. metadata +68 -54
  74. data/watir/bonus-elements.rb +0 -65
  75. data/watir/testUnitAddons.rb +0 -8
@@ -1,4 +1,7 @@
1
- require 'find'
1
+ # should be moved to watir/contrib
2
+ # use of modules here is ugly
3
+
4
+ require 'find'
2
5
  module Watir
3
6
  module CookieManager
4
7
 
@@ -41,12 +41,19 @@ module Watir
41
41
  end
42
42
  end"
43
43
  end
44
+ # return a message indicating how the element is being located
45
+ def located_using_message
46
+ result = "using #{@how.inspect}"
47
+ result << ", #{@what.inspect}" if @what
48
+ result
49
+ end
44
50
 
45
51
  public
46
52
  def assert_exists
47
53
  locate if defined?(locate)
48
54
  unless ole_object
49
- raise UnknownObjectException.new("Unable to locate object, using #{@how} and #{@what}")
55
+ raise UnknownObjectException.new(
56
+ "Unable to locate element, #{located_using_message}")
50
57
  end
51
58
  end
52
59
  def assert_enabled
@@ -57,7 +57,7 @@ module Watir
57
57
  REVISION = $1 or 'unknown'
58
58
 
59
59
  # The Release number
60
- VERSION_SHORT = '1.5.4'
60
+ VERSION_SHORT = '1.5.5'
61
61
  VERSION = VERSION_SHORT + '.' + REVISION
62
62
 
63
63
  # Used internally to determine when IE has finished loading a page
@@ -492,7 +492,7 @@ module Watir
492
492
  until doc.readyState == "complete" do
493
493
  sleep a_moment
494
494
  end
495
- @url_list << doc.url unless @url_list.include?(doc.url)
495
+ @url_list << doc.location.href unless @url_list.include?(doc.location.href)
496
496
  doc.frames.length.times do |n|
497
497
  begin
498
498
  documents_to_wait_for << doc.frames[n.to_s].document
@@ -252,7 +252,7 @@ module Watir
252
252
  def verify_contains(target) # FIXME: verify_contains should have same name and semantics as IE#contains_text (prolly make this work for all elements)
253
253
  assert_exists
254
254
  if target.kind_of? String
255
- return true if self.value == target
255
+ return true if self.value == target
256
256
  elsif target.kind_of? Regexp
257
257
  return true if self.value.match(target) != nil
258
258
  end
@@ -440,7 +440,7 @@ module Watir
440
440
  WindowHelper.check_autoit_installed
441
441
  begin
442
442
  thrd = Thread.new do
443
- system("rubyw -e \"require 'win32ole'; @autoit=WIN32OLE.new('AutoItX3.Control'); waitresult=@autoit.WinWait 'Choose file', '', 15; if waitresult == 1\" -e \"@autoit.ControlSetText 'Choose file', '', 'Edit1', '#{setPath}'; @autoit.ControlSend 'Choose file', '', 'Button2', '{ENTER}';\" -e \"end\"")
443
+ system("rubyw -e \"require 'win32ole'; @autoit=WIN32OLE.new('AutoItX3.Control'); waitresult=@autoit.WinWait 'Choose file', '', 15; sleep 1; if waitresult == 1\" -e \"@autoit.ControlSetText 'Choose file', '', 'Edit1', '#{setPath}'; @autoit.ControlSend 'Choose file', '', 'Button2', '{ENTER}';\" -e \"end\"")
444
444
  end
445
445
  thrd.join(1)
446
446
  rescue
@@ -1,3 +1,4 @@
1
+ require 'active_support'
1
2
  module Watir
2
3
 
3
4
  # this class contains items that are common between the span, div, and pre objects
@@ -6,8 +7,14 @@ module Watir
6
7
  # many of the methods available to this object are inherited from the Element class
7
8
  #
8
9
  class NonControlElement < Element
10
+ def self.inherited subclass
11
+ class_name = subclass.to_s.demodulize
12
+ method_name = class_name.underscore
13
+ Watir::Container.module_eval "def #{method_name}(how, what=nil)
14
+ return #{class_name}.new(self, how, what); end"
15
+ end
9
16
  include Watir::Exception
10
-
17
+
11
18
  def locate
12
19
  if @how == :xpath
13
20
  @o = @container.element_by_xpath(@what)
@@ -41,6 +48,7 @@ module Watir
41
48
  return r.join("\n")
42
49
  end
43
50
  end
51
+
44
52
 
45
53
  class Pre < NonControlElement
46
54
  TAG = 'PRE'
@@ -61,6 +69,14 @@ module Watir
61
69
  TAG = 'SPAN'
62
70
  end
63
71
 
72
+ class Map < NonControlElement
73
+ TAG = 'MAP'
74
+ end
75
+
76
+ class Area < NonControlElement
77
+ TAG = 'AREA'
78
+ end
79
+
64
80
  # Accesses Label element on the html page - http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/label.asp?frame=true
65
81
  class Label < NonControlElement
66
82
  TAG = 'LABEL'
@@ -87,5 +103,26 @@ module Watir
87
103
  class Li < NonControlElement
88
104
  TAG = 'LI'
89
105
  end
90
-
106
+ class Ul < NonControlElement
107
+ TAG = 'UL'
108
+ end
109
+ class H1 < NonControlElement
110
+ TAG = 'H1'
111
+ end
112
+ class H2 < NonControlElement
113
+ TAG = 'H2'
114
+ end
115
+ class H3 < NonControlElement
116
+ TAG = 'H3'
117
+ end
118
+ class H4 < NonControlElement
119
+ TAG = 'H4'
120
+ end
121
+ class H5 < NonControlElement
122
+ TAG = 'H5'
123
+ end
124
+ class H6 < NonControlElement
125
+ TAG = 'H6'
126
+ end
127
+
91
128
  end
@@ -17,7 +17,7 @@ module Watir
17
17
  end
18
18
  else
19
19
  # assume its IE6
20
- url = self.document.url
20
+ url = self.document.location.href
21
21
  if /shdoclc.dll/.match(url)
22
22
  m = /id=IEText.*?>(.*?)</i.match(self.html)
23
23
  raise NavigationException, m[1] if m
@@ -8,12 +8,12 @@ module Watir
8
8
  class Table < Element
9
9
  include Container
10
10
 
11
- # Returns the table object containing anElement
11
+ # Returns the table object containing the element
12
12
  # * container - an instance of an IE object
13
13
  # * anElement - a Watir object (TextField, Button, etc.)
14
- def Table.create_from_element(container, anElement)
15
- anElement.locate if defined?(anElement.locate)
16
- o = anElement.ole_object.parentElement
14
+ def Table.create_from_element(container, element)
15
+ element.locate if defined?(element.locate)
16
+ o = element.ole_object.parentElement
17
17
  o = o.parentElement until o.tagName == 'TABLE'
18
18
  new container, :ole_object, o
19
19
  end
@@ -42,7 +42,6 @@ module Watir
42
42
  # override the highlight method, as if the tables rows are set to have a background color,
43
43
  # this will override the table background color, and the normal flash method won't work
44
44
  def highlight(set_or_clear)
45
-
46
45
  if set_or_clear == :set
47
46
  begin
48
47
  @original_border = @o.border.to_i
@@ -70,8 +69,8 @@ module Watir
70
69
  # this method is used to populate the properties in the to_s method
71
70
  def table_string_creator
72
71
  n = []
73
- n << "rows:".ljust(TO_S_SIZE) + self.row_count.to_s
74
- n << "cols:".ljust(TO_S_SIZE) + self.column_count.to_s
72
+ n << "rows:".ljust(TO_S_SIZE) + self.row_count.to_s
73
+ n << "cols:".ljust(TO_S_SIZE) + self.column_count.to_s
75
74
  return n
76
75
  end
77
76
  private :table_string_creator
@@ -88,14 +87,16 @@ module Watir
88
87
  # iterates through the rows in the table. Yields a TableRow object
89
88
  def each
90
89
  assert_exists
91
- 1.upto(@o.getElementsByTagName("TR").length) { |i| yield TableRow.new(@container, :ole_object, row(i)) }
90
+ 1.upto(@o.getElementsByTagName("TR").length) do |i|
91
+ yield TableRow.new(@container, :ole_object, _row(i))
92
+ end
92
93
  end
93
94
 
94
95
  # Returns a row in the table
95
96
  # * index - the index of the row
96
97
  def [](index)
97
98
  assert_exists
98
- return TableRow.new(@container, :ole_object, row(index))
99
+ return TableRow.new(@container, :ole_object, _row(index))
99
100
  end
100
101
 
101
102
  # This method returns the number of rows in the table.
@@ -111,10 +112,11 @@ module Watir
111
112
  # * index - the index of the row
112
113
  def column_count(index=1)
113
114
  assert_exists
114
- row(index).cells.length
115
+ _row(index).cells.length
115
116
  end
116
117
 
117
- # This method returns the table as a 2 dimensional array. Dont expect too much if there are nested tables, colspan etc.
118
+ # This method returns the table as a 2 dimensional array.
119
+ # Don't expect too much if there are nested tables, colspan etc.
118
120
  # Raises an UnknownObjectException if the table doesn't exist.
119
121
  # http://www.w3.org/TR/html4/struct/tables.html
120
122
  def to_a
@@ -148,10 +150,10 @@ module Watir
148
150
  end
149
151
 
150
152
  # returns an ole object
151
- def row(index)
152
- return @o.invoke("rows")[(index-1).to_s]
153
+ def _row(index)
154
+ return @o.invoke("rows")[(index - 1).to_s]
153
155
  end
154
- private :row
156
+ private :_row
155
157
 
156
158
  # Returns an array containing all the text values in the specified column
157
159
  # Raises an UnknownCellException if the specified column does not exist in every
@@ -159,15 +161,14 @@ module Watir
159
161
  # row of the table
160
162
  # * columnnumber - column index to extract values from
161
163
  def column_values(columnnumber)
162
-
163
- return(1..row_count).collect {|idx| self[idx][columnnumber].text}
164
+ return (1..row_count).collect {|i| self[i][columnnumber].text}
164
165
  end
165
166
 
166
167
  # Returns an array containing all the text values in the specified row
167
168
  # Raises an UnknownObjectException if the table doesn't exist.
168
169
  # * rownumber - row index to extract values from
169
170
  def row_values(rownumber)
170
- return(1..column_count(rownumber)).collect {|idx| self[rownumber][idx].text}
171
+ return (1..column_count(rownumber)).collect {|i| self[rownumber][i].text}
171
172
  end
172
173
 
173
174
  end
@@ -201,7 +202,9 @@ module Watir
201
202
 
202
203
  # iterates through each of the TableBodies in the Table. Yields a TableBody object
203
204
  def each
204
- 1.upto(@o.tBodies.length) { |i| yield TableBody.new(@container, :ole_object, ole_table_body_at_index(i)) }
205
+ 1.upto(@o.tBodies.length) do |i|
206
+ yield TableBody.new(@container, :ole_object, ole_table_body_at_index(i))
207
+ end
205
208
  end
206
209
 
207
210
  end
@@ -248,9 +251,7 @@ module Watir
248
251
  return @rows.length
249
252
  end
250
253
  end
251
-
252
-
253
- # this class is a table row
254
+
254
255
  class TableRow < Element
255
256
 
256
257
  def locate
@@ -291,7 +292,9 @@ module Watir
291
292
  # Returns an element from the row as a TableCell object
292
293
  def [](index)
293
294
  assert_exists
294
- raise UnknownCellException, "Unable to locate a cell at index #{index}" if @cells.length < index
295
+ if @cells.length < index
296
+ raise UnknownCellException, "Unable to locate a cell at index #{index}"
297
+ end
295
298
  return @cells[(index - 1)]
296
299
  end
297
300
 
@@ -300,7 +303,6 @@ module Watir
300
303
  # def method_missing(aSymbol, *args)
301
304
  # return @o.send(aSymbol, *args)
302
305
  # end
303
-
304
306
  def column_count
305
307
  locate
306
308
  @cells.length
metadata CHANGED
@@ -1,37 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
3
- specification_version: 1
4
2
  name: watir
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.5.4
7
- date: 2008-04-23 00:00:00 -05:00
8
- summary: Automated testing tool for web applications.
9
- require_paths:
10
- - .
11
- email: wtr-general@rubyforge.org
12
- homepage: http://wtr.rubyforge.org/
13
- rubyforge_project: Web Testing with Ruby
14
- description: WATIR is "Web Application Testing in Ruby". Watir (pronounced water) is a free, open-source functional testing tool for automating browser-based tests of web applications. It works with applications written in any language. Watir drives the Internet Explorer browser the same way an end user would. It clicks links, fills in forms, presses buttons. Watir also checks results, such as whether expected text appears on the page, or whether a control is enabled. Watir can test web applications written in any language. Watir is a Ruby library that works with Internet Explorer on Windows.
15
- autorequire: watir
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.5.5
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Bret Pettichord
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-06-09 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: win32-process
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.5.1
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: windows-pr
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - "="
30
+ - !ruby/object:Gem::Version
31
+ version: 0.6.6
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: activesupport
35
+ version_requirement:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
42
+ description: WATIR is "Web Application Testing in Ruby". Watir (pronounced water) is a free, open-source functional testing tool for automating browser-based tests of web applications. It works with applications written in any language. Watir drives the Internet Explorer browser the same way an end user would. It clicks links, fills in forms, presses buttons. Watir also checks results, such as whether expected text appears on the page, or whether a control is enabled. Watir can test web applications written in any language. Watir is a Ruby library that works with Internet Explorer on Windows.
43
+ email: watir-general@groups.google.com
44
+ executables:
45
+ - watir-console
46
+ extensions: []
47
+
48
+ extra_rdoc_files: []
49
+
31
50
  files:
32
51
  - watir.rb
33
52
  - watir/assertions.rb
34
- - watir/bonus-elements.rb
35
53
  - watir/camel_case.rb
36
54
  - watir/clickJSDialog.rb
37
55
  - watir/close_all.rb
@@ -62,7 +80,6 @@ files:
62
80
  - watir/setFileDialog.rb
63
81
  - watir/table.rb
64
82
  - watir/testcase.rb
65
- - watir/testUnitAddons.rb
66
83
  - watir/utils.rb
67
84
  - watir/waiter.rb
68
85
  - watir/watir_simple.rb
@@ -112,7 +129,6 @@ files:
112
129
  - unittests/pre_test.rb
113
130
  - unittests/radios_test.rb
114
131
  - unittests/radios_xpath_test.rb
115
- - unittests/screen_capture_test.rb
116
132
  - unittests/selectbox_test.rb
117
133
  - unittests/selectbox_xpath_test.rb
118
134
  - unittests/setup.rb
@@ -191,6 +207,7 @@ files:
191
207
  - unittests/other/all_tests_concurrent.rb
192
208
  - unittests/other/navigate_exception_test.rb
193
209
  - unittests/other/rexml_unit_test.rb
210
+ - unittests/other/screen_capture_test.rb
194
211
  - unittests/other/testcase_method_order_test.rb
195
212
  - unittests/other/testcase_verify_test.rb
196
213
  - unittests/other/wait_until_test.rb
@@ -221,8 +238,9 @@ files:
221
238
  - readme.rb
222
239
  - changes.rb
223
240
  - license.rb
224
- test_files:
225
- - unittests/core_tests.rb
241
+ has_rdoc: true
242
+ homepage: http://wtr.rubyforge.org/
243
+ post_install_message:
226
244
  rdoc_options:
227
245
  - --title
228
246
  - Watir API Reference
@@ -232,30 +250,26 @@ rdoc_options:
232
250
  - Watir::IE
233
251
  - --exclude
234
252
  - unittests|camel_case.rb|testUnitAddons.rb
235
- extra_rdoc_files: []
236
-
237
- executables:
238
- - watir-console
239
- extensions: []
240
-
253
+ require_paths:
254
+ - .
255
+ required_ruby_version: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - ">="
258
+ - !ruby/object:Gem::Version
259
+ version: "0"
260
+ version:
261
+ required_rubygems_version: !ruby/object:Gem::Requirement
262
+ requirements:
263
+ - - ">="
264
+ - !ruby/object:Gem::Version
265
+ version: "0"
266
+ version:
241
267
  requirements:
242
268
  - Microsoft Windows running Internet Explorer 5.5 or later.
243
- dependencies:
244
- - !ruby/object:Gem::Dependency
245
- name: win32-process
246
- version_requirement:
247
- version_requirements: !ruby/object:Gem::Version::Requirement
248
- requirements:
249
- - - ">="
250
- - !ruby/object:Gem::Version
251
- version: 0.5.1
252
- version:
253
- - !ruby/object:Gem::Dependency
254
- name: windows-pr
255
- version_requirement:
256
- version_requirements: !ruby/object:Gem::Version::Requirement
257
- requirements:
258
- - - ">="
259
- - !ruby/object:Gem::Version
260
- version: 0.6.6
261
- version:
269
+ rubyforge_project: Watir
270
+ rubygems_version: 1.1.1
271
+ signing_key:
272
+ specification_version: 2
273
+ summary: Automated testing tool for web applications.
274
+ test_files:
275
+ - unittests/core_tests.rb