watirsplash 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ === Version 0.2.8 / 2010-10-06
2
+
3
+ * use Watir 1.6.6 and RSpec 1.3.0 from now on
4
+
1
5
  === Version 0.2.7 / 2010-09-27
2
6
 
3
7
  * added explicit dependencies for Watir 1.6.5 and RSpec 1.3.0 so upcoming versions wouldn't break things accidentally
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.7
1
+ 0.2.8
@@ -8,113 +8,12 @@ end
8
8
  # patches for Watir
9
9
  module Watir
10
10
  class IE #:nodoc:all
11
- READYSTATE_INTERACTIVE = 3
12
-
13
11
  include WaitHelper
14
-
15
- # This is Watir's overriden wait method, which is used in many places for deciding
16
- # if browser is ready or not. We have to patch one line in it to work properly
17
- # when file save as dialog has been displayed. For some reason READYSTATE (4)
18
- # property value will be READYSTATE_INTERACTIVE (3) after file has been downloaded
19
- # and not 4, thus wait will stay blocking.
20
- # read more about IE READYSTATE property:
21
- # http://msdn.microsoft.com/en-us/library/aa768362(VS.85).aspx
22
- #
23
- # Block execution until the page has loaded.
24
- # Raises Timeout::Error if page is not loaded within 5 minutes.
25
- # =nodoc
26
- # Note: This code needs to be prepared for the ie object to be closed at
27
- # any moment!
28
- def wait(no_sleep=false)
29
- @xml_parser_doc = nil
30
- @down_load_time = 0.0
31
- a_moment = 0.2 # seconds
32
- start_load_time = Time.now
33
- timeout = 5*60
34
- timeout_error = Timeout::Error.new("Failed to load page within #{timeout} seconds!")
35
- begin
36
- while @ie.busy
37
- sleep a_moment
38
- raise timeout_error if Time.now - start_load_time >= timeout
39
- end
40
- # this is the line which has been changed to accept also state 3
41
- until @ie.readyState == READYSTATE_INTERACTIVE ||
42
- @ie.readyState == READYSTATE_COMPLETE do
43
- sleep a_moment
44
- raise timeout_error if Time.now - start_load_time >= timeout
45
- end
46
- sleep a_moment
47
- until @ie.document do
48
- sleep a_moment
49
- raise timeout_error if Time.now - start_load_time >= timeout
50
- end
51
-
52
- documents_to_wait_for = [@ie.document]
53
-
54
- rescue WIN32OLERuntimeError # IE window must have been closed
55
- @down_load_time = Time.now - start_load_time
56
- sleep @pause_after_wait unless no_sleep
57
- return @down_load_time
58
- end
59
-
60
- while doc = documents_to_wait_for.shift
61
- begin
62
- until doc.readyState == "complete" do
63
- sleep a_moment
64
- raise timeout_error if Time.now - start_load_time >= timeout
65
- end
66
- @url_list << doc.location.href unless @url_list.include?(doc.location.href)
67
- doc.frames.length.times do |n|
68
- begin
69
- documents_to_wait_for << doc.frames[n.to_s].document
70
- rescue WIN32OLERuntimeError, NoMethodError
71
- end
72
- end
73
- rescue WIN32OLERuntimeError
74
- end
75
- end
76
-
77
- @down_load_time = Time.now - start_load_time
78
- run_error_checks
79
- sleep @pause_after_wait unless no_sleep
80
- @down_load_time
81
- end
82
-
83
- # Closes the browser even if #wait throws an exception.
84
- # It happens mostly when #run_error_checks throws some exception.
85
- def close
86
- return unless exists?
87
- @closing = true
88
- @ie.stop
89
- wait rescue nil
90
- chwnd = @ie.hwnd.to_i
91
- @ie.quit
92
- while Win32API.new("user32", "IsWindow", 'L', 'L').Call(chwnd) == 1
93
- sleep 0.3
94
- end
95
- end
96
12
  end
97
13
 
98
14
  class Element #:nodoc:all
99
15
  include ElementExtensions
100
16
 
101
- def_wrap_guard :currentstyle
102
-
103
- # returns current style instead of inline style
104
- # http://msdn.microsoft.com/en-us/library/ms535231(VS.85).aspx
105
- def style
106
- currentstyle
107
- end
108
-
109
- def click_no_wait
110
- assert_enabled
111
-
112
- highlight(:set)
113
- element = "#{self.class}.new(#{@page_container.attach_command}, :unique_number, #{self.unique_number})"
114
- @page_container.click_no_wait(element)
115
- highlight(:clear)
116
- end
117
-
118
17
  # saves a file with the browser
119
18
  #
120
19
  # clicking the button opens a browser's save as dialog and saves the file document.pdf
@@ -146,82 +45,4 @@ module Watir
146
45
  end
147
46
  end
148
47
 
149
- module PageContainer #:nodoc:all
150
- def click_no_wait(element)
151
- ruby_code = "require 'rubygems';" <<
152
- "require '#{File.expand_path(File.dirname(__FILE__))}/watir_core';" <<
153
- "#{element}.click!"
154
- system(spawned_click_no_wait_command(ruby_code))
155
- end
156
-
157
- def spawned_click_no_wait_command(command)
158
- unless $VERBOSE
159
- "start rubyw -e #{command.inspect}"
160
- else
161
- puts "#click_no_wait command:"
162
- command = "ruby -e #{command.inspect}"
163
- puts command
164
- command
165
- end
166
- end
167
-
168
- private :spawned_click_no_wait_command
169
- end
170
-
171
- class Table < Element
172
-
173
- # This method returns multi-dimensional array of the cell texts in table.
174
- #
175
- # Works with tr, th, td elements, colspan, rowspan and nested tables.
176
- # Takes an optional parameter *max_depth*, which is by default 1
177
- def to_a(max_depth=1)
178
- assert_exists
179
- y = []
180
- @o.rows.each do |row|
181
- y << TableRow.new(@container, :ole_object, row).to_a(max_depth)
182
- end
183
- y
184
- end
185
- end
186
-
187
- class TableRow < Element
188
-
189
- # This method returns (multi-dimensional) array of the cell texts in table's row.
190
- #
191
- # Works with th, td elements, colspan, rowspan and nested tables.
192
- # Takes an optional parameter *max_depth*, which is by default 1
193
- def to_a(max_depth=1)
194
- assert_exists
195
- y = []
196
- @o.cells.each do |cell|
197
- inner_tables = cell.getElementsByTagName("TABLE")
198
- inner_tables.each do |inner_table|
199
- # make sure that the inner table is directly child for this cell
200
- if inner_table?(cell, inner_table)
201
- max_depth -= 1
202
- y << Table.new(@container, :ole_object, inner_table).to_a(max_depth) if max_depth >= 1
203
- end
204
- end
205
-
206
- if inner_tables.length == 0
207
- y << cell.innerText.strip
208
- end
209
- end
210
- y
211
- end
212
-
213
- private
214
- # returns true if inner_table is direct child
215
- # table for cell and there's not any table-s in between
216
- def inner_table?(cell, inner_table)
217
- parent_element = inner_table.parentElement
218
- if parent_element.uniqueID == cell.uniqueID
219
- return true
220
- elsif parent_element.tagName == "TABLE"
221
- return false
222
- else
223
- return inner_table?(cell, parent_element)
224
- end
225
- end
226
- end
227
48
  end
data/lib/watirsplash.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require "rubygems"
2
2
  require "require_all"
3
+ gem "rspec", "=1.3.0"
3
4
  require "spec"
5
+ gem "watir", "=1.6.6"
4
6
  require "watir"
5
7
  require "pathname"
6
8
  require_rel "watirsplash/wait_helper"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watirsplash
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 7
10
- version: 0.2.7
9
+ - 8
10
+ version: 0.2.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jarmo Pertman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-27 00:00:00 +03:00
18
+ date: 2010-10-06 00:00:00 +03:00
19
19
  default_executable: watirsplash
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -164,7 +164,6 @@ files:
164
164
  - lib/watirsplash/util.rb
165
165
  - lib/watirsplash/wait_helper.rb
166
166
  - lib/watirsplash/watir.rb
167
- - lib/watirsplash/watir_core.rb
168
167
  - spec/spec.opts
169
168
  - spec/spec_helper_spec.rb
170
169
  - spec/spec_match_array_spec.rb
@@ -188,7 +187,7 @@ licenses: []
188
187
  post_install_message: |-
189
188
  *************************
190
189
 
191
- Thank you for installing WatirSplash 0.2.7! Don't forget to take a look at README and History files!
190
+ Thank you for installing WatirSplash 0.2.8! Don't forget to take a look at README and History files!
192
191
 
193
192
  Execute "watirsplash generate" under your project's directory to generate default project structure.
194
193
 
@@ -227,7 +226,7 @@ rubyforge_project:
227
226
  rubygems_version: 1.3.7
228
227
  signing_key:
229
228
  specification_version: 3
230
- summary: watirsplash 0.2.7
229
+ summary: watirsplash 0.2.8
231
230
  test_files:
232
231
  - spec/spec_helper_spec.rb
233
232
  - spec/spec_match_array_spec.rb
@@ -1,79 +0,0 @@
1
- # these require statements are needed for Watir
2
- # to work with minimum functionality
3
- #
4
- # this is needed for #click_no_wait to perform faster
5
- module Watir
6
- # dummy modules for patching
7
- module Win32
8
- end
9
-
10
- module Utils
11
- end
12
- end
13
-
14
-
15
- require 'watir/win32ole'
16
- require 'logger'
17
- require 'watir/exceptions'
18
- require 'watir/matches'
19
-
20
- require 'watir/core_ext'
21
- require 'watir/logger'
22
- require 'watir/container'
23
- require 'watir/locator'
24
- require 'watir/page-container'
25
- require 'watir/ie-class'
26
- require 'watir/element'
27
- require 'watir/element_collections'
28
- require 'watir/form'
29
- require 'watir/non_control_elements'
30
- require 'watir/input_elements'
31
- require 'watir/table'
32
- require 'watir/image'
33
- require 'watir/link'
34
- begin
35
- require 'watir/html_element'
36
- rescue LoadError
37
- # this exists currently only on github
38
- end
39
-
40
- require 'watir/waiter'
41
-
42
- # watir/module
43
- module Watir
44
- include Watir::Exception
45
-
46
- # Directory containing the watir.rb file
47
- @@dir = File.expand_path(File.dirname(__FILE__))
48
-
49
- ATTACHER = Waiter.new
50
- # Like regular Ruby "until", except that a TimeOutException is raised
51
- # if the timeout is exceeded. Timeout is IE.attach_timeout.
52
- def self.until_with_timeout # block
53
- ATTACHER.timeout = IE.attach_timeout
54
- ATTACHER.wait_until { yield }
55
- end
56
-
57
- @@autoit = nil
58
-
59
- def self.autoit
60
- unless @@autoit
61
- begin
62
- @@autoit = WIN32OLE.new('AutoItX3.Control')
63
- rescue WIN32OLERuntimeError
64
- _register('AutoItX3.dll')
65
- @@autoit = WIN32OLE.new('AutoItX3.Control')
66
- end
67
- end
68
- @@autoit
69
- end
70
-
71
- def self._register(dll)
72
- system("regsvr32.exe /s " + "#{@@dir}/#{dll}".gsub('/', '\\'))
73
- end
74
-
75
- def self._unregister(dll)
76
- system("regsvr32.exe /s /u " + "#{@@dir}/#{dll}".gsub('/', '\\'))
77
- end
78
-
79
- end