watir 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,3 +1,10 @@
1
+ == Version 2.0.3 - 2011/10/21
2
+
3
+ * fix ElementCollections#[]
4
+ * fix IE::Process.start for IE9 when opening multiple windows
5
+ * add support for Spanish JavaScript and file upload dialogs
6
+ * fix IE#execute_script for Ruby 1.9 with IE9
7
+
1
8
  == Version 2.0.2 - 2011/09/10
2
9
 
3
10
  * added support for del, ins, font, meta and ol tags
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.2
1
+ 2.0.3
@@ -21,15 +21,15 @@ module Watir
21
21
  end
22
22
 
23
23
  def open_button
24
- file_upload_window.button(:value => '&Open')
24
+ file_upload_window.button(:value => /&Open|&Abrir/)
25
25
  end
26
26
 
27
27
  def cancel_button
28
- file_upload_window.button(:value => 'Cancel')
28
+ file_upload_window.button(:value => /Cancel/)
29
29
  end
30
30
 
31
31
  def file_upload_window
32
- @window ||= RAutomation::Window.new(:title => /^choose file( to upload)?$/i)
32
+ @window ||= RAutomation::Window.new(:title => /^choose file( to upload)?|Elegir archivos para cargar$/i)
33
33
  end
34
34
 
35
35
  end
@@ -1,7 +1,7 @@
1
1
  module Watir
2
2
 
3
3
  class JavascriptDialog
4
- WINDOW_TITLES = ['Message from webpage', 'Windows Internet Explorer','Microsoft Internet Explorer']
4
+ WINDOW_TITLES = ['Message from webpage', 'Windows Internet Explorer','Microsoft Internet Explorer',/Mensaje de p.*/]
5
5
 
6
6
  def initialize(opts={})
7
7
  @opts = opts
@@ -3,7 +3,7 @@ module Watir
3
3
  # it would normally only be accessed by the iterator methods (spans, links etc) of IE
4
4
  class ElementCollections
5
5
  include Enumerable
6
-
6
+
7
7
  # Super class for all the iteractor classes
8
8
  # * container - an instance of an IE object
9
9
  def initialize(container, how, what)
@@ -19,7 +19,7 @@ module Watir
19
19
  @length = length
20
20
  @page_container = container.page_container
21
21
  end
22
-
22
+
23
23
  def length
24
24
  count = 0
25
25
  each {|element| count += 1 }
@@ -32,14 +32,17 @@ module Watir
32
32
  def each
33
33
  @container.tagged_element_locator(element_tag, @how, @what, element_class).each {|element| yield element}
34
34
  end
35
-
35
+
36
36
  # allows access to a specific item in the collection
37
37
  def [](n)
38
- unless n.between?(0, length - 1)
38
+ number = n - Watir::IE.base_index
39
+ offset = Watir::IE.zero_based_indexing ? (length - 1) : length
40
+
41
+ unless number.between?(0, offset)
39
42
  raise Exception::MissingWayOfFindingObjectException,
40
43
  "Can't find #{element_tag.downcase} with :index #{n} from #{self.class} with size of #{length}"
41
44
  end
42
- return iterator_object(n)
45
+ return iterator_object(number)
43
46
  end
44
47
 
45
48
  def first
@@ -64,7 +67,7 @@ module Watir
64
67
  count = 0
65
68
  each {|e| return e if count == i; count += 1}
66
69
  end
67
-
70
+
68
71
  def element_class
69
72
  Watir.const_get self.class.name.split("::").last.chop
70
73
  end
@@ -420,7 +420,7 @@ module Watir
420
420
  # Execute the given JavaScript string
421
421
  def execute_script(source)
422
422
  document.parentWindow.eval(source.to_s)
423
- rescue WIN32OLERuntimeError #if eval fails we need to use execScript(source.to_s) which does not return a value, hence the workaround
423
+ rescue WIN32OLERuntimeError, NoMethodError #if eval fails we need to use execScript(source.to_s) which does not return a value, hence the workaround
424
424
  wrapper = "_watir_helper_div_#{rand(100000)}"
425
425
  escaped_src = source.to_s
426
426
  escaped_src = escaped_src.gsub("'", "\\\\'")
@@ -6,6 +6,7 @@ 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
10
  process_info = ::Process.create('app_name' => "#{startup_command} about:blank")
10
11
  process_id = process_info.process_id
11
12
  new process_id
@@ -0,0 +1,57 @@
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
+ require 'unittests/setup'
3
+
4
+
5
+ class TC_TestElementCollectionIndexingForOneBasedIndexes < Test::Unit::TestCase
6
+
7
+ def setup
8
+ close_browser
9
+ Watir.options[:zero_based_indexing] = false
10
+ goto_page "zeroindex.html"
11
+ end
12
+
13
+ def teardown
14
+ Watir.options[:zero_based_indexing] = true
15
+ close_browser
16
+ end
17
+
18
+ def test_one_based_index
19
+ assert browser.table(:id, 'a_table').rows.length == 6
20
+
21
+ #row 1
22
+ r = browser.table(:id, 'a_table').rows[1]
23
+ assert r.id == 'first'
24
+
25
+ #something in the middle
26
+ r = browser.table(:id, 'a_table').rows[2]
27
+ assert r.id == 'second'
28
+
29
+ #the last row
30
+ r = browser.table(:id, 'a_table').rows[6]
31
+ assert r.id == 'sixth'
32
+ end
33
+ end
34
+
35
+ class TC_TestElementCollectionIndexingForZeroBasedIndexes < Test::Unit::TestCase
36
+
37
+ def setup
38
+ #currently the watir default is zero based index
39
+ goto_page "zeroindex.html"
40
+ end
41
+
42
+ def test_zero_based_index
43
+ assert browser.table(:id, 'a_table').rows.length == 6
44
+
45
+ #row 1
46
+ r = browser.table(:id, 'a_table').rows[0]
47
+ assert r.id == 'first'
48
+
49
+ #something in the middle
50
+ r = browser.table(:id, 'a_table').rows[2]
51
+ assert r.id == 'third'
52
+
53
+ #last row
54
+ r = browser.table(:id, 'a_table').rows[5]
55
+ assert r.id == 'sixth'
56
+ end
57
+ end
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
+ <html>
3
+ <table id="a_table">
4
+ <tr id="first"><td>alt_1 - boring text</td></tr>
5
+ <tr id="second"><td>alt_2 - great text</td></tr>
6
+ <tr id="third"><td>alt_1 - the best text ever<td></tr>
7
+ <tr id="fourth"><td>alt_2 - okay text<td></tr>
8
+ <tr id="fifth"><td>alt_1 - supreme text<td></tr>
9
+ <tr id="sixth"><td>alt_2 - middle of the road text<td></tr>
10
+ </table>
11
+ </html>
@@ -0,0 +1,24 @@
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'commonwatir', 'lib')
3
+ require 'test/unit'
4
+ require 'watir/ie'
5
+
6
+ class TC_NewProcess < Test::Unit::TestCase
7
+ def test_new_process_single_window
8
+ assert_nothing_raised {
9
+ ie = Watir::IE.new_process
10
+ ie.goto 'www.yahoo.com'
11
+ ie.close
12
+ }
13
+ end
14
+ def test_new_process_multiple_windows
15
+ assert_nothing_raised {
16
+ ie1 = Watir::IE.new_process
17
+ ie1.goto 'www.yahoo.com'
18
+ ie2 = Watir::IE.new_process
19
+ ie2.goto 'www.google.com'
20
+ ie1.close
21
+ ie2.close
22
+ }
23
+ end
24
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 2
10
- version: 2.0.2
9
+ - 3
10
+ version: 2.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bret Pettichord
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-10 00:00:00 Z
18
+ date: 2011-10-21 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: win32-process
@@ -57,12 +57,12 @@ dependencies:
57
57
  requirements:
58
58
  - - "="
59
59
  - !ruby/object:Gem::Version
60
- hash: 11
60
+ hash: 9
61
61
  segments:
62
62
  - 2
63
63
  - 0
64
- - 2
65
- version: 2.0.2
64
+ - 3
65
+ version: 2.0.3
66
66
  type: :runtime
67
67
  version_requirements: *id003
68
68
  - !ruby/object:Gem::Dependency
@@ -173,6 +173,7 @@ files:
173
173
  - unittests/div_xpath_test.rb
174
174
  - unittests/document_standards.rb
175
175
  - unittests/element_collections_test.rb
176
+ - unittests/element_collection_indexes_test.rb
176
177
  - unittests/element_test.rb
177
178
  - unittests/errorchecker_test.rb
178
179
  - unittests/filefield_test.rb
@@ -282,6 +283,7 @@ files:
282
283
  - unittests/html/textsearch.html
283
284
  - unittests/html/wallofcheckboxes.html
284
285
  - unittests/html/xpath_nbsp.html
286
+ - unittests/html/zeroindex.html
285
287
  - unittests/html/images/1.gif
286
288
  - unittests/html/images/2.GIF
287
289
  - unittests/html/images/3.GIF
@@ -308,6 +310,7 @@ files:
308
310
  - unittests/windows/ie-each_test.rb
309
311
  - unittests/windows/iedialog_test.rb
310
312
  - unittests/windows/modal_dialog_test.rb
313
+ - unittests/windows/new_process_test.rb
311
314
  - unittests/windows/new_test.rb
312
315
  - unittests/windows/open_close_test.rb
313
316
  - unittests/windows/send_keys_test.rb
@@ -355,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
355
358
  requirements:
356
359
  - Microsoft Windows running Internet Explorer 5.5 or later.
357
360
  rubyforge_project: Watir
358
- rubygems_version: 1.8.10
361
+ rubygems_version: 1.8.4
359
362
  signing_key:
360
363
  specification_version: 3
361
364
  summary: Automated testing tool for web applications.