watir-classic 3.3.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/CHANGES +17 -0
  2. data/Gemfile.lock +9 -8
  3. data/LICENSE +1 -0
  4. data/README.rdoc +6 -7
  5. data/Rakefile +3 -1
  6. data/VERSION +1 -1
  7. data/lib/watir-classic.rb +0 -5
  8. data/lib/watir-classic/browser.rb +58 -35
  9. data/lib/watir-classic/browsers.rb +1 -1
  10. data/lib/watir-classic/container.rb +39 -33
  11. data/lib/watir-classic/cookies.rb +32 -2
  12. data/lib/watir-classic/core.rb +0 -1
  13. data/lib/watir-classic/dialogs/alert.rb +12 -0
  14. data/lib/watir-classic/dialogs/file_field.rb +11 -0
  15. data/lib/watir-classic/drag_and_drop_helper.rb +14 -0
  16. data/lib/watir-classic/element.rb +292 -257
  17. data/lib/watir-classic/element_collection.rb +26 -8
  18. data/lib/watir-classic/element_extensions.rb +22 -16
  19. data/lib/watir-classic/exceptions.rb +4 -4
  20. data/lib/watir-classic/form.rb +52 -49
  21. data/lib/watir-classic/frame.rb +23 -14
  22. data/lib/watir-classic/ie-class.rb +363 -315
  23. data/lib/watir-classic/ie-process.rb +1 -0
  24. data/lib/watir-classic/ie.rb +0 -17
  25. data/lib/watir-classic/image.rb +58 -64
  26. data/lib/watir-classic/input_elements.rb +224 -219
  27. data/lib/watir-classic/link.rb +14 -15
  28. data/lib/watir-classic/locator.rb +12 -7
  29. data/lib/watir-classic/matches.rb +7 -3
  30. data/lib/watir-classic/modal_dialog.rb +38 -26
  31. data/lib/watir-classic/non_control_elements.rb +29 -0
  32. data/lib/watir-classic/options.rb +10 -15
  33. data/lib/watir-classic/page-container.rb +30 -48
  34. data/lib/watir-classic/process.rb +4 -2
  35. data/lib/watir-classic/screenshot.rb +6 -0
  36. data/lib/watir-classic/supported_elements.rb +36 -14
  37. data/lib/watir-classic/table.rb +81 -71
  38. data/lib/watir-classic/util.rb +9 -11
  39. data/lib/watir-classic/wait.rb +17 -4
  40. data/lib/watir-classic/wait_helper.rb +15 -2
  41. data/lib/watir-classic/win32.rb +2 -1
  42. data/lib/watir-classic/window.rb +35 -7
  43. data/lib/watir-classic/xpath_locator.rb +1 -0
  44. data/lib/watir-classic/yard/global_macros.rb +7 -0
  45. data/spec/frame_spec.rb +17 -0
  46. metadata +5 -7
  47. data/lib/watir-classic/close_all.rb +0 -31
  48. data/lib/watir-classic/contrib/enabled_popup.rb +0 -21
  49. data/lib/watir-classic/contrib/ie-new-process.rb +0 -27
  50. data/lib/watir-classic/contrib/page_checker.rb +0 -29
  51. data/watir.gif +0 -0
data/CHANGES CHANGED
@@ -1,3 +1,20 @@
1
+ == 3.4.0 - 2013/01/06
2
+
3
+ * All deprecated methods will print out warnings.
4
+ * Documentation overhaul - http://rubydoc.info/github/watir/watir-classic/frames
5
+ * Element#flash returns self instead of nil.
6
+ * Fix frame locator in Frame#attach_command (issue #45).
7
+ * Remove :zero_based_indexing option - from now on all index options are starting from zero.
8
+ * Remove global variable $HIDE_IE - use IE.visible= method instead. Support for command line switch -b is also removed.
9
+ * Remove global varialbe $FAST_SPEED - IE.speed= method instead. Support for command line switch -f is also removed.
10
+ * Remove IE#close_all - use browser.windows.each(&:close) instead.
11
+ * Remove IE#close_modal - use browser.modal_dialog.close instead.
12
+ * Remove IE#close_others - use browser.windows.reject(&:current?).each(&:close) instead.
13
+ * Remove unused ie-new-process.rb.
14
+ * Remove unused PageContainer module.
15
+ * Remove unused PageContainer#check_for_http_error.
16
+ * Remove unused PageContainer#enabled_popup - use browser.modal_dialog instead.
17
+
1
18
  == 3.3.0 - 2012/10/27
2
19
 
3
20
  * Add support for optional Element#style property argument, which allows to get specific css style attribute value.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- watir-classic (3.2.0)
4
+ watir-classic (3.3.0)
5
5
  ffi (~> 1.0)
6
6
  multi_json
7
7
  nokogiri
@@ -14,22 +14,23 @@ PATH
14
14
  GEM
15
15
  remote: http://rubygems.org/
16
16
  specs:
17
- builder (3.1.3)
17
+ builder (3.1.4)
18
18
  childprocess (0.3.4)
19
19
  ffi (~> 1.0, >= 1.0.6)
20
20
  diff-lcs (1.1.3)
21
21
  ffi (1.1.3-x86-mingw32)
22
- hoe (3.0.8)
22
+ hoe (3.3.0)
23
23
  rake (~> 0.8)
24
24
  mini_magick (3.2.1)
25
25
  subexec (~> 0.0.4)
26
- multi_json (1.3.6)
26
+ multi_json (1.3.7)
27
27
  nokogiri (1.5.5-x86-mingw32)
28
28
  rack (1.4.1)
29
29
  rack-protection (1.2.0)
30
30
  rack
31
- rake (0.9.2.2)
32
- rautomation (0.7.2)
31
+ rake (0.9.4)
32
+ rautomation (0.7.3)
33
+ ffi
33
34
  rspec (2.11.0)
34
35
  rspec-core (~> 2.11.0)
35
36
  rspec-expectations (~> 2.11.0)
@@ -63,8 +64,8 @@ GEM
63
64
  windows-pr (1.2.2)
64
65
  win32-api (>= 1.4.5)
65
66
  windows-api (>= 0.3.0)
66
- xml-simple (1.1.1)
67
- yard (0.8.2.1)
67
+ xml-simple (1.1.2)
68
+ yard (0.8.3)
68
69
 
69
70
  PLATFORMS
70
71
  x86-mingw32
data/LICENSE CHANGED
@@ -2,6 +2,7 @@
2
2
  Copyright (c) 2004 - 2006, Paul Rogers
3
3
  Copyright (c) 2006 - 2007, Angrez Singh
4
4
  Copyright (c) 2004 - 2010, Bret Pettichord
5
+ Copyright (c) 2010 - 2013, Jarmo Pertman
5
6
  All rights reserved.
6
7
 
7
8
  Redistribution and use in source and binary forms, with or without
data/README.rdoc CHANGED
@@ -1,18 +1,17 @@
1
1
  = Watir Classic
2
2
 
3
- Watir, pronounced water, is an open-source (BSD) family of Ruby libraries for automating web browsers.
4
- It supports your app no matter what technology it is developed in.
5
- They support Internet Explorer on Windows, Firefox and Chrome on Windows, Mac and Linux and Safari on Mac.
3
+ Watir Classic is a Watir[https://github.com/watir/watir] driver for automating Internet Explorer on Windows.
6
4
 
7
5
  Project Home:: http://watir.com
6
+ Documentation:: http://rubydoc.info/github/watir/watir-classic/frames
8
7
  Source Code:: http://github.com/watir/watir-classic
9
8
  Support:: http://watir.com/support
10
9
  Gem:: https://rubygems.org/gems/watir-classic
11
10
 
12
11
  == Install
13
12
 
14
- You have to install Ruby and RubyGems first.
15
- gem update --system
13
+ Install the gem:
14
+
16
15
  gem install watir-classic
17
16
 
18
17
  Detailed installation instructions are at http://watir.com/installation
@@ -25,7 +24,7 @@ Loading Watir gem to drive Internet Explorer on Windows
25
24
 
26
25
  require 'watir-classic'
27
26
 
28
- Starting a new browser & and going to our site
27
+ Starting a new browser & going to our site
29
28
 
30
29
  browser = Watir::Browser.new
31
30
  browser.goto("http://bit.ly/watir-example")
@@ -56,7 +55,7 @@ Clicking a button
56
55
  Clearing, getting and selecting selection list values
57
56
 
58
57
  browser.select_list(:name => "entry.6.single").clear
59
- puts browser.select_list(:name => "entry.6.single").options
58
+ puts browser.select_list(:name => "entry.6.single").options.map(&:text)
60
59
  browser.select_list(:name => "entry.6.single").select "Chrome"
61
60
 
62
61
  Clicking a button
data/Rakefile CHANGED
@@ -13,7 +13,9 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
13
13
  end
14
14
 
15
15
  require 'yard'
16
- YARD::Rake::YardocTask.new
16
+ YARD::Rake::YardocTask.new do |t|
17
+ t.files = ["lib/watir-classic/yard/global_macros.rb", "lib/**/*.rb"]
18
+ end
17
19
 
18
20
  #
19
21
  # ------------------------------ watirspec -----------------------------------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.4.0
data/lib/watir-classic.rb CHANGED
@@ -1,8 +1,3 @@
1
- #--
2
- # The 'watir-classic' library loads the common watir-classic code, common to all watir-classic
3
- # implementations. The 'watir-classic/browser' library will autoload the actual
4
- # implementations.
5
-
6
1
  require 'watir-classic/version'
7
2
  require 'watir-classic/wait'
8
3
  require 'watir-classic/wait_helper'
@@ -1,4 +1,3 @@
1
- # watir-classic/browser
2
1
  require 'watir-classic/options'
3
2
  module Watir
4
3
 
@@ -11,74 +10,82 @@ Watir drives browsers the same way people do. It clicks links, fills in forms,
11
10
  presses buttons. Watir also checks results, such as whether expected text
12
11
  appears on a page.
13
12
 
14
- The Watir family currently includes support for Internet Explorer (on Windows),
15
- Firefox (on Windows, Mac and Linux) and Safari (on Mac).
13
+ The Watir Classic is a driver for Internet Explorer (on Windows).
16
14
 
17
- Project Homepage: http://wtr.rubyforge.org
15
+ Project Homepage: http://watir.com
18
16
 
19
- This Browser module provides a generic interface
20
- that tests can use to access any browser. The actual browser (and thus
21
- the actual Watir driver) is determined at runtime based on configuration
22
- settings.
17
+ @example usage
23
18
 
24
19
  require 'watir-classic'
25
20
  browser = Watir::Browser.new
26
21
  browser.goto 'http://google.com'
27
- browser.text_field(:name, 'q').set 'pickaxe'
28
- browser.button(:name, 'btnG').click
22
+ browser.text_field(:name => 'q').set 'pickaxe'
23
+ browser.button(:name => 'btnG').click
29
24
  if browser.text.include? 'Programming Ruby'
30
25
  puts 'Text was found'
31
26
  else
32
27
  puts 'Text was not found'
33
28
  end
34
29
 
35
- A comprehensive summary of the Watir API can be found here
36
- http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
37
-
38
- There are two ways to configure the browser that will be used by your tests.
39
-
40
- One is to set the +watir_browser+ environment variable to +ie+ or +firefox+.
41
- (How you do this depends on your platform.)
42
-
43
- The other is to create a file that looks like this.
44
-
45
- browser: ie
46
-
47
- And then to add this line to your script, after the require statement and
48
- before you invoke Browser.new.
49
-
50
- Watir.options_file = 'path/to/the/file/you/just/created'
51
-
52
30
  =end rdoc
53
31
 
54
32
  class Browser
33
+ # @private
55
34
  @@browser_classes = {}
35
+
36
+ # @private
56
37
  @@sub_options = {}
38
+
39
+ # @private
57
40
  @@default = nil
41
+
58
42
  class << self
59
43
 
60
- # Create a new instance of a browser driver, as determined by the
61
- # configuration settings. (Don't be fooled: this is not actually
62
- # an instance of Browser class.)
63
- def new ignored=nil # argument is needed to make watir-classic more compatible with watir-webdriver
44
+ # Create a new instance of the {Browser} object
45
+ # @param [Object] ignored Argument is only needed to make
46
+ # watir-classic more compatible with watir-webdriver and is really ignored.
47
+ def new(ignored=nil)
64
48
  set_sub_options
65
49
  klass.new
66
50
  end
67
- # Create a new instance as with #new and start the browser on the
51
+
52
+ # Create a new {Browser} instance as with {.new} and start the browser on the
68
53
  # specified url.
69
- def start url
54
+ # @param [String] url Url to start the browser at.
55
+ def start(url)
70
56
  set_sub_options
71
57
  klass.start url
72
58
  end
73
- # Attach to an existing browser.
59
+
60
+ # Attach to an existing IE {Browser}.
61
+ #
62
+ # @example Attach with full title:
63
+ # Watir::Browser.attach(:title, "Full title of IE")
64
+ #
65
+ # @example Attach with part of the title using {Regexp}:
66
+ # Watir::Browser.attach(:title, /part of the title of IE/)
67
+ #
68
+ # @example Attach with part of the url:
69
+ # Watir::Browser.attach(:url, /google/)
70
+ #
71
+ # @example Attach with window handle:
72
+ # Watir::Browser.attach(:hwnd, 123456)
73
+ #
74
+ # @param [Symbol] how type of the locator. Can be :title, :url or :hwnd.
75
+ # @param [Symbol] what value of the locator. Can be {String}, {Regexp} or {Fixnum}
76
+ # depending of the type parameter.
74
77
  def attach(how, what)
75
78
  set_sub_options
76
79
  klass.attach(how, what)
77
80
  end
78
- def set_options options
81
+
82
+ # Set options for the {Browser}.
83
+ def set_options(options)
79
84
  return unless klass.respond_to?(:set_options)
80
85
  klass.set_options options
81
86
  end
87
+
88
+ # @return [Hash] options of the {Browser}.
82
89
  def options
83
90
  return {} unless klass.respond_to?(:options)
84
91
  klass.options
@@ -89,11 +96,14 @@ before you invoke Browser.new.
89
96
  eval @@browser_classes[key] # this triggers the autoload
90
97
  end
91
98
  private :klass
99
+
92
100
  # Add support for the browser option, using the specified class,
93
101
  # provided as a string. Optionally, additional options supported by
94
102
  # the class can be specified as an array of symbols. Options specified
95
103
  # by the user and included in this list will be passed (as a hash) to
96
104
  # the set_options class method (if defined) before creating an instance.
105
+ # @todo remove this and autoloading since now only IE is supported.
106
+ # @private
97
107
  def support hash_args
98
108
  option = hash_args[:name]
99
109
  class_string = hash_args[:class]
@@ -108,26 +118,37 @@ before you invoke Browser.new.
108
118
  activate_gem gem, option
109
119
  end
110
120
 
121
+ # @private
111
122
  def default
112
123
  @@default
113
124
  end
125
+
114
126
  # Specifies a default browser. Must be specified before options are parsed.
127
+ # @todo remove this since only IE is supported.
128
+ # @private
115
129
  def default= option
116
130
  @@default = option
117
131
  end
132
+
118
133
  # Returns the names of the browsers that are supported by this module.
119
134
  # These are the options for 'watir_browser' (env var) or 'browser:' (yaml).
135
+ # @todo remove this since only IE is supported.
136
+ # @private
120
137
  def browser_names
121
138
  @@browser_classes.keys
122
139
  end
123
140
 
124
141
  private
142
+
143
+ # @todo remove this since only IE is supported.
125
144
  def autoload class_string, library
126
145
  mod, klass = class_string.split('::')
127
146
  eval "module ::#{mod}; autoload :#{klass}, '#{library}'; end"
128
147
  end
148
+
129
149
  # Activate the gem (if installed). The default browser will be set
130
150
  # to the first gem that activates.
151
+ # @todo remove this since only IE is supported.
131
152
  def activate_gem gem_name, option
132
153
  begin
133
154
  gem gem_name
@@ -135,6 +156,8 @@ before you invoke Browser.new.
135
156
  rescue Gem::LoadError
136
157
  end
137
158
  end
159
+
160
+ # @todo remove this since only IE is supported.
138
161
  def set_sub_options
139
162
  sub_options = @@sub_options[Watir.options[:browser]]
140
163
  return if sub_options.nil?
@@ -4,4 +4,4 @@
4
4
 
5
5
  Watir::Browser.support :name => 'ie', :class => 'Watir::IE',
6
6
  :library => 'watir-classic/ie', :gem => 'watir-classic',
7
- :options => [:speed, :visible, :zero_based_indexing]
7
+ :options => [:speed, :visible]
@@ -1,5 +1,5 @@
1
1
  module Watir
2
- # This module contains the factory methods that are used to access most html objects
2
+ # This module contains the factory methods that are used to access all html objects.
3
3
  #
4
4
  # For example, to access a button on a web page that has the following html
5
5
  # <input type=button name='b1' value='Click Me' onClick='javascript:doSomething()'>
@@ -12,71 +12,77 @@ module Watir
12
12
  #
13
13
  # browser.button(:value, 'Click Me').name
14
14
  #
15
- # there are many methods available to the Button object
16
- #--
17
- # Is includable for classes that have @container, document and __ole_inner_elements
15
+ # there are many methods available to the {Button} object
18
16
  module Container
19
17
  include Watir::Exception
20
18
 
19
+ # The {Browser} object containing this element.
20
+ attr_accessor :page_container
21
+ alias_method :browser, :page_container
22
+
21
23
  # Note: @container is the container of this object, i.e. the container
22
24
  # of this container.
23
25
  # In other words, for browser.table().this_thing().text_field().set,
24
26
  # container of this_thing is the table.
25
27
 
26
28
  # This is used to change the typing speed when entering text on a page.
29
+ # @private
27
30
  attr_accessor :typingspeed
31
+
32
+ # @private
28
33
  attr_accessor :type_keys
34
+
29
35
  # The color we want to use for the active object. This can be any valid web-friendly color.
30
- attr_accessor :activeObjectHighLightColor
31
- # The PageContainer object containing this element
32
- attr_accessor :page_container
33
- alias_method :browser, :page_container
34
-
35
- def copy_test_config(container) # only used by form and frame
36
- @typingspeed = container.typingspeed
37
- @type_keys = container.type_keys
38
- @activeObjectHighLightColor = container.activeObjectHighLightColor
36
+ # @private
37
+ attr_accessor :active_object_highlight_color
38
+
39
+ # @return [ModalDialog] modal dialog instance.
40
+ def modal_dialog
41
+ ModalDialog.new(self)
39
42
  end
40
- private :copy_test_config
41
-
43
+
44
+ # Retrieve the JavaScript dialog instance.
45
+ # Supported dialogs are alert, confirm and prompt.
46
+ # @return [Alert] JavaScript dialog instance.
47
+ def alert
48
+ Alert.new(self)
49
+ end
50
+
42
51
  # Wait until Browser has finished loading the page.
43
52
  #--
44
53
  # called explicitly by most click and set methods
54
+ # @private
45
55
  def wait(no_sleep=false)
46
56
  @container.wait(no_sleep)
47
57
  end
48
58
 
49
- def set_container container #:nodoc:
59
+ # @private
60
+ def set_container(container)
50
61
  @container = container
51
62
  @page_container = container.page_container
52
63
  end
53
64
 
54
- public
55
-
56
- def modal_dialog
57
- ModalDialog.new(self)
58
- end
59
-
60
- def alert
61
- Alert.new(self)
62
- end
63
-
64
65
  # Searching for Page Elements
65
66
  # Not for external consumption
66
- #
67
- #++
67
+ # @private
68
68
  def __ole_inner_elements
69
- return document.body.all
69
+ document.body.all
70
70
  end
71
71
 
72
- # Locator Methods
73
- #
74
72
  # Not for external use, but cannot set to private due to usages in Element
75
73
  # classes.
76
-
74
+ # @private
77
75
  def locator_for(locator_class, specifiers, klass)
78
76
  locator_class.new self, specifiers, klass
79
77
  end
78
+
79
+ private
80
+
81
+ def copy_test_config(container) # only used by form and frame
82
+ @typingspeed = container.typingspeed
83
+ @type_keys = container.type_keys
84
+ @active_object_high_light_color = container.active_object_highlight_color
85
+ end
80
86
 
81
- end # module
87
+ end
82
88
  end