watir 1.8.1 → 1.9.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +10 -0
- data/VERSION +1 -1
- data/lib/watir/container.rb +7 -2
- data/lib/watir/core.rb +4 -0
- data/lib/watir/dialogs/file_upload.rb +36 -0
- data/lib/watir/dialogs/javascript.rb +47 -0
- data/lib/watir/element.rb +44 -4
- data/lib/watir/frame.rb +15 -2
- data/lib/watir/ie-class.rb +42 -18
- data/lib/watir/ie.rb +3 -6
- data/lib/watir/image.rb +5 -4
- data/lib/watir/input_elements.rb +40 -89
- data/lib/watir/modal_dialog.rb +6 -0
- data/lib/watir/module.rb +0 -23
- data/lib/watir/win32.rb +4 -0
- data/lib/watir/win32ole.rb +5 -2
- data/lib/watir/win32ole/1.8.7/win32ole.so +0 -0
- data/rakefile.rb +2 -1
- data/unittests/click_no_wait_test.rb +4 -2
- data/unittests/close_all_test.rb +1 -1
- data/unittests/dialog_test.rb +22 -38
- data/unittests/filefield_xpath_test.rb +4 -1
- data/unittests/form_test.rb +1 -0
- data/unittests/frame_test.rb +17 -1
- data/unittests/html/ie_9.html +6 -0
- data/unittests/html/iframe.html +3 -0
- data/unittests/ie9_test.rb +16 -0
- data/unittests/images_test.rb +1 -1
- data/unittests/minmax_test.rb +16 -9
- data/unittests/no_wait_test.rb +10 -4
- data/unittests/setup.rb +0 -13
- data/unittests/version_test.rb +15 -0
- data/unittests/win32ole_so_test.rb +35 -0
- data/unittests/windows/send_keys_test.rb +0 -6
- data/watir.gemspec +6 -4
- metadata +67 -38
- data/lib/watir/AutoItX.chm +0 -0
- data/lib/watir/AutoItX3.dll +0 -0
- data/lib/watir/WindowHelper.rb +0 -49
- data/lib/watir/clickJSDialog.rb +0 -19
- data/lib/watir/dialog.rb +0 -46
- data/lib/watir/popup.rb +0 -30
- data/lib/watir/setFileDialog.rb +0 -16
- data/lib/watir/win32ole/win32ole.so +0 -0
- data/lib/watir/winClicker.rb +0 -460
- data/unittests/other/WindowLogonExample.rb +0 -28
- data/unittests/other/WindowLogonExtra.rb +0 -7
- data/unittests/other/jscriptExtraAlert.rb +0 -7
- data/unittests/other/jscriptExtraConfirmCancel.rb +0 -7
- data/unittests/other/jscriptExtraConfirmOk.rb +0 -7
- data/unittests/other/jscriptPushButton.rb +0 -6
- data/unittests/other/jscript_test.rb +0 -63
- data/unittests/popups_test.rb +0 -41
data/CHANGES
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
== Version 1.9.0 -2011//
|
2
|
+
|
3
|
+
* Added support for IE9
|
4
|
+
* Updated watir/ie for Ruby 1.8.7 and are no longer supporting Ruby 1.8.6.
|
5
|
+
* Using RAutomation instead of Autoit, WinClicker and the WindowHelper
|
6
|
+
* New implementation of ie.file_field
|
7
|
+
* Replaced ie.dialog with ie.javascript_dialog
|
8
|
+
* Recompiled win32ole for 1.8.7 mingw and removed win32ole for 1.8.6
|
9
|
+
|
10
|
+
|
1
11
|
== Version 1.8.1 - 2011/04/08
|
2
12
|
|
3
13
|
=== IE improvements
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.9.0.rc1
|
data/lib/watir/container.rb
CHANGED
@@ -269,9 +269,14 @@ module Watir
|
|
269
269
|
# browser.file_field(:index, 2) # access the second file upload on the page (1 based, so the first field is accessed with :index,1)
|
270
270
|
#
|
271
271
|
def file_field(how, what=nil)
|
272
|
-
|
272
|
+
FileUpload.new(self, how, what)
|
273
273
|
end
|
274
|
-
|
274
|
+
|
275
|
+
def javascript_dialog(opts={})
|
276
|
+
JavascriptDialog.new(opts)
|
277
|
+
end
|
278
|
+
alias :dialog :javascript_dialog
|
279
|
+
|
275
280
|
# this is the main method for accessing the file_fields iterator. It returns a FileFields object
|
276
281
|
#
|
277
282
|
# Typical usage:
|
data/lib/watir/core.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Watir
|
2
|
+
class FileUpload < InputElement
|
3
|
+
#:stopdoc:
|
4
|
+
INPUT_TYPES = ["file"]
|
5
|
+
#:startdoc:
|
6
|
+
|
7
|
+
def set(file_path)
|
8
|
+
assert_file_exists(file_path)
|
9
|
+
assert_exists
|
10
|
+
click_no_wait
|
11
|
+
set_file_name file_path
|
12
|
+
open_button.click
|
13
|
+
end
|
14
|
+
|
15
|
+
def assert_file_exists(file_path)
|
16
|
+
raise WatirException, "#{file_path} has to exist to set!" unless File.exists?(file_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_file_name(path_to_file)
|
20
|
+
file_upload_window.text_field(:class => 'Edit', :index => 0).set path_to_file
|
21
|
+
end
|
22
|
+
|
23
|
+
def open_button
|
24
|
+
file_upload_window.button(:value => '&Open')
|
25
|
+
end
|
26
|
+
|
27
|
+
def cancel_button
|
28
|
+
file_upload_window.button(:value => 'Cancel')
|
29
|
+
end
|
30
|
+
|
31
|
+
def file_upload_window
|
32
|
+
@window ||= RAutomation::Window.new(:title => /^choose file( to upload)?$/i)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Watir
|
2
|
+
|
3
|
+
class JavascriptDialog
|
4
|
+
WINDOW_TITLES = ['Message from webpage', 'Windows Internet Explorer','Microsoft Internet Explorer']
|
5
|
+
|
6
|
+
attr_accessor :timeout
|
7
|
+
|
8
|
+
def initialize(opts={})
|
9
|
+
@opts = opts
|
10
|
+
@timeout = 30
|
11
|
+
end
|
12
|
+
|
13
|
+
def exists?
|
14
|
+
javascript_dialog_window.exists?
|
15
|
+
end
|
16
|
+
|
17
|
+
def button(value)
|
18
|
+
javascript_dialog_window.button(:value => value)
|
19
|
+
end
|
20
|
+
|
21
|
+
def close
|
22
|
+
javascript_dialog_window.close
|
23
|
+
end
|
24
|
+
|
25
|
+
def text
|
26
|
+
javascript_dialog_window.text
|
27
|
+
end
|
28
|
+
|
29
|
+
def javascript_dialog_window
|
30
|
+
return @window if @window
|
31
|
+
begin
|
32
|
+
original_timeout = RAutomation::Window.wait_timeout
|
33
|
+
RAutomation::Window.wait_timeout = @timeout
|
34
|
+
::RAutomation::Window.new(:title => @opts[:title] || /^(#{WINDOW_TITLES.join('|')})$/)
|
35
|
+
ensure
|
36
|
+
RAutomation::Window.wait_timeout = original_timeout
|
37
|
+
end
|
38
|
+
@window
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
data/lib/watir/element.rb
CHANGED
@@ -251,7 +251,7 @@ module Watir
|
|
251
251
|
def generate_ruby_code(element, method_name, *args)
|
252
252
|
element = "#{self.class}.new(#{@page_container.attach_command}, :unique_number, #{self.unique_number})"
|
253
253
|
method = build_method(method_name, *args)
|
254
|
-
ruby_code = "$:.unshift(#{$LOAD_PATH.
|
254
|
+
ruby_code = "$:.unshift(#{$LOAD_PATH.map {|p| "'#{p}'" }.join(").unshift(")});" <<
|
255
255
|
"require '#{File.expand_path(File.dirname(__FILE__))}/core';#{element}.#{method};"
|
256
256
|
return ruby_code
|
257
257
|
end
|
@@ -276,7 +276,10 @@ module Watir
|
|
276
276
|
assert_enabled
|
277
277
|
|
278
278
|
highlight(:set)
|
279
|
-
|
279
|
+
# Not sure why but in IE9 Document mode, passing a parameter
|
280
|
+
# to click seems to work. Firing the onClick event breaks other tests
|
281
|
+
# so this seems to be the safest change and also works fine in IE8
|
282
|
+
ole_object.click(0)
|
280
283
|
highlight(:clear)
|
281
284
|
end
|
282
285
|
|
@@ -300,13 +303,50 @@ module Watir
|
|
300
303
|
def fire_event(event)
|
301
304
|
assert_exists
|
302
305
|
assert_enabled
|
303
|
-
|
304
306
|
highlight(:set)
|
305
|
-
|
307
|
+
dispatch_event(event)
|
306
308
|
@container.wait
|
307
309
|
highlight(:clear)
|
308
310
|
end
|
309
311
|
|
312
|
+
def dispatch_event(event)
|
313
|
+
if IE.version_parts.first.to_i >= 8 && @container.page_container.document.respond_to?(:createEvent)
|
314
|
+
# we're in IE9 document standards mode
|
315
|
+
ole_object.dispatchEvent(create_event(event))
|
316
|
+
else
|
317
|
+
ole_object.fireEvent(event)
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
def create_event(event)
|
322
|
+
event =~ /on(.*)/i
|
323
|
+
event = $1 if $1
|
324
|
+
event.downcase!
|
325
|
+
|
326
|
+
# See http://www.howtocreate.co.uk/tutorials/javascript/domevents
|
327
|
+
case event
|
328
|
+
when 'abort', 'blur', 'change', 'error', 'focus', 'load',
|
329
|
+
'reset', 'resize', 'scroll', 'select', 'submit', 'unload'
|
330
|
+
dom_event_type = 'HTMLEvents'
|
331
|
+
dom_event_init = "initEvent(\"#{event}\", true, true)"
|
332
|
+
when 'keydown', 'keypress', 'keyup'
|
333
|
+
dom_event_type = 'KeyEvents'
|
334
|
+
# 'type', bubbles, cancelable, windowObject, ctrlKey, altKey, shiftKey, metaKey, keyCode, charCode
|
335
|
+
dom_event_init = "initKeyEvent(\"#{event}\", true, true, #{@container.page_container.window}, false, false, false, false, 0, 0)"
|
336
|
+
when 'click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover',
|
337
|
+
'mouseup'
|
338
|
+
dom_event_type = 'MouseEvents'
|
339
|
+
# 'type', bubbles, cancelable, windowObject, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget
|
340
|
+
dom_event_init = "initMouseEvent(\"#{event}\", true, true, #{@container.page_container.window}, 1, 0, 0, 0, 0, false, false, false, false, 0, null)"
|
341
|
+
else
|
342
|
+
dom_event_type = 'HTMLEvents'
|
343
|
+
dom_event_init = "initEvents(\"#{event}\", true, true)"
|
344
|
+
end
|
345
|
+
event = @container.page_container.document.createEvent("HTMLEvents")
|
346
|
+
event.initEvent("change", true, true)
|
347
|
+
event
|
348
|
+
end
|
349
|
+
|
310
350
|
# This method sets focus on the active element.
|
311
351
|
# raises: UnknownObjectException if the object is not found
|
312
352
|
# ObjectDisabledException if the object is currently disabled
|
data/lib/watir/frame.rb
CHANGED
@@ -17,7 +17,16 @@ module Watir
|
|
17
17
|
located_frame, document = locator.locate
|
18
18
|
unless (located_frame.nil? && document.nil?)
|
19
19
|
@o = located_frame
|
20
|
-
|
20
|
+
begin
|
21
|
+
@document = document.document
|
22
|
+
rescue WIN32OLERuntimeError => e
|
23
|
+
if e.message =~ /Access is denied/
|
24
|
+
# This frame's content is not directly accessible but let the
|
25
|
+
# user continue so they can access the frame properties
|
26
|
+
else
|
27
|
+
raise e
|
28
|
+
end
|
29
|
+
end
|
21
30
|
break
|
22
31
|
end
|
23
32
|
end
|
@@ -38,7 +47,11 @@ module Watir
|
|
38
47
|
|
39
48
|
def document
|
40
49
|
assert_exists
|
41
|
-
@document
|
50
|
+
if @document
|
51
|
+
@document
|
52
|
+
else
|
53
|
+
raise FrameAccessDeniedException, "IE will not allow access to this frame for security reasons. You can work around this with ie.goto(frame.src)"
|
54
|
+
end
|
42
55
|
end
|
43
56
|
|
44
57
|
def attach_command
|
data/lib/watir/ie-class.rb
CHANGED
@@ -249,7 +249,21 @@ module Watir
|
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
252
|
-
|
252
|
+
def self.version
|
253
|
+
begin
|
254
|
+
require 'win32/registry'
|
255
|
+
::Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\Microsoft\\Internet Explorer") do |ie_key|
|
256
|
+
ie_key.read('Version').last
|
257
|
+
end
|
258
|
+
# OR: ::WIN32OLE.new("WScript.Shell").RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\Version")
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def self.version_parts
|
263
|
+
version.split('.')
|
264
|
+
end
|
265
|
+
|
266
|
+
# return internet explorer instance as specified. if none is found,
|
253
267
|
# return nil.
|
254
268
|
# arguments:
|
255
269
|
# :url, url -- the URL of the IE browser window
|
@@ -413,43 +427,53 @@ module Watir
|
|
413
427
|
|
414
428
|
# Maximize the window (expands to fill the screen)
|
415
429
|
def maximize
|
416
|
-
|
430
|
+
rautomation.maximize
|
417
431
|
end
|
418
432
|
|
419
433
|
# Minimize the window (appears as icon on taskbar)
|
420
434
|
def minimize
|
421
|
-
|
435
|
+
rautomation.minimize
|
436
|
+
end
|
437
|
+
|
438
|
+
def minimized?
|
439
|
+
rautomation.minimized?
|
422
440
|
end
|
423
441
|
|
424
442
|
# Restore the window (after minimizing or maximizing)
|
425
443
|
def restore
|
426
|
-
|
444
|
+
rautomation.restore
|
427
445
|
end
|
428
446
|
|
429
447
|
# Make the window come to the front
|
430
|
-
def
|
431
|
-
|
448
|
+
def activate
|
449
|
+
rautomation.activate
|
432
450
|
end
|
451
|
+
alias :bring_to_front :activate
|
433
452
|
|
434
|
-
def
|
435
|
-
|
453
|
+
def active?
|
454
|
+
rautomation.active?
|
436
455
|
end
|
456
|
+
alias :front? :active?
|
437
457
|
|
438
|
-
|
439
|
-
|
440
|
-
|
458
|
+
def rautomation
|
459
|
+
@rautomation ||= ::RAutomation::Window.new(:hwnd => hwnd)
|
460
|
+
@rautomation
|
441
461
|
end
|
462
|
+
|
442
463
|
def autoit
|
443
|
-
Watir
|
464
|
+
raise NotImplementedError, 'Watir no longer uses AutoIT. ' <<
|
465
|
+
'If you need this functionality you can downgrade to v1.8.1 ' <<
|
466
|
+
'or update your scripts to use ie.rautomation. ' <<
|
467
|
+
'Please refer to https://github.com/jarmo/RAutomation'
|
444
468
|
end
|
445
|
-
public
|
446
469
|
|
447
|
-
#
|
448
|
-
#
|
449
|
-
#
|
470
|
+
# Activates the window and sends keys to it.
|
471
|
+
#
|
472
|
+
# Refer to MSDN documentation at http://msdn.microsoft.com/en-us/library/dd375731(v=VS.85).aspx
|
473
|
+
# for the keycodes.
|
474
|
+
# @see RAutomation::Window#send_keys
|
450
475
|
def send_keys(key_string)
|
451
|
-
|
452
|
-
autoit.Send key_string
|
476
|
+
rautomation.send_keys key_string
|
453
477
|
end
|
454
478
|
|
455
479
|
def dir
|
data/lib/watir/ie.rb
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
require 'watir'
|
2
2
|
require 'watir/core'
|
3
|
-
require 'watir/winClicker'
|
4
3
|
require 'watir/close_all'
|
5
4
|
require 'watir/ie-process'
|
6
5
|
|
7
|
-
require 'dl/import'
|
8
|
-
require 'dl/struct'
|
9
|
-
require 'Win32API'
|
10
|
-
|
11
6
|
# these switches need to be deleted from ARGV to enable the Test::Unit
|
12
7
|
# functionality that grabs
|
13
8
|
# the remaining ARGV as a filter on what tests to run.
|
@@ -25,8 +20,10 @@ $FAST_SPEED = ARGV.delete('-f')
|
|
25
20
|
ARGV.delete('-s')
|
26
21
|
|
27
22
|
require 'watir/win32'
|
28
|
-
require 'watir/popup'
|
29
23
|
require 'watir/modal_dialog'
|
30
24
|
require 'watir/collections'
|
31
25
|
|
32
26
|
require 'watir/camel_case'
|
27
|
+
|
28
|
+
|
29
|
+
|
data/lib/watir/image.rb
CHANGED
@@ -107,11 +107,8 @@ module Watir
|
|
107
107
|
# will not overwrite a previously existing image. If an image already
|
108
108
|
# exists at the given path then a dialog will be displayed prompting
|
109
109
|
# for overwrite.
|
110
|
-
# Raises a WatirException if AutoIt is not correctly installed
|
111
110
|
# path - directory path and file name of where image should be saved
|
112
111
|
def save(path)
|
113
|
-
require 'watir/windowhelper'
|
114
|
-
WindowHelper.check_autoit_installed
|
115
112
|
@container.goto(src)
|
116
113
|
begin
|
117
114
|
thrd = fill_save_image_dialog(path)
|
@@ -123,8 +120,12 @@ module Watir
|
|
123
120
|
end
|
124
121
|
|
125
122
|
def fill_save_image_dialog(path)
|
123
|
+
command = "require 'rautomation';" <<
|
124
|
+
"window=::RAutomation::Window.new(:title => 'Save Picture');" <<
|
125
|
+
"window.text_field(:class => 'Edit', :index => 0).set('#{path}');" <<
|
126
|
+
"window.button(:value => '&Save').click"
|
126
127
|
Thread.new do
|
127
|
-
system("ruby -e \"
|
128
|
+
system("ruby -e \"#{command}\"")
|
128
129
|
end
|
129
130
|
end
|
130
131
|
private :fill_save_image_dialog
|
data/lib/watir/input_elements.rb
CHANGED
@@ -40,14 +40,14 @@ module Watir
|
|
40
40
|
highlight(:clear)
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
|
44
44
|
# This method selects an item, or items in a select box, by text.
|
45
45
|
# Raises NoValueFoundException if the specified value is not found.
|
46
46
|
# * item - the thing to select, string or reg exp
|
47
47
|
def select(item)
|
48
48
|
select_item_in_select_list(:text, item)
|
49
49
|
end
|
50
|
-
alias :set :select
|
50
|
+
alias :set :select
|
51
51
|
|
52
52
|
# Selects an item, or items in a select box, by value.
|
53
53
|
# Raises NoValueFoundException if the specified value is not found.
|
@@ -75,7 +75,7 @@ module Watir
|
|
75
75
|
break
|
76
76
|
else
|
77
77
|
option.selected = true
|
78
|
-
|
78
|
+
dispatch_event("onChange")
|
79
79
|
@container.wait
|
80
80
|
found = true
|
81
81
|
break
|
@@ -88,7 +88,7 @@ module Watir
|
|
88
88
|
end
|
89
89
|
highlight(:clear)
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
# Returns array of all text items displayed in a select box
|
93
93
|
# An empty array is returned if the select box has no contents.
|
94
94
|
# Raises UnknownObjectException if the select box is not found
|
@@ -308,14 +308,14 @@ module Watir
|
|
308
308
|
@o.select
|
309
309
|
value = self.value
|
310
310
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
destination.
|
315
|
-
destination.
|
316
|
-
destination.
|
311
|
+
dispatch_event("onSelect")
|
312
|
+
dispatch_event("ondragstart")
|
313
|
+
dispatch_event("ondrag")
|
314
|
+
destination.dispatch_event("onDragEnter")
|
315
|
+
destination.dispatch_event("onDragOver")
|
316
|
+
destination.dispatch_event("ondrop")
|
317
317
|
|
318
|
-
|
318
|
+
dispatch_event("ondragend")
|
319
319
|
destination.value = destination.value + value.to_s
|
320
320
|
self.value = ""
|
321
321
|
end
|
@@ -334,10 +334,10 @@ module Watir
|
|
334
334
|
@o.scrollIntoView
|
335
335
|
@o.focus
|
336
336
|
@o.select
|
337
|
-
|
337
|
+
dispatch_event("onSelect")
|
338
338
|
@o.value = ""
|
339
|
-
|
340
|
-
|
339
|
+
dispatch_event("onKeyPress")
|
340
|
+
dispatch_event("onChange")
|
341
341
|
@container.wait
|
342
342
|
highlight(:clear)
|
343
343
|
end
|
@@ -366,33 +366,33 @@ module Watir
|
|
366
366
|
assert_exists
|
367
367
|
assert_enabled
|
368
368
|
assert_not_readonly
|
369
|
-
|
369
|
+
|
370
370
|
highlight(:set)
|
371
371
|
@o.scrollIntoView
|
372
372
|
if type_keys
|
373
373
|
@o.focus
|
374
374
|
@o.select
|
375
|
-
|
376
|
-
|
375
|
+
dispatch_event("onSelect")
|
376
|
+
dispatch_event("onKeyPress")
|
377
377
|
@o.value = ""
|
378
378
|
type_by_character(value)
|
379
|
-
|
380
|
-
|
379
|
+
dispatch_event("onChange")
|
380
|
+
dispatch_event("onBlur")
|
381
381
|
else
|
382
382
|
@o.value = limit_to_maxlength(value)
|
383
383
|
end
|
384
384
|
highlight(:clear)
|
385
385
|
end
|
386
|
-
|
387
|
-
# Sets the value of the text field directly.
|
388
|
-
# It causes no events to be fired or exceptions to be raised,
|
386
|
+
|
387
|
+
# Sets the value of the text field directly.
|
388
|
+
# It causes no events to be fired or exceptions to be raised,
|
389
389
|
# so generally shouldn't be used.
|
390
390
|
# It is preffered to use the set method.
|
391
391
|
def value=(v)
|
392
392
|
assert_exists
|
393
393
|
@o.value = v.to_s
|
394
394
|
end
|
395
|
-
|
395
|
+
|
396
396
|
def requires_typing #:nodoc:
|
397
397
|
@type_keys = true
|
398
398
|
self
|
@@ -403,7 +403,7 @@ module Watir
|
|
403
403
|
end
|
404
404
|
|
405
405
|
private
|
406
|
-
|
406
|
+
|
407
407
|
# Type the characters in the specified string (value) one by one.
|
408
408
|
# It should not be used externally.
|
409
409
|
# * value - string - The string to enter into the text field
|
@@ -411,10 +411,10 @@ module Watir
|
|
411
411
|
value = limit_to_maxlength(value)
|
412
412
|
characters_in(value) do |c|
|
413
413
|
sleep @container.typingspeed
|
414
|
-
@o.value = @o.value.to_s + c
|
415
|
-
|
416
|
-
|
417
|
-
|
414
|
+
@o.value = @o.value.to_s + c
|
415
|
+
dispatch_event("onKeyDown")
|
416
|
+
dispatch_event("onKeyPress")
|
417
|
+
dispatch_event("onKeyUp")
|
418
418
|
end
|
419
419
|
end
|
420
420
|
|
@@ -476,51 +476,7 @@ module Watir
|
|
476
476
|
end
|
477
477
|
|
478
478
|
end
|
479
|
-
|
480
|
-
# For fields that accept file uploads
|
481
|
-
# Windows dialog is opened and handled in this case by autoit
|
482
|
-
# launching into a new process.
|
483
|
-
# Normally a user would not need to create this object as it is returned by the Watir::Container#file_field method
|
484
|
-
class FileField < InputElement
|
485
|
-
#:stopdoc:
|
486
|
-
INPUT_TYPES = ["file"]
|
487
|
-
POPUP_TITLES = ['Choose file', 'Choose File to Upload']
|
488
|
-
#:startdoc:
|
489
|
-
|
490
|
-
# set the file location in the Choose file dialog in a new process
|
491
|
-
# will raise a WatirException if AutoIt is not correctly installed
|
492
|
-
def set(path_to_file)
|
493
|
-
assert_exists
|
494
|
-
require 'watir/windowhelper'
|
495
|
-
WindowHelper.check_autoit_installed
|
496
|
-
begin
|
497
|
-
Thread.new do
|
498
|
-
sleep 1 # it takes some time for popup to appear
|
499
|
-
|
500
|
-
system %{ruby -e '
|
501
|
-
require "win32ole"
|
502
|
-
|
503
|
-
@autoit = WIN32OLE.new("AutoItX3.Control")
|
504
|
-
time = Time.now
|
505
479
|
|
506
|
-
while (Time.now - time) < 15 # the loop will wait up to 15 seconds for popup to appear
|
507
|
-
#{POPUP_TITLES.inspect}.each do |popup_title|
|
508
|
-
next unless @autoit.WinWait(popup_title, "", 1) == 1
|
509
|
-
|
510
|
-
@autoit.ControlSetText(popup_title, "", "Edit1", #{path_to_file.inspect})
|
511
|
-
@autoit.ControlSend(popup_title, "", "Button2", "{ENTER}")
|
512
|
-
exit
|
513
|
-
end # each
|
514
|
-
end # while
|
515
|
-
'}
|
516
|
-
end.join(1)
|
517
|
-
rescue
|
518
|
-
raise Watir::Exception::WatirException, "Problem accessing Choose file dialog"
|
519
|
-
end
|
520
|
-
click
|
521
|
-
end
|
522
|
-
end
|
523
|
-
|
524
480
|
# This class contains common methods to both radio buttons and check boxes.
|
525
481
|
# Normally a user would not need to create this object as it is returned by the Watir::Container#checkbox or by Watir::Container#radio methods
|
526
482
|
#--
|
@@ -547,15 +503,7 @@ module Watir
|
|
547
503
|
end
|
548
504
|
alias checked? set?
|
549
505
|
|
550
|
-
|
551
|
-
def set_clear_item(set)
|
552
|
-
@o.checked = set
|
553
|
-
@o.fireEvent("onClick")
|
554
|
-
@container.wait
|
555
|
-
end
|
556
|
-
private :set_clear_item
|
557
|
-
|
558
|
-
end
|
506
|
+
end
|
559
507
|
|
560
508
|
#--
|
561
509
|
# this class makes the docs better
|
@@ -572,7 +520,8 @@ module Watir
|
|
572
520
|
assert_exists
|
573
521
|
assert_enabled
|
574
522
|
highlight(:set)
|
575
|
-
|
523
|
+
@o.checked = false
|
524
|
+
highlight(:clear)
|
576
525
|
highlight(:clear)
|
577
526
|
end
|
578
527
|
|
@@ -584,12 +533,13 @@ module Watir
|
|
584
533
|
assert_enabled
|
585
534
|
highlight(:set)
|
586
535
|
@o.scrollIntoView
|
587
|
-
|
536
|
+
@o.checked = true
|
537
|
+
click
|
588
538
|
highlight(:clear)
|
589
539
|
end
|
590
|
-
|
540
|
+
|
591
541
|
end
|
592
|
-
|
542
|
+
|
593
543
|
# This class is the watir representation of a check box.
|
594
544
|
# Normally a user would not need to create this object as it is returned by the Watir::Container#checkbox method
|
595
545
|
class CheckBox < RadioCheckCommon
|
@@ -603,8 +553,9 @@ module Watir
|
|
603
553
|
assert_exists
|
604
554
|
assert_enabled
|
605
555
|
highlight :set
|
606
|
-
|
607
|
-
|
556
|
+
current_value = @o.checked
|
557
|
+
unless value == current_value
|
558
|
+
click
|
608
559
|
end
|
609
560
|
highlight :clear
|
610
561
|
end
|
@@ -615,7 +566,7 @@ module Watir
|
|
615
566
|
def clear
|
616
567
|
set false
|
617
568
|
end
|
618
|
-
|
569
|
+
|
619
570
|
end
|
620
|
-
|
571
|
+
|
621
572
|
end
|