watir 6.14.0 → 6.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +24 -6
  3. data/CHANGES.md +10 -0
  4. data/Gemfile +0 -2
  5. data/README.md +1 -1
  6. data/Rakefile +2 -2
  7. data/lib/watir.rb +2 -3
  8. data/lib/watir/adjacent.rb +2 -2
  9. data/lib/watir/alert.rb +5 -9
  10. data/lib/watir/attribute_helper.rb +2 -3
  11. data/lib/watir/browser.rb +5 -17
  12. data/lib/watir/capabilities.rb +11 -0
  13. data/lib/watir/cell_container.rb +2 -2
  14. data/lib/watir/container.rb +7 -8
  15. data/lib/watir/cookies.rb +2 -12
  16. data/lib/watir/element_collection.rb +2 -2
  17. data/lib/watir/elements/button.rb +2 -11
  18. data/lib/watir/elements/element.rb +43 -25
  19. data/lib/watir/elements/hidden.rb +1 -1
  20. data/lib/watir/elements/iframe.rb +7 -5
  21. data/lib/watir/elements/option.rb +2 -13
  22. data/lib/watir/elements/select.rb +6 -22
  23. data/lib/watir/elements/table.rb +2 -2
  24. data/lib/watir/exception.rb +1 -2
  25. data/lib/watir/generator/base/idl_sorter.rb +1 -1
  26. data/lib/watir/generator/base/spec_extractor.rb +2 -2
  27. data/lib/watir/generator/base/visitor.rb +1 -1
  28. data/lib/watir/generator/html/generator.rb +0 -1
  29. data/lib/watir/generator/html/spec_extractor.rb +1 -1
  30. data/lib/watir/generator/html/visitor.rb +1 -1
  31. data/lib/watir/generator/svg/spec_extractor.rb +1 -1
  32. data/lib/watir/generator/svg/visitor.rb +1 -1
  33. data/lib/watir/js_execution.rb +11 -0
  34. data/lib/watir/js_snippets.rb +1 -1
  35. data/lib/watir/js_snippets/elementObscured.js +14 -0
  36. data/lib/watir/js_snippets/selectedText.js +17 -0
  37. data/lib/watir/legacy_wait.rb +5 -5
  38. data/lib/watir/locators.rb +16 -5
  39. data/lib/watir/locators/anchor/selector_builder.rb +38 -0
  40. data/lib/watir/locators/button/locator.rb +14 -12
  41. data/lib/watir/locators/button/selector_builder.rb +0 -22
  42. data/lib/watir/locators/button/selector_builder/xpath.rb +67 -12
  43. data/lib/watir/locators/button/validator.rb +2 -1
  44. data/lib/watir/locators/cell/selector_builder.rb +0 -14
  45. data/lib/watir/locators/cell/selector_builder/xpath.rb +21 -0
  46. data/lib/watir/locators/element/locator.rb +60 -153
  47. data/lib/watir/locators/element/selector_builder.rb +103 -84
  48. data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +66 -0
  49. data/lib/watir/locators/element/selector_builder/xpath.rb +195 -82
  50. data/lib/watir/locators/element/selector_builder/xpath_support.rb +27 -0
  51. data/lib/watir/locators/element/validator.rb +2 -9
  52. data/lib/watir/locators/row/selector_builder.rb +5 -22
  53. data/lib/watir/locators/row/selector_builder/xpath.rb +53 -0
  54. data/lib/watir/locators/text_area/selector_builder.rb +1 -1
  55. data/lib/watir/locators/text_area/selector_builder/xpath.rb +19 -0
  56. data/lib/watir/locators/text_field/locator.rb +11 -8
  57. data/lib/watir/locators/text_field/selector_builder.rb +0 -23
  58. data/lib/watir/locators/text_field/selector_builder/xpath.rb +33 -4
  59. data/lib/watir/locators/text_field/validator.rb +4 -4
  60. data/lib/watir/radio_set.rb +5 -5
  61. data/lib/watir/row_container.rb +2 -2
  62. data/lib/watir/user_editable.rb +2 -2
  63. data/lib/watir/version.rb +1 -1
  64. data/lib/watir/wait.rb +24 -37
  65. data/lib/watir/window.rb +11 -8
  66. data/lib/watirspec/remote_server.rb +3 -1
  67. data/spec/locator_spec_helper.rb +1 -1
  68. data/spec/spec_helper.rb +25 -1
  69. data/spec/unit/anchor_locator_spec.rb +68 -0
  70. data/spec/unit/capabilities_spec.rb +27 -0
  71. data/spec/unit/element_locator_spec.rb +184 -101
  72. data/spec/unit/logger_spec.rb +5 -0
  73. data/spec/watirspec/adjacent_spec.rb +34 -34
  74. data/spec/watirspec/after_hooks_spec.rb +78 -35
  75. data/spec/watirspec/alert_spec.rb +10 -0
  76. data/spec/watirspec/browser_spec.rb +27 -1
  77. data/spec/watirspec/element_hidden_spec.rb +6 -0
  78. data/spec/watirspec/elements/button_spec.rb +5 -11
  79. data/spec/watirspec/elements/buttons_spec.rb +1 -1
  80. data/spec/watirspec/elements/checkbox_spec.rb +2 -15
  81. data/spec/watirspec/elements/date_time_field_spec.rb +6 -1
  82. data/spec/watirspec/elements/dd_spec.rb +0 -17
  83. data/spec/watirspec/elements/del_spec.rb +0 -14
  84. data/spec/watirspec/elements/div_spec.rb +0 -18
  85. data/spec/watirspec/elements/dl_spec.rb +0 -17
  86. data/spec/watirspec/elements/dt_spec.rb +0 -17
  87. data/spec/watirspec/elements/element_spec.rb +177 -17
  88. data/spec/watirspec/elements/elements_spec.rb +7 -6
  89. data/spec/watirspec/elements/em_spec.rb +0 -13
  90. data/spec/watirspec/elements/filefield_spec.rb +0 -11
  91. data/spec/watirspec/elements/form_spec.rb +6 -0
  92. data/spec/watirspec/elements/hn_spec.rb +0 -14
  93. data/spec/watirspec/elements/iframe_spec.rb +15 -0
  94. data/spec/watirspec/elements/ins_spec.rb +0 -14
  95. data/spec/watirspec/elements/labels_spec.rb +1 -1
  96. data/spec/watirspec/elements/li_spec.rb +0 -14
  97. data/spec/watirspec/elements/link_spec.rb +22 -14
  98. data/spec/watirspec/elements/links_spec.rb +13 -0
  99. data/spec/watirspec/elements/list_spec.rb +15 -0
  100. data/spec/watirspec/elements/ol_spec.rb +0 -14
  101. data/spec/watirspec/elements/option_spec.rb +0 -10
  102. data/spec/watirspec/elements/p_spec.rb +0 -14
  103. data/spec/watirspec/elements/pre_spec.rb +0 -14
  104. data/spec/watirspec/elements/radio_spec.rb +0 -14
  105. data/spec/watirspec/elements/select_list_spec.rb +0 -10
  106. data/spec/watirspec/elements/span_spec.rb +4 -15
  107. data/spec/watirspec/elements/strong_spec.rb +4 -15
  108. data/spec/watirspec/elements/table_nesting_spec.rb +1 -1
  109. data/spec/watirspec/elements/table_spec.rb +7 -0
  110. data/spec/watirspec/elements/text_field_spec.rb +10 -2
  111. data/spec/watirspec/elements/text_fields_spec.rb +1 -1
  112. data/spec/watirspec/elements/tr_spec.rb +1 -1
  113. data/spec/watirspec/elements/ul_spec.rb +0 -14
  114. data/spec/watirspec/html/closeable.html +8 -0
  115. data/spec/watirspec/html/forms_with_input_elements.html +28 -23
  116. data/spec/watirspec/html/nested_elements.html +9 -9
  117. data/spec/watirspec/html/obscured.html +34 -0
  118. data/spec/watirspec/html/tables.html +13 -13
  119. data/spec/watirspec/radio_set_spec.rb +5 -0
  120. data/spec/watirspec/selector_builder/button_spec.rb +254 -0
  121. data/spec/watirspec/selector_builder/cell_spec.rb +93 -0
  122. data/spec/watirspec/selector_builder/element_spec.rb +639 -0
  123. data/spec/watirspec/selector_builder/row_spec.rb +150 -0
  124. data/spec/watirspec/selector_builder/text_spec.rb +170 -0
  125. data/spec/watirspec/support/rspec_matchers.rb +6 -1
  126. data/spec/watirspec/user_editable_spec.rb +4 -0
  127. data/spec/watirspec/wait_spec.rb +65 -14
  128. data/spec/watirspec/window_switching_spec.rb +54 -1
  129. data/spec/watirspec_helper.rb +2 -0
  130. data/watir.gemspec +7 -1
  131. metadata +86 -8
  132. data/lib/watir/locators/text_area/locator.rb +0 -13
  133. data/lib/watir/xpath_support.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a6cd2d994ac6819dcc74e5b15639de4061bf1fe
4
- data.tar.gz: f713658a590057181b64c8cfb26e2c278c02fdda
3
+ metadata.gz: d985e9510a911174b9ba60c5d3174eb67fc612b5
4
+ data.tar.gz: f7a5ba01ad7bea4f7fe8222c55f571e5340d8725
5
5
  SHA512:
6
- metadata.gz: c55e3c6cb644323b2e1e4dfe0b1488a9c0a53733d88022f4986e55cfb6ee0ad5b4b64c5604f096df2d702d86f4d2393012f6ad507468e88fad4be89c10fbbee1
7
- data.tar.gz: 07f6e39aa359c8c89b2dc012a7ce6ef4a4c17b68645ef827aed01bb03cf130217e94c69eb0fadc5d41826708fe672c443b73c80e54613f7e08ca81c2f1bbad04
6
+ metadata.gz: 4ba1c06f7bfeaa9c8ac573ca2b023a23dc5222741d925db41d77e72bfaeb46d5a7f217560337d1afbf8e8d9204b050dcded5ff50218ba5129ba48ceff3adf3db
7
+ data.tar.gz: 98e3d14ab62868105c6e7af9108fbfd341fbc6f181baae28235b2aca8bafdad9c0c9e9b5c664c809a69bb84b80320e08adfd217751df0f4a87f2c30b794b5a04
@@ -53,28 +53,42 @@ Metrics/ModuleLength:
53
53
  # Configuration parameters: CountComments.
54
54
  Metrics/MethodLength:
55
55
  Max: 18
56
+ Exclude:
57
+ - 'lib/watir/locators/element/selector_builder.rb'
58
+ - 'lib/watir/locators/element/selector_builder/xpath.rb'
59
+ - 'lib/watir/locators/element/selector_builder/regexp_disassembler.rb'
56
60
 
57
61
  # Configuration parameters: CountComments.
58
62
  Metrics/ClassLength:
59
- Max: 116
63
+ Max: 95
60
64
  Exclude:
65
+ - 'lib/watir/capabilities.rb'
61
66
  - 'lib/watir/locators/element/locator.rb'
67
+ - 'lib/watir/locators/element/selector_builder.rb'
68
+ - 'lib/watir/locators/element/selector_builder/xpath.rb'
62
69
  - 'lib/watir/browser.rb'
70
+ - 'lib/watir/window.rb'
63
71
  - 'lib/watir/elements/element.rb'
64
72
  - 'lib/watir/elements/select.rb'
73
+ - 'lib/watir/generator/base/spec_extractor.rb'
65
74
 
66
75
  Metrics/PerceivedComplexity:
67
- Max: 9
76
+ Max: 10
68
77
 
69
78
  Metrics/CyclomaticComplexity:
70
- Max: 9
79
+ Max: 8
80
+ Exclude:
81
+ - 'lib/watir/locators/element/selector_builder.rb'
71
82
 
72
- # Offense count: 28
73
83
  Metrics/AbcSize:
74
- Max: 22
84
+ Max: 20
75
85
  Exclude:
76
86
  - 'lib/watir/locators/element/selector_builder.rb'
87
+ - 'lib/watir/locators/element/selector_builder/regexp_disassembler.rb'
88
+ - 'lib/watir/locators/element/selector_builder/xpath.rb'
89
+ - 'lib/watir/locators/element/locator.rb'
77
90
  - 'lib/watir/generator/base/generator.rb'
91
+ - 'lib/watir/generator/base/visitor.rb'
78
92
 
79
93
  # TODO: fix with Watir 7
80
94
  # Configuration parameters: CountKeywordArgs.
@@ -107,6 +121,10 @@ Style/GlobalVars:
107
121
  AllowedVariables:
108
122
  - $browser
109
123
 
124
+ Style/RegexpLiteral:
125
+ Exclude:
126
+ - 'spec/watirspec/selector_builder/element_spec.rb'
127
+
110
128
  ### Cop supports --auto-correct.
111
129
  ### Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
112
130
  ## SupportedStyles: single_quotes, double_quotes
@@ -124,7 +142,7 @@ Style/MethodCallWithoutArgsParentheses:
124
142
  Style/FormatStringToken:
125
143
  Exclude:
126
144
  - 'lib/watir/browser.rb'
127
- - 'lib/watir/locators/text_field/selector_builder.rb'
145
+ - 'lib/watir/locators/text_field/selector_builder/xpath.rb'
128
146
  - 'lib/watir/window.rb'
129
147
 
130
148
  Style/Documentation:
data/CHANGES.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 6.15.0 (2018-11-07)
2
+
3
+ * Add `Element#selected_text`
4
+ * Add `Element#classes`
5
+ * Add `Element#obscured?`
6
+ * Deprecate `#wait_until_present` and `#wait_while_present`
7
+ * Improved Locator classes to reduce wire calls when using multiple/complex locators
8
+ * Fix bug with IE options
9
+ * Allow time values in yaml files for cookies (thanks Ryan Baumann)
10
+
1
11
  ### 6.14.0 (2018-09-13)
2
12
 
3
13
  * HTML Element attribute support updated to HTML 5.2
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'simplecov', '>= 0.3.5', platform: :ruby_19 unless ENV['TRAVIS']
4
-
5
3
  gem 'webidl', path: File.expand_path('../webidl') if ENV['LOCAL_WEBIDL']
6
4
 
7
5
  gem 'selenium-webdriver', path: File.expand_path('../selenium/build/rb') if ENV['LOCAL_SELENIUM']
data/README.md CHANGED
@@ -6,7 +6,7 @@ Watir Powered By Selenium!
6
6
  [![Travis Status](https://travis-ci.org/watir/watir.svg?branch=master)](https://travis-ci.org/watir/watir)
7
7
  [![AppVeyor status](https://ci.appveyor.com/api/projects/status/9vbb7pp5p4uyoott/branch/master?svg=true)](https://ci.appveyor.com/project/p0deje/watir)
8
8
  [![Code Climate](https://codeclimate.com/github/watir/watir.svg)](https://codeclimate.com/github/watir/watir)
9
- [![Coverage Status](https://coveralls.io/repos/watir/watir/badge.svg?branch=master)](https://coveralls.io/r/watir/watir)
9
+ [![Coverage Status](https://coveralls.io/repos/github/watir/watir/badge.svg?branch=master)](https://coveralls.io/github/watir/watir?branch=master)
10
10
 
11
11
  ## Using Watir
12
12
 
data/Rakefile CHANGED
@@ -41,7 +41,7 @@ end
41
41
 
42
42
  File.open(spec_path, 'w') do |io|
43
43
  io << "<!-- downloaded from #{spec_uri} on #{Time.now} -->\n"
44
- io << data = URI.open(spec_uri).read
44
+ io << data = URI.parse(spec_uri).read
45
45
  downloaded_bytes = data.bytesize
46
46
  end
47
47
 
@@ -73,7 +73,7 @@ end
73
73
  generator.generate(spec_path, file)
74
74
  end
75
75
 
76
- system "diff -Naut #{old_file} #{old_file}.new | less" if File.exist?(old_file)
76
+ system "diff -Naut #{old_file} #{old_file}.new" if File.exist?(old_file)
77
77
  end
78
78
 
79
79
  desc "Move #{type}.rb.new to #{type}.rb"
@@ -4,7 +4,6 @@ require 'time'
4
4
  require 'watir/legacy_wait'
5
5
  require 'watir/wait'
6
6
  require 'watir/exception'
7
- require 'watir/xpath_support'
8
7
  require 'watir/window'
9
8
  require 'watir/has_window'
10
9
  require 'watir/adjacent'
@@ -55,7 +54,7 @@ module Watir
55
54
  end
56
55
 
57
56
  #
58
- # Whether or not Watir should prefer CSS when translating the Watir selectors to Selenium.
57
+ # Whether or not Watir should prefer CSS when translating the Watir selector to Selenium.
59
58
  #
60
59
 
61
60
  def prefer_css?
@@ -104,7 +103,7 @@ module Watir
104
103
  #
105
104
 
106
105
  def self.logger
107
- @logger ||= Watir::Logger.new
106
+ @logger ||= Logger.new
108
107
  end
109
108
  end
110
109
  require 'watir/locators'
@@ -59,7 +59,7 @@ module Watir
59
59
  #
60
60
  # @example
61
61
  # browser.text_field(name: "new_user_first_name").following_siblings.size
62
- # #=> 53
62
+ # #=> 55
63
63
  #
64
64
 
65
65
  def following_siblings(opt = {})
@@ -74,7 +74,7 @@ module Watir
74
74
  #
75
75
  # @example
76
76
  # browser.text_field(name: "new_user_first_name").siblings.size
77
- # #=> 57
77
+ # #=> 59
78
78
  #
79
79
 
80
80
  def siblings(opt = {})
@@ -2,6 +2,7 @@ module Watir
2
2
  class Alert
3
3
  include EventuallyPresent
4
4
  include Waitable
5
+ include Exception
5
6
 
6
7
  def initialize(browser)
7
8
  @browser = browser
@@ -79,13 +80,14 @@ module Watir
79
80
  def exists?
80
81
  assert_exists
81
82
  true
82
- rescue Exception::UnknownObjectException
83
+ rescue UnknownObjectException
83
84
  false
84
85
  end
85
86
  alias present? exists?
86
87
 
87
88
  #
88
89
  # @api private
90
+ # @see Watir::Wait
89
91
  #
90
92
 
91
93
  def selector_string
@@ -97,7 +99,7 @@ module Watir
97
99
  def assert_exists
98
100
  @alert = @browser.driver.switch_to.alert
99
101
  rescue Selenium::WebDriver::Error::NoSuchAlertError
100
- raise Exception::UnknownObjectException, 'unable to locate alert'
102
+ raise UnknownObjectException, 'unable to locate alert'
101
103
  end
102
104
 
103
105
  def wait_for_exists
@@ -106,13 +108,7 @@ module Watir
106
108
  begin
107
109
  wait_until(message: 'waiting for alert', &:exists?)
108
110
  rescue Wait::TimeoutError
109
- unless Watir.default_timeout.zero?
110
- message = 'This code has slept for the duration of the default timeout '
111
- message << 'waiting for an Alert to exist. If the test is still passing, '
112
- message << 'consider using Alert#exists? instead of rescuing UnknownObjectException'
113
- Watir.logger.warn message, ids: [:wait_for_alert]
114
- end
115
- raise Exception::UnknownObjectException, 'unable to locate alert'
111
+ raise UnknownObjectException, 'unable to locate alert'
116
112
  end
117
113
  end
118
114
  end # Alert
@@ -52,8 +52,6 @@ module Watir
52
52
 
53
53
  def define_attribute(type, name, attr)
54
54
  case type.to_s
55
- when 'String'
56
- define_string_attribute(name, attr)
57
55
  when 'Boolean'
58
56
  define_boolean_attribute(name, attr)
59
57
  when 'Integer'
@@ -61,7 +59,7 @@ module Watir
61
59
  when 'Float'
62
60
  define_float_attribute(name, attr)
63
61
  else
64
- Watir.logger.debug "treating #{type.inspect} as string for now"
62
+ define_string_attribute(name, attr)
65
63
  end
66
64
  end
67
65
 
@@ -87,6 +85,7 @@ module Watir
87
85
  def define_float_attribute(mname, aname)
88
86
  define_method mname do
89
87
  value = attribute_value(aname)
88
+ value = nil if value == 'NaN'
90
89
  value && Float(value)
91
90
  end
92
91
  end
@@ -8,6 +8,7 @@ module Watir
8
8
  include HasWindow
9
9
  include Waitable
10
10
  include Navigation
11
+ include Exception
11
12
 
12
13
  attr_writer :default_context, :original_window, :locator_namespace
13
14
  attr_reader :driver, :after_hooks
@@ -40,7 +41,7 @@ module Watir
40
41
  def initialize(browser = :chrome, *args)
41
42
  case browser
42
43
  when ::Symbol, String
43
- selenium_args = Watir::Capabilities.new(browser, *args).to_args
44
+ selenium_args = Capabilities.new(browser, *args).to_args
44
45
  @driver = Selenium::WebDriver.for(*selenium_args)
45
46
  when Selenium::WebDriver::Driver
46
47
  @driver = browser
@@ -212,7 +213,7 @@ module Watir
212
213
  #
213
214
 
214
215
  def execute_script(script, *args)
215
- args.map! { |e| e.is_a?(Watir::Element) ? e.wd : e }
216
+ args.map! { |e| e.is_a?(Element) ? e.wd : e }
216
217
 
217
218
  wrap_elements_in(self, @driver.execute_script(script, *args))
218
219
  end
@@ -252,21 +253,8 @@ module Watir
252
253
  end
253
254
  alias exists? exist?
254
255
 
255
- #
256
- # Protocol shared with Watir::Element
257
- #
258
- # @api private
259
- #
260
-
261
- def assert_exists
262
- locate
263
- return if window.present?
264
-
265
- raise Exception::NoMatchingWindowFoundException, 'browser window was closed'
266
- end
267
-
268
256
  def locate
269
- raise Exception::Error, 'browser was closed' if @closed
257
+ raise Error, 'browser was closed' if @closed
270
258
 
271
259
  ensure_context
272
260
  end
@@ -298,7 +286,7 @@ module Watir
298
286
  #
299
287
 
300
288
  def locator_namespace
301
- @locator_namespace ||= Watir::Locators
289
+ @locator_namespace ||= Locators
302
290
  end
303
291
 
304
292
  #
@@ -113,6 +113,17 @@ module Watir
113
113
  if @browser == :safari && @options.delete(:technology_preview)
114
114
  @options['safari.options'] = {'technologyPreview' => true}
115
115
  end
116
+ when :ie
117
+ if @options.key?(:args)
118
+ browser_options ||= {}
119
+ browser_options[:args] = @options.delete(:args).dup
120
+ end
121
+ unless browser_options.is_a? Selenium::WebDriver::IE::Options
122
+ ie_caps = browser_options.select { |k| Selenium::WebDriver::IE::Options::CAPABILITIES.include?(k) }
123
+ browser_options = Selenium::WebDriver::IE::Options.new(browser_options)
124
+ ie_caps.each { |k, v| browser_options.add_option(k, v) }
125
+ end
126
+ @selenium_opts[:options] = browser_options
116
127
  end
117
128
  end
118
129
  # rubocop:enable Metrics/AbcSize
@@ -7,7 +7,7 @@ module Watir
7
7
  #
8
8
 
9
9
  def cell(*args)
10
- Cell.new(self, extract_selector(args).merge(tag_name: /^(th|td)$/))
10
+ Cell.new(self, extract_selector(args))
11
11
  end
12
12
 
13
13
  #
@@ -17,7 +17,7 @@ module Watir
17
17
  #
18
18
 
19
19
  def cells(*args)
20
- CellCollection.new(self, extract_selector(args).merge(tag_name: /^(th|td)$/))
20
+ CellCollection.new(self, extract_selector(args))
21
21
  end
22
22
  end # CellContainer
23
23
  end # Watir
@@ -1,6 +1,5 @@
1
1
  module Watir
2
2
  module Container
3
- include XpathSupport
4
3
  include JSSnippets
5
4
 
6
5
  #
@@ -33,22 +32,22 @@ module Watir
33
32
  # @api private
34
33
  #
35
34
 
36
- def extract_selector(selectors)
37
- case selectors.size
35
+ def extract_selector(selector)
36
+ case selector.size
38
37
  when 2
39
- msg = "Using ordered parameters to locate elements (:#{selectors.first}, #{selectors.last.inspect})"
38
+ msg = "Using ordered parameters to locate elements (:#{selector.first}, #{selector.last.inspect})"
40
39
  Watir.logger.deprecate msg,
41
- "{#{selectors.first}: #{selectors.last.inspect}}",
40
+ "{#{selector.first}: #{selector.last.inspect}}",
42
41
  ids: [:selector_parameters]
43
- return {selectors[0] => selectors[1]}
42
+ return {selector[0] => selector[1]}
44
43
  when 1
45
- obj = selectors.first
44
+ obj = selector.first
46
45
  return obj if obj.is_a? Hash
47
46
  when 0
48
47
  return {}
49
48
  end
50
49
 
51
- raise ArgumentError, "expected Hash, got #{selectors.inspect}"
50
+ raise ArgumentError, "expected Hash, got #{selector.inspect}"
52
51
  end
53
52
  end # Container
54
53
  end # Watir
@@ -18,7 +18,7 @@ module Watir
18
18
 
19
19
  def to_a
20
20
  @control.all_cookies.map do |e|
21
- e.merge(expires: e[:expires] ? to_time(e[:expires]) : nil)
21
+ e.merge(expires: e[:expires] ? e[:expires].to_time : nil)
22
22
  end
23
23
  end
24
24
 
@@ -115,19 +115,9 @@ module Watir
115
115
  #
116
116
 
117
117
  def load(file = '.cookies')
118
- YAML.safe_load(IO.read(file), [::Symbol]).each do |c|
118
+ YAML.safe_load(IO.read(file), [::Symbol, ::Time]).each do |c|
119
119
  add(c.delete(:name), c.delete(:value), c)
120
120
  end
121
121
  end
122
-
123
- private
124
-
125
- def to_time(time)
126
- if time.respond_to?(:to_time)
127
- time.to_time
128
- else
129
- ::Time.local time.year, time.month, time.day, time.hour, time.min, time.sec
130
- end
131
- end
132
122
  end # Cookies
133
123
  end # Watir
@@ -90,8 +90,8 @@ module Watir
90
90
  selector = @selector.merge(element: e)
91
91
  selector[:index] = idx
92
92
  element = element_class.new(@query_scope, selector)
93
- if [Watir::HTMLElement, Watir::Input].include? element.class
94
- tag_name = @selector[:tag_name] || element.tag_name.to_sym
93
+ if [HTMLElement, Input].include? element.class
94
+ tag_name = @selector[:tag_name] || element.tag_name
95
95
  hash[tag_name] ||= 0
96
96
  hash[tag_name] += 1
97
97
  selector[:index] = hash[tag_name] - 1
@@ -6,7 +6,7 @@ module Watir
6
6
  #
7
7
 
8
8
  class Button < HTMLElement
9
- inherit_attributes_from Watir::Input
9
+ inherit_attributes_from Input
10
10
 
11
11
  VALID_TYPES = %w[button reset submit image].freeze
12
12
 
@@ -20,16 +20,7 @@ module Watir
20
20
  #
21
21
 
22
22
  def text
23
- tn = tag_name
24
-
25
- case tn
26
- when 'input'
27
- value
28
- when 'button'
29
- super
30
- else
31
- raise Exception::Error, "unknown tag name for button: #{tn}"
32
- end
23
+ tag_name == 'input' ? value : super
33
24
  end
34
25
  end # Button
35
26
  end # Watir