selenium-webdriver 2.24.0 → 2.25.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,22 @@
1
+ 2.25.0 (2012-07-19)
2
+ ===================
3
+
4
+ * Respect no_proxy / NO_PROXY env vars (#4007).
5
+ * Improve error message if a configured proxy refuses the connection.
6
+ * Ignored exception can be configured on the Wait class.
7
+ * Add Selenium::WebDriver::Support::Color class.
8
+ * Ignore Errno::ENETUNREACH when trying to detect our local IP (#4165).
9
+ * Ignore Errno::EADDRNOTAVAIL in PortProber (#3987).
10
+ * Firefox:
11
+ * Enumerate through client rects until finding one with non-zero dimensions when clicking.
12
+ * Updated supported versions of Firefox to 17.
13
+ * Allow windows to be resized from a frame (#3897).
14
+ * Fix an issue where a call to submit could hang the driver.
15
+ * IE:
16
+ * Ability to configure logging through the :log_file and :log_level options.
17
+ * Increasing stability of file upload dialog handling (#3858)
18
+ * Better handling of overflow edge cases when determining element visibility.
19
+
1
20
  2.24.0 (2012-06-19)
2
21
  ===================
3
22
 
@@ -128,7 +128,13 @@ module Selenium
128
128
  alias_method :send_key, :send_keys
129
129
 
130
130
  #
131
- # Clear this element
131
+ # If this element is a text entry element, this will clear the value. Has no effect on other
132
+ # elements. Text entry elements are INPUT and TEXTAREA elements.
133
+ #
134
+ # Note that the events fired by this event may not be as you'd expect. In particular, we don't
135
+ # fire any keyboard or mouse events. If you want to ensure keyboard events are
136
+ # fired, consider using #send_keys with the backspace key. To ensure you get a change event,
137
+ # consider following with a call to #send_keys with the tab key.
132
138
  #
133
139
 
134
140
  def clear
@@ -188,19 +188,11 @@ module Selenium
188
188
  ]
189
189
 
190
190
  # aliased for backwards compatibility
191
- ObsoleteElementError = StaleElementReferenceError
192
-
193
- # aliased for backwards compatibility
194
- UnhandledError = UnknownError
195
-
196
- # aliased for backwards compatibility
191
+ ObsoleteElementError = StaleElementReferenceError
192
+ UnhandledError = UnknownError
197
193
  UnexpectedJavascriptError = JavascriptError
198
-
199
- # aliased for backwards compatibility
200
- NoAlertOpenError = NoAlertPresentError
201
-
202
- # aliased for backwards compatibility
203
- ElementNotDisplayedError = ElementNotVisibleError
194
+ NoAlertOpenError = NoAlertPresentError
195
+ ElementNotDisplayedError = ElementNotVisibleError
204
196
 
205
197
  class << self
206
198
  def for_code(code)
@@ -161,13 +161,15 @@ module Selenium
161
161
  ensure
162
162
  Socket.do_not_reverse_lookup = orig
163
163
  end
164
+ rescue Errno::ENETUNREACH
165
+ # no external ip
164
166
  end
165
167
 
166
168
  def interfaces
167
169
  interfaces = Socket.getaddrinfo("localhost", 8080).map { |e| e[3] }
168
170
  interfaces += ["0.0.0.0", Platform.ip]
169
171
 
170
- interfaces.uniq
172
+ interfaces.compact.uniq
171
173
  end
172
174
 
173
175
  end # Platform
@@ -20,7 +20,15 @@ module Selenium
20
20
  end
21
21
 
22
22
  def self.free?(port)
23
- Platform.interfaces.each { |host| TCPServer.new(host, port).close }
23
+ Platform.interfaces.each do |host|
24
+ begin
25
+ TCPServer.new(host, port).close
26
+ rescue Errno::EADDRNOTAVAIL
27
+ $stderr.puts "port prober could not bind to #{host}:#{port}" if $DEBUG
28
+ # ignored - some machines appear unable to bind to some of their interfaces
29
+ end
30
+ end
31
+
24
32
  true
25
33
  rescue SocketError, Errno::EADDRINUSE
26
34
  false
@@ -12,11 +12,14 @@ module Selenium
12
12
  # @option opts [Numeric] :timeout (5) Seconds to wait before timing out.
13
13
  # @option opts [Numeric] :interval (0.2) Seconds to sleep between polls.
14
14
  # @option opts [String] :message Exception mesage if timed out.
15
+ # @option opts [Array, Exception] :ignore Exceptions to ignore while polling (default: Error::NoSuchElementError)
16
+ #
15
17
 
16
18
  def initialize(opts = {})
17
19
  @timeout = opts.fetch(:timeout, DEFAULT_TIMEOUT)
18
20
  @interval = opts.fetch(:interval, DEFAULT_INTERVAL)
19
21
  @message = opts[:message]
22
+ @ignored = Array(opts[:ignore] || Error::NoSuchElementError)
20
23
  end
21
24
 
22
25
 
@@ -35,7 +38,7 @@ module Selenium
35
38
  begin
36
39
  result = yield
37
40
  return result if result
38
- rescue Error::NoSuchElementError => last_error
41
+ rescue *@ignored => last_error
39
42
  # swallowed
40
43
  end
41
44
 
@@ -19,11 +19,19 @@ module Selenium
19
19
  ignore_mode = opts.delete(:introduce_flakiness_by_ignoring_security_domains)
20
20
  native_events = opts.delete(:native_events) != false
21
21
 
22
+ @server = Server.get
23
+
24
+ # get rid of this when the DLL server is gone
25
+ if @server.respond_to?(:log_level=)
26
+ # TODO: docs for these options
27
+ @server.log_level = opts.delete(:log_level)
28
+ @server.log_file = opts.delete(:log_file)
29
+ end
30
+
22
31
  unless opts.empty?
23
32
  raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
24
33
  end
25
34
 
26
- @server = Server.get
27
35
  @port = @server.start Integer(port), timeout
28
36
 
29
37
  caps = Remote::Capabilities.internet_explorer
@@ -15,11 +15,22 @@ module Selenium
15
15
  end
16
16
  end
17
17
 
18
- def initialize(binary_path)
18
+ attr_accessor :log_level, :log_file
19
+
20
+ def initialize(binary_path, opts = {})
19
21
  Platform.assert_executable binary_path
20
22
 
21
23
  @binary_path = binary_path
22
- @process = nil
24
+ @process = nil
25
+
26
+ opts = opts.dup
27
+ @log_level = opts.delete(:log_level)
28
+ @log_file = opts.delete(:log_file)
29
+
30
+ unless opts.empty?
31
+ raise ArgumentError, "invalid option#{'s' if opts.size != 1}: #{opts.inspect}"
32
+ end
33
+
23
34
  end
24
35
 
25
36
  def start(port, timeout)
@@ -27,7 +38,7 @@ module Selenium
27
38
 
28
39
  @port = port
29
40
 
30
- @process = ChildProcess.new(@binary_path, "--port=#{@port}")
41
+ @process = ChildProcess.new(@binary_path, *server_args)
31
42
  @process.io.inherit! if $DEBUG
32
43
  @process.start
33
44
 
@@ -58,6 +69,17 @@ module Selenium
58
69
  @process && @process.alive?
59
70
  end
60
71
 
72
+ private
73
+
74
+ def server_args
75
+ args = ["--port=#{@port}"]
76
+
77
+ args << "--log-level=#{@log_level.to_s.upcase}" if @log_level
78
+ args << "--log-file=#{@log_file}" if @log_file
79
+
80
+ args
81
+ end
82
+
61
83
  end
62
84
  end
63
85
  end
@@ -50,6 +50,12 @@ module Selenium
50
50
  retries += 1
51
51
 
52
52
  retry
53
+ rescue Errno::ECONNREFUSED => ex
54
+ if use_proxy?
55
+ raise ex.class, "using proxy: #{proxy.http}"
56
+ else
57
+ raise
58
+ end
53
59
  end
54
60
 
55
61
  if response.kind_of? Net::HTTPRedirection
@@ -77,7 +83,7 @@ module Selenium
77
83
  end
78
84
 
79
85
  def new_http_client
80
- if proxy
86
+ if use_proxy?
81
87
  unless proxy.respond_to?(:http) && url = @proxy.http
82
88
  raise Error::WebDriverError, "expected HTTP proxy, got #{@proxy.inspect}"
83
89
  end
@@ -94,13 +100,26 @@ module Selenium
94
100
  def proxy
95
101
  @proxy ||= (
96
102
  proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
103
+ no_proxy = ENV['no_proxy'] || ENV['NO_PROXY']
104
+
97
105
  if proxy
98
106
  proxy = "http://#{proxy}" unless proxy.start_with?("http://")
99
- Proxy.new(:http => proxy)
107
+ Proxy.new(:http => proxy, :no_proxy => no_proxy)
100
108
  end
101
109
  )
102
110
  end
103
111
 
112
+ def use_proxy?
113
+ return false if proxy.nil?
114
+
115
+ if proxy.no_proxy
116
+ hosts = proxy.no_proxy.split(",")
117
+ !(hosts.include?(server_url.host) || hosts.first == "*")
118
+ else
119
+ true
120
+ end
121
+ end
122
+
104
123
  end # Default
105
124
  end # Http
106
125
  end # Remote
@@ -1,4 +1,5 @@
1
1
  require 'selenium/webdriver/support/event_firing_bridge'
2
2
  require 'selenium/webdriver/support/abstract_event_listener'
3
3
  require 'selenium/webdriver/support/block_event_listener'
4
- require 'selenium/webdriver/support/select'
4
+ require 'selenium/webdriver/support/select'
5
+ require 'selenium/webdriver/support/color'
@@ -0,0 +1,98 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module Support
4
+ class Color
5
+ RGB_PATTERN = /^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/
6
+ RGB_PCT_PATTERN = /^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/
7
+ RGBA_PATTERN = /^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/
8
+ RGBA_PCT_PATTERN = /^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/
9
+ HEX_PATTERN = /#([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})/ # \p{XDigit} or \h only works on Ruby 1.9
10
+ HEX3_PATTERN = /#([A-Fa-f0-9])([A-Fa-f0-9])([A-Fa-f0-9])/ # \p{XDigit} or \h only works on Ruby 1.9
11
+ HSL_PATTERN = /^\s*hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)\s*$/
12
+ HSLA_PATTERN = /^\s*hsla\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/
13
+
14
+ attr_reader :red, :green, :blue, :alpha
15
+
16
+ def self.from_string(str)
17
+ case str
18
+ when RGB_PATTERN
19
+ new $1, $2, $3
20
+ when RGB_PCT_PATTERN
21
+ new(*[$1, $2, $3].map { |e| Float(e) / 100 * 255 })
22
+ when RGBA_PATTERN
23
+ new $1, $2, $3, $4
24
+ when RGBA_PCT_PATTERN
25
+ new(*[$1, $2, $3].map { |e| Float(e) / 100 * 255 } << $4)
26
+ when HEX_PATTERN
27
+ new(*[$1, $2, $3].map { |e| e.to_i(16) })
28
+ when HEX3_PATTERN
29
+ new(*[$1, $2, $3].map { |e| (e * 2).to_i(16) })
30
+ when HSL_PATTERN, HSLA_PATTERN
31
+ from_hsl($1, $2, $3, $4)
32
+ else
33
+ raise ArgumentError, "could not convert #{str.inspect} into color"
34
+ end
35
+ end
36
+
37
+ def self.from_hsl(h, s, l, a)
38
+ h = Float(h) / 360
39
+ s = Float(s) / 100
40
+ l = Float(l) / 100
41
+ a = Float(a || 1)
42
+
43
+ if s == 0
44
+ r = l
45
+ g = r
46
+ b = r
47
+ else
48
+ luminocity2 = (l < 0.5) ? l * (1 + s) : l + s - l * s
49
+ luminocity1 = 2 * l - luminocity2
50
+
51
+ hue_to_rgb = lambda do |lum1, lum2, hue|
52
+ hue += 1 if hue < 0.0
53
+ hue -= 1 if hue > 1.0
54
+
55
+ if hue < 1.0 / 6.0
56
+ (lum1 + (lum2 - lum1) * 6.0 * hue)
57
+ elsif hue < 1.0 / 2.0
58
+ lum2
59
+ elsif hue < 2.0 / 3.0
60
+ lum1 + (lum2 - lum1) * ((2.0 / 3.0) - hue) * 6.0
61
+ else
62
+ lum1
63
+ end
64
+ end
65
+
66
+ r = hue_to_rgb.call(luminocity1, luminocity2, h + 1.0 / 3.0)
67
+ g = hue_to_rgb.call(luminocity1, luminocity2, h)
68
+ b = hue_to_rgb.call(luminocity1, luminocity2, h - 1.0 / 3.0)
69
+ end
70
+
71
+ new r * 256, g * 256, b * 256, a
72
+ end
73
+
74
+
75
+ def initialize(red, green, blue, alpha = 1)
76
+ @red = Integer(red)
77
+ @green = Integer(green)
78
+ @blue = Integer(blue)
79
+ @alpha = Float(alpha)
80
+ end
81
+
82
+ def rgb
83
+ "rgb(#{red}, #{green}, #{blue})"
84
+ end
85
+
86
+ def rgba
87
+ a = alpha == 1 ? '1' : alpha
88
+ "rgba(#{red}, #{green}, #{blue}, #{a})"
89
+ end
90
+
91
+ def hex
92
+ "#%02x%02x%02x" % [red, green, blue]
93
+ end
94
+
95
+ end
96
+ end
97
+ end
98
+ end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 2.24.0
4
+ prerelease: 7
5
+ version: 2.25.0.rc1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jari Bakken
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-06-20 00:00:00 +02:00
13
+ date: 2012-07-19 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -213,6 +213,7 @@ files:
213
213
  - lib/selenium/webdriver/safari/server.rb
214
214
  - lib/selenium/webdriver/support/abstract_event_listener.rb
215
215
  - lib/selenium/webdriver/support/block_event_listener.rb
216
+ - lib/selenium/webdriver/support/color.rb
216
217
  - lib/selenium/webdriver/support/event_firing_bridge.rb
217
218
  - lib/selenium/webdriver/support/select.rb
218
219
  - CHANGES
@@ -236,9 +237,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
236
237
  required_rubygems_version: !ruby/object:Gem::Requirement
237
238
  none: false
238
239
  requirements:
239
- - - ">="
240
+ - - ">"
240
241
  - !ruby/object:Gem::Version
241
- version: "0"
242
+ version: 1.3.1
242
243
  requirements: []
243
244
 
244
245
  rubyforge_project: