watir-classic 3.3.0 → 3.4.0
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 +17 -0
- data/Gemfile.lock +9 -8
- data/LICENSE +1 -0
- data/README.rdoc +6 -7
- data/Rakefile +3 -1
- data/VERSION +1 -1
- data/lib/watir-classic.rb +0 -5
- data/lib/watir-classic/browser.rb +58 -35
- data/lib/watir-classic/browsers.rb +1 -1
- data/lib/watir-classic/container.rb +39 -33
- data/lib/watir-classic/cookies.rb +32 -2
- data/lib/watir-classic/core.rb +0 -1
- data/lib/watir-classic/dialogs/alert.rb +12 -0
- data/lib/watir-classic/dialogs/file_field.rb +11 -0
- data/lib/watir-classic/drag_and_drop_helper.rb +14 -0
- data/lib/watir-classic/element.rb +292 -257
- data/lib/watir-classic/element_collection.rb +26 -8
- data/lib/watir-classic/element_extensions.rb +22 -16
- data/lib/watir-classic/exceptions.rb +4 -4
- data/lib/watir-classic/form.rb +52 -49
- data/lib/watir-classic/frame.rb +23 -14
- data/lib/watir-classic/ie-class.rb +363 -315
- data/lib/watir-classic/ie-process.rb +1 -0
- data/lib/watir-classic/ie.rb +0 -17
- data/lib/watir-classic/image.rb +58 -64
- data/lib/watir-classic/input_elements.rb +224 -219
- data/lib/watir-classic/link.rb +14 -15
- data/lib/watir-classic/locator.rb +12 -7
- data/lib/watir-classic/matches.rb +7 -3
- data/lib/watir-classic/modal_dialog.rb +38 -26
- data/lib/watir-classic/non_control_elements.rb +29 -0
- data/lib/watir-classic/options.rb +10 -15
- data/lib/watir-classic/page-container.rb +30 -48
- data/lib/watir-classic/process.rb +4 -2
- data/lib/watir-classic/screenshot.rb +6 -0
- data/lib/watir-classic/supported_elements.rb +36 -14
- data/lib/watir-classic/table.rb +81 -71
- data/lib/watir-classic/util.rb +9 -11
- data/lib/watir-classic/wait.rb +17 -4
- data/lib/watir-classic/wait_helper.rb +15 -2
- data/lib/watir-classic/win32.rb +2 -1
- data/lib/watir-classic/window.rb +35 -7
- data/lib/watir-classic/xpath_locator.rb +1 -0
- data/lib/watir-classic/yard/global_macros.rb +7 -0
- data/spec/frame_spec.rb +17 -0
- metadata +5 -7
- data/lib/watir-classic/close_all.rb +0 -31
- data/lib/watir-classic/contrib/enabled_popup.rb +0 -21
- data/lib/watir-classic/contrib/ie-new-process.rb +0 -27
- data/lib/watir-classic/contrib/page_checker.rb +0 -29
- data/watir.gif +0 -0
data/lib/watir-classic/util.rb
CHANGED
@@ -1,25 +1,23 @@
|
|
1
1
|
module Watir
|
2
2
|
class Util
|
3
3
|
class << self
|
4
|
-
|
5
|
-
#
|
6
|
-
#
|
4
|
+
|
5
|
+
# @example
|
6
|
+
# Watir::Util.demodulize("Watir::Span") # => "Span"
|
7
7
|
def demodulize(str)
|
8
8
|
str.gsub(/^.*::/, '')
|
9
9
|
end
|
10
10
|
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
11
|
+
# @example
|
12
|
+
# Watir::Util.underscore("FooBar") # => "foo_bar"
|
14
13
|
def underscore(str)
|
15
14
|
str.gsub(/\B[A-Z][^A-Z]/, '_\&').downcase.gsub(' ', '_')
|
16
15
|
end
|
17
16
|
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
17
|
+
# @example
|
18
|
+
# Watir::Util.singularize("Checkboxes") # => "Checkbox"
|
19
|
+
# Watir::Util.singularize("Bodies") # => "Body"
|
20
|
+
# Watir::Util.singularize("Buttons") # => "Button"
|
23
21
|
def singularize(str)
|
24
22
|
case str.downcase
|
25
23
|
when "checkboxes"
|
data/lib/watir-classic/wait.rb
CHANGED
@@ -7,10 +7,16 @@ module Watir
|
|
7
7
|
class TimeoutError < StandardError
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
10
|
# Wait until the block evaluates to true or times out.
|
12
11
|
#
|
13
|
-
|
12
|
+
# @example
|
13
|
+
# Watir::Wait.until(5) { browser.text_field.exists? }
|
14
|
+
#
|
15
|
+
# @param [Fixnum] timeout timeout to wait until block returns true.
|
16
|
+
# @yieldparam [self] instance instance of self.
|
17
|
+
# @raise [TimeoutError] when timeout exceeds.
|
18
|
+
# @see WaitHelper
|
19
|
+
# @see ElementExtensions
|
14
20
|
def until(timeout = 60, &block)
|
15
21
|
end_time = ::Time.now + timeout
|
16
22
|
|
@@ -23,9 +29,16 @@ module Watir
|
|
23
29
|
raise TimeoutError, "timed out after #{timeout} seconds"
|
24
30
|
end
|
25
31
|
|
26
|
-
#
|
27
32
|
# Wait while the block evaluates to true or times out.
|
28
33
|
#
|
34
|
+
# @example
|
35
|
+
# Watir::Wait.while(5) { browser.text_field.exists? }
|
36
|
+
#
|
37
|
+
# @param [Fixnum] timeout timeout to wait while block returns true.
|
38
|
+
# @yieldparam [self] instance instance of self.
|
39
|
+
# @raise [TimeoutError] when timeout exceeds.
|
40
|
+
# @see WaitHelper
|
41
|
+
# @see ElementExtensions
|
29
42
|
def while(timeout = 60, &block)
|
30
43
|
end_time = ::Time.now + timeout
|
31
44
|
|
@@ -38,4 +51,4 @@ module Watir
|
|
38
51
|
end
|
39
52
|
|
40
53
|
end # Wait
|
41
|
-
end # Watir
|
54
|
+
end # Watir
|
@@ -1,12 +1,25 @@
|
|
1
|
-
# include this module if there's a need to have wait_until and wait_while methods in some different scope
|
2
1
|
module Watir
|
3
2
|
module WaitHelper
|
3
|
+
# Wait until block evaluates to true or times out.
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# browser.wait_until(5) { browser.text_field.exists? }
|
7
|
+
#
|
8
|
+
# @see Wait
|
9
|
+
# @see ElementExtensions
|
4
10
|
def wait_until(*args, &blk)
|
5
11
|
Wait.until(*args, &blk)
|
6
12
|
end
|
7
13
|
|
14
|
+
# Wait while block evaluates to true or times out.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# browser.wait_while(5) { browser.text_field.exists? }
|
18
|
+
#
|
19
|
+
# @see Wait
|
20
|
+
# @see ElementExtensions
|
8
21
|
def wait_while(*args, &blk)
|
9
22
|
Wait.while(*args, &blk)
|
10
23
|
end
|
11
24
|
end
|
12
|
-
end
|
25
|
+
end
|
data/lib/watir-classic/win32.rb
CHANGED
@@ -3,6 +3,7 @@ require 'dl/struct'
|
|
3
3
|
require 'Win32API'
|
4
4
|
|
5
5
|
module Watir
|
6
|
+
# @private
|
6
7
|
module Win32
|
7
8
|
# this will find the IEDialog.dll file in its build location
|
8
9
|
@@iedialog_file = (File.expand_path(File.dirname(__FILE__) + '/..') + "/watir-classic/IEDialog/Release/IEDialog.dll").gsub('/', '\\')
|
@@ -37,4 +38,4 @@ module Watir
|
|
37
38
|
rtn == 1
|
38
39
|
end
|
39
40
|
end
|
40
|
-
end
|
41
|
+
end
|
data/lib/watir-classic/window.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module Watir
|
2
|
+
# Returned by {IE#window}.
|
2
3
|
class Window
|
3
4
|
include ElementExtensions
|
4
5
|
|
5
6
|
class << self
|
7
|
+
# @private
|
6
8
|
attr_accessor :__main_ie
|
7
9
|
|
8
|
-
|
10
|
+
# @private
|
11
|
+
def wrap(*meths)
|
9
12
|
meths.each do |meth|
|
10
13
|
define_method meth do
|
11
14
|
result = nil
|
@@ -16,7 +19,7 @@ module Watir
|
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
|
-
def initialize(main_browser, locators, browser=nil
|
22
|
+
def initialize(main_browser, locators, browser=nil)
|
20
23
|
valid_locators = [:title, :url, :hwnd, :index]
|
21
24
|
locators.each_pair do |k, v|
|
22
25
|
raise ArgumentError, "Valid locators are #{valid_locators.join(", ")}" unless valid_locators.include?(k)
|
@@ -27,14 +30,36 @@ module Watir
|
|
27
30
|
@browser = browser
|
28
31
|
end
|
29
32
|
|
33
|
+
# @!method url
|
34
|
+
# @return [String] url of the {Window}.
|
35
|
+
# @!method title
|
36
|
+
# @return [String] title of the {Window}.
|
37
|
+
# @!method hwnd
|
38
|
+
# @return [Fixnum] handle of the {Window}.
|
39
|
+
# @!method close
|
40
|
+
# Close the {Window}.
|
30
41
|
wrap :url, :title, :hwnd, :close
|
31
42
|
|
43
|
+
# @return [Browser] browser of the window.
|
32
44
|
def browser
|
33
45
|
@browser ||= begin
|
34
46
|
IE.find(@locators.keys.first, @locators.values.first)
|
35
47
|
end
|
36
48
|
end
|
37
49
|
|
50
|
+
# Use the window.
|
51
|
+
#
|
52
|
+
# @example Change current window:
|
53
|
+
# browser.window(:title => /foo/).use
|
54
|
+
# browser.title # => "foo"
|
55
|
+
#
|
56
|
+
# @example Execute code in the other window:
|
57
|
+
# browser.window(:title => /foo/).use do
|
58
|
+
# browser.title # => "foo"
|
59
|
+
# end
|
60
|
+
# browser.title # => "current window title"
|
61
|
+
#
|
62
|
+
# @yield optional block in the context of new {Window}.
|
38
63
|
def use(&blk)
|
39
64
|
@main_browser.ie = browser.ie
|
40
65
|
if blk
|
@@ -49,20 +74,23 @@ module Watir
|
|
49
74
|
self
|
50
75
|
end
|
51
76
|
|
77
|
+
# @return [Boolean] true when {Window} is the active {Browser} instance,
|
78
|
+
# false otherwise
|
52
79
|
def current?
|
53
80
|
@main_browser.hwnd == browser.hwnd && @main_browser.html == browser.html
|
54
81
|
end
|
55
82
|
|
83
|
+
# @return [Boolean] true when {Window} browser exists, false otherwise.
|
84
|
+
def present?
|
85
|
+
@browser = nil
|
86
|
+
browser && browser.exists?
|
87
|
+
end
|
88
|
+
|
56
89
|
def ==(other)
|
57
90
|
browser.hwnd == other.hwnd && browser.html == other.browser.html
|
58
91
|
end
|
59
92
|
|
60
93
|
alias_method :eql?, :==
|
61
94
|
|
62
|
-
def present?
|
63
|
-
@browser = nil
|
64
|
-
browser && browser.exists?
|
65
|
-
end
|
66
|
-
|
67
95
|
end
|
68
96
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# @!macro exists
|
2
|
+
# @raise [UnknownObjectException] when element does not exist.
|
3
|
+
# @raise [UnknownFrameException] when element is inside of a frame and
|
4
|
+
# that frame does not exist.
|
5
|
+
|
6
|
+
# @!macro enabled
|
7
|
+
# @raise [ObjectDisabledException] when element is disabled.
|
data/spec/frame_spec.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("watirspec/spec_helper", File.dirname(__FILE__))
|
3
|
+
|
4
|
+
describe "Frame" do
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.url_for("frames.html"))
|
7
|
+
end
|
8
|
+
|
9
|
+
it "handles clicking elements without waiting" do
|
10
|
+
browser.frame(:id, "frame_1").text_field(:name, 'senderElement').value.should == 'send_this_value'
|
11
|
+
browser.frame(:id, "frame_2").text_field(:name, 'recieverElement').value.should == 'old_value'
|
12
|
+
browser.frame(:id, "frame_1").button(:id, 'send').click_no_wait
|
13
|
+
browser.frame(:id, "frame_2").text_field(:name, 'recieverElement').value.should == 'old_value'
|
14
|
+
browser.frame(:id, "frame_2").text_field(:name => 'recieverElement', :text => 'send_this_value').wait_until_present(10).should_not raise_error(Watir::Wait::TimeoutError)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir-classic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: win32-process
|
@@ -254,11 +254,7 @@ files:
|
|
254
254
|
- lib/watir-classic/IEDialog/stdafx.h
|
255
255
|
- lib/watir-classic/browser.rb
|
256
256
|
- lib/watir-classic/browsers.rb
|
257
|
-
- lib/watir-classic/close_all.rb
|
258
257
|
- lib/watir-classic/container.rb
|
259
|
-
- lib/watir-classic/contrib/enabled_popup.rb
|
260
|
-
- lib/watir-classic/contrib/ie-new-process.rb
|
261
|
-
- lib/watir-classic/contrib/page_checker.rb
|
262
258
|
- lib/watir-classic/cookies.rb
|
263
259
|
- lib/watir-classic/core.rb
|
264
260
|
- lib/watir-classic/dialogs/alert.rb
|
@@ -302,13 +298,14 @@ files:
|
|
302
298
|
- lib/watir-classic/win32ole/history.txt
|
303
299
|
- lib/watir-classic/window.rb
|
304
300
|
- lib/watir-classic/xpath_locator.rb
|
301
|
+
- lib/watir-classic/yard/global_macros.rb
|
305
302
|
- spec/browser_spec.rb
|
306
303
|
- spec/element_spec.rb
|
304
|
+
- spec/frame_spec.rb
|
307
305
|
- spec/implementation.rb
|
308
306
|
- spec/link_spec.rb
|
309
307
|
- spec/select_list_spec.rb
|
310
308
|
- watir-classic.gemspec
|
311
|
-
- watir.gif
|
312
309
|
homepage: http://watir.com/
|
313
310
|
licenses: []
|
314
311
|
post_install_message:
|
@@ -337,6 +334,7 @@ summary: Automated testing tool for web applications.
|
|
337
334
|
test_files:
|
338
335
|
- spec/browser_spec.rb
|
339
336
|
- spec/element_spec.rb
|
337
|
+
- spec/frame_spec.rb
|
340
338
|
- spec/implementation.rb
|
341
339
|
- spec/link_spec.rb
|
342
340
|
- spec/select_list_spec.rb
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'watir-classic/ie'
|
2
|
-
|
3
|
-
module Watir
|
4
|
-
class IE
|
5
|
-
# close all ie browser windows
|
6
|
-
def self.close_all
|
7
|
-
close_all_but nil
|
8
|
-
end
|
9
|
-
# find other ie browser windows and close them
|
10
|
-
def close_others
|
11
|
-
IE.close_all_but self
|
12
|
-
end
|
13
|
-
private
|
14
|
-
def self.close_all_but(except=nil)
|
15
|
-
Watir::IE.each do |ie|
|
16
|
-
ie.close_modal
|
17
|
-
ie.close unless except and except.hwnd == ie.hwnd
|
18
|
-
end
|
19
|
-
sleep 1.0 # replace with polling for window count to be zero?
|
20
|
-
end
|
21
|
-
public
|
22
|
-
# close modal dialog. unlike IE#modal_dialog.close, does not wait for dialog
|
23
|
-
# to appear and does not raise exception if no window is found.
|
24
|
-
# returns true if modal was found and close, otherwise false
|
25
|
-
def close_modal
|
26
|
-
while self.modal_dialog.exists? do
|
27
|
-
self.modal_dialog.close
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# http://www.vbcity.com/forums/topic.asp?tid=108859
|
2
|
-
require 'watir-classic/ie'
|
3
|
-
module Watir
|
4
|
-
module PageContainer
|
5
|
-
include Win32
|
6
|
-
def enabled_popup(timeout=4)
|
7
|
-
# Use handle of our parent window to see if we have any currently
|
8
|
-
# enabled popup.
|
9
|
-
hwnd_modal = 0
|
10
|
-
Wait.until(timeout) do
|
11
|
-
hwnd_modal, arr = GetWindow.call(hwnd, GW_ENABLEDPOPUP)
|
12
|
-
hwnd_modal > 0
|
13
|
-
end
|
14
|
-
# use hwnd() method to find the IE or Container hwnd (overriden by IE)
|
15
|
-
if hwnd_modal == hwnd() || 0 == hwnd_modal
|
16
|
-
hwnd_modal = nil
|
17
|
-
end
|
18
|
-
hwnd_modal
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# based on http://svn.instiki.org/instiki/trunk/test/watir/e2e.rb
|
2
|
-
# and http://rubyforge.org/pipermail/wtr-general/2005-November/004108.html
|
3
|
-
|
4
|
-
require 'watir-classic/ie-process'
|
5
|
-
|
6
|
-
class IEProcess < Watir::IE::Process
|
7
|
-
def stop
|
8
|
-
right_to_terminate_process = 1
|
9
|
-
handle = Win32API.new('kernel32.dll', 'OpenProcess', 'lil', 'l').
|
10
|
-
call(right_to_terminate_process, 0, @process_id)
|
11
|
-
Win32API.new('kernel32.dll', 'TerminateProcess', 'll', 'l').call(handle, 0)
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
module Watir
|
17
|
-
class IE
|
18
|
-
def process_id
|
19
|
-
@process_id ||= IEProcess.process_id_from_hwnd @ie.hwnd
|
20
|
-
end
|
21
|
-
attr_writer :process_id
|
22
|
-
def kill
|
23
|
-
iep = IEProcess.new process_id
|
24
|
-
iep.stop
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# This module includes checkers which are run on every page load
|
2
|
-
#
|
3
|
-
# In order to use this module, add a require to one of your test scripts:
|
4
|
-
# require 'watir-classic/contrib/page_checker'
|
5
|
-
# To add checkers, call the ie.add_checker method
|
6
|
-
#
|
7
|
-
# ie.add_checker(PageCheckers::NAVIGATION_CHECKER)
|
8
|
-
#
|
9
|
-
# Checkers are Ruby proc objects which are called within Watir::IE and passed
|
10
|
-
# the current instance of ie.
|
11
|
-
|
12
|
-
module PageCheckers
|
13
|
-
|
14
|
-
# This checker iterates through the current document including any frames
|
15
|
-
# and checks for http errors, 404, 500 etc
|
16
|
-
NAVIGATION_CHECKER = lambda do |ie|
|
17
|
-
if ie.document.frames.length > 1
|
18
|
-
1.upto ie.document.frames.length do |i|
|
19
|
-
begin
|
20
|
-
ie.frame(:index, i).check_for_http_error
|
21
|
-
rescue Watir::Exception::UnknownFrameException
|
22
|
-
# frame can be already destroyed
|
23
|
-
end
|
24
|
-
end
|
25
|
-
else
|
26
|
-
ie.check_for_http_error
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/watir.gif
DELETED
Binary file
|