selenium-webdriver 2.22.0.rc1 → 2.22.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,7 +1,23 @@
1
- 2.22.0 (???)
1
+ 2.22.0
2
2
  ============
3
3
 
4
4
  * Fix conflict with ActiveSupport's Object#load (#3819)
5
+ * IE:
6
+ * standalone server executable, falls back to bundled DLLs.
7
+ * Firefox:
8
+ * Native events for Firefox 12.
9
+ * Native events retained for Firefox 3.x, 10 and 11.
10
+ * Fix for typing in Firefox 12
11
+ * Fix for typing on XHTML pages (#3647)
12
+ * Fix for maximizing windows when switched to a frame (#3758)
13
+ * Handle alerts from nested iframes (#3825)
14
+ * Element#attribute returns nil if a boolean attribute is not present.
15
+ * NoSuchWindowError will be thrown if the currently selected
16
+ window is closed and another command is sent
17
+ * Safari:
18
+ * support for frame switching, snapshot taking, execute script
19
+ * message protocol changed, not backwards compatible with 2.21.
20
+ * Style attributes are no longer lower-cased by default (#1089).
5
21
 
6
22
  2.21.2 (2012-04-18)
7
23
  ===================
@@ -184,9 +184,10 @@ module Selenium
184
184
  private
185
185
 
186
186
  def self.net_http
187
- if ENV['http_proxy']
188
- http_proxy = ENV['http_proxy']
189
- http_proxy = "http://#{http_proxy}" unless http_proxy =~ /^http:\/\//i
187
+ http_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
188
+
189
+ if http_proxy
190
+ http_proxy = "http://#{http_proxy}" unless http_proxy.start_with?("http://")
190
191
  uri = URI.parse(http_proxy)
191
192
 
192
193
  Net::HTTP::Proxy(uri.host, uri.port)
@@ -9,6 +9,7 @@ module Selenium
9
9
  class Service
10
10
  START_TIMEOUT = 20
11
11
  STOP_TIMEOUT = 5
12
+ DEFAULT_PORT = 9515
12
13
  MISSING_TEXT = "Unable to find the chromedriver executable. Please download the server from http://code.google.com/p/chromedriver/downloads/list and place it somewhere on your PATH. More info at http://code.google.com/p/selenium/wiki/ChromeDriver."
13
14
 
14
15
  attr_reader :uri
@@ -29,7 +30,7 @@ module Selenium
29
30
  end
30
31
 
31
32
  def self.default_service
32
- new executable_path, PortProber.random
33
+ new executable_path, PortProber.above(DEFAULT_PORT)
33
34
  end
34
35
 
35
36
  def initialize(executable_path, port)
@@ -5,21 +5,30 @@ module Selenium
5
5
  port += 1 until free? port
6
6
  port
7
7
  end
8
-
8
+
9
9
  def self.random
10
+ # TODO: Avoid this
11
+ #
12
+ # (a) should pick a port that's guaranteed to be free on all interfaces
13
+ # (b) should pick a random port outside the ephemeral port range
14
+ #
10
15
  server = TCPServer.new(Platform.localhost, 0)
11
16
  port = server.addr[1]
12
17
  server.close
13
-
18
+
14
19
  port
15
20
  end
16
-
21
+
17
22
  def self.free?(port)
18
- TCPServer.new(Platform.localhost, port).close
23
+ interfaces = Socket.getaddrinfo("localhost", port).map { |e| e[2] }
24
+ interfaces += ["0.0.0.0", Platform.ip]
25
+ interfaces.each { |address| TCPServer.new(address, port).close }
26
+
19
27
  true
20
28
  rescue SocketError, Errno::EADDRINUSE
21
29
  false
22
30
  end
31
+
23
32
  end # PortProber
24
33
  end # WebDriver
25
34
  end # Selenium
@@ -81,12 +81,12 @@ module Selenium
81
81
  end
82
82
 
83
83
  def with_timeout(&blk)
84
- max_time = Time.now + @timeout
84
+ max_time = time_now + @timeout
85
85
 
86
86
  (
87
87
  return true if yield
88
88
  wait
89
- ) until Time.now > max_time
89
+ ) until time_now > max_time
90
90
 
91
91
  false
92
92
  end
@@ -95,6 +95,11 @@ module Selenium
95
95
  sleep @interval
96
96
  end
97
97
 
98
+ # for testability
99
+ def time_now
100
+ Time.now
101
+ end
102
+
98
103
  end # SocketPoller
99
104
  end # WebDriver
100
105
  end # Selenium
@@ -15,7 +15,7 @@ module Selenium
15
15
  class << self
16
16
 
17
17
  def unzip(path)
18
- destination = Dir.mktmpdir("unzip")
18
+ destination = Dir.mktmpdir("webdriver-unzip")
19
19
  FileReaper << destination
20
20
 
21
21
  Zip::ZipFile.open(path) do |zip|
@@ -13,16 +13,17 @@ module Selenium
13
13
  DEFAULT_TIMEOUT = 30
14
14
 
15
15
  def initialize(opts = {})
16
- timeout = opts.delete(:timeout) { DEFAULT_TIMEOUT }
17
- port = opts.delete(:port) { DEFAULT_PORT }
18
- http_client = opts.delete(:http_client)
19
- ignore_mode = opts.delete(:introduce_flakiness_by_ignoring_security_domains)
16
+ timeout = opts.delete(:timeout) { DEFAULT_TIMEOUT }
17
+ port = opts.delete(:port) { PortProber.above(DEFAULT_PORT) }
18
+ http_client = opts.delete(:http_client)
19
+ ignore_mode = opts.delete(:introduce_flakiness_by_ignoring_security_domains)
20
+ native_events = opts.delete(:native_events) != false
20
21
 
21
22
  unless opts.empty?
22
23
  raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
23
24
  end
24
25
 
25
- @server = Server.new
26
+ @server = Server.get
26
27
  @port = @server.start Integer(port), timeout
27
28
 
28
29
  caps = Remote::Capabilities.internet_explorer
@@ -30,6 +31,8 @@ module Selenium
30
31
  caps['ignoreProtectedModeSettings'] = true
31
32
  end
32
33
 
34
+ caps['nativeEvents'] = native_events
35
+
33
36
  remote_opts = {
34
37
  :url => @server.uri,
35
38
  :desired_capabilities => caps
@@ -50,9 +53,9 @@ module Selenium
50
53
 
51
54
  def quit
52
55
  super
53
- @server.stop
54
-
55
56
  nil
57
+ ensure
58
+ @server.stop
56
59
  end
57
60
 
58
61
  end # Bridge
@@ -0,0 +1,72 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module IE
4
+
5
+ #
6
+ # @api private
7
+ #
8
+
9
+ class InProcessServer
10
+ extend FFI::Library
11
+
12
+ if Platform.bitsize == 64
13
+ ffi_lib WebDriver::IE::DLLS[:x64]
14
+ else
15
+ ffi_lib WebDriver::IE::DLLS[:win32]
16
+ end
17
+
18
+ ffi_convention :stdcall
19
+
20
+ attach_function :start_server, :StartServer, [:int], :pointer
21
+ attach_function :stop_server, :StopServer, [:pointer], :void
22
+ attach_function :session_count, :GetServerSessionCount, [], :int
23
+ attach_function :current_port, :GetServerPort, [], :int
24
+ attach_function :is_running, :ServerIsRunning, [], :bool
25
+
26
+ def initialize
27
+ @handle = nil
28
+ end
29
+
30
+ #
31
+ # Starts the server, communicating on the specified port, if it is not already running
32
+ #
33
+
34
+ def start(start_port, timeout)
35
+ return port if running?
36
+ @handle = self.class.start_server(start_port)
37
+
38
+ unless SocketPoller.new(Platform.localhost, start_port, timeout).connected?
39
+ raise Error::WebDriverError, "unable to connect to IE server within #{timeout} seconds"
40
+ end
41
+
42
+ start_port
43
+ end
44
+
45
+ def stop
46
+ return if session_count != 0 || @handle.nil?
47
+ self.class.stop_server @handle
48
+ @handle = nil
49
+ end
50
+
51
+ def running?
52
+ self.class.is_running
53
+ end
54
+
55
+ def port
56
+ self.class.current_port
57
+ end
58
+
59
+ def uri
60
+ "http://#{Platform.localhost}:#{port}"
61
+ end
62
+
63
+ private
64
+
65
+ def session_count
66
+ self.class.session_count
67
+ end
68
+
69
+ end # Server
70
+ end # IE
71
+ end # WebDriver
72
+ end # Selenium
@@ -1,72 +1,65 @@
1
1
  module Selenium
2
2
  module WebDriver
3
3
  module IE
4
-
5
- #
6
- # @api private
7
- #
8
-
9
4
  class Server
10
- extend FFI::Library
11
5
 
12
- if Platform.bitsize == 64
13
- ffi_lib WebDriver::IE::DLLS[:x64]
14
- else
15
- ffi_lib WebDriver::IE::DLLS[:win32]
16
- end
6
+ STOP_TIMEOUT = 5
17
7
 
18
- ffi_convention :stdcall
8
+ def self.get
9
+ binary = Platform.find_binary("IEDriverServer")
10
+ if binary
11
+ new(binary)
12
+ else
13
+ # TODO: deprecation warning
14
+ require 'selenium/webdrier/ie/in_process_server'
15
+ InProcessServer.new
16
+ end
17
+ end
19
18
 
20
- attach_function :start_server, :StartServer, [:int], :pointer
21
- attach_function :stop_server, :StopServer, [:pointer], :void
22
- attach_function :session_count, :GetServerSessionCount, [], :int
23
- attach_function :current_port, :GetServerPort, [], :int
24
- attach_function :is_running, :ServerIsRunning, [], :bool
19
+ def initialize(binary_path)
20
+ Platform.assert_executable binary_path
25
21
 
26
- def initialize
27
- @handle = nil
22
+ @binary_path = binary_path
23
+ @process = nil
28
24
  end
29
25
 
30
- #
31
- # Starts the server, communicating on the specified port, if it is not already running
32
- #
26
+ def start(port, timeout)
27
+ return @port if running?
28
+
29
+ @port = port
33
30
 
34
- def start(start_port, timeout)
35
- return port if running?
36
- @handle = self.class.start_server(start_port)
31
+ @process = ChildProcess.new(@binary_path, "--port=#{@port}")
32
+ @process.io.inherit! if $DEBUG
33
+ @process.start
37
34
 
38
- unless SocketPoller.new(Platform.localhost, start_port, timeout).connected?
35
+ unless SocketPoller.new(Platform.localhost, @port, timeout).connected?
39
36
  raise Error::WebDriverError, "unable to connect to IE server within #{timeout} seconds"
40
37
  end
41
38
 
42
- start_port
43
- end
39
+ Platform.exit_hook { stop }
44
40
 
45
- def stop
46
- return if session_count != 0 || @handle.nil?
47
- self.class.stop_server @handle
48
- @handle = nil
41
+ @port
49
42
  end
50
43
 
51
- def running?
52
- self.class.is_running
44
+ def stop
45
+ if running?
46
+ @process.stop STOP_TIMEOUT
47
+ end
53
48
  end
54
49
 
55
50
  def port
56
- self.class.current_port
51
+ @port
57
52
  end
58
53
 
59
54
  def uri
60
55
  "http://#{Platform.localhost}:#{port}"
61
56
  end
62
57
 
63
- private
64
-
65
- def session_count
66
- self.class.session_count
58
+ def running?
59
+ @process && @process.alive?
67
60
  end
68
61
 
69
- end # Server
70
- end # IE
71
- end # WebDriver
72
- end # Selenium
62
+ end
63
+ end
64
+ end
65
+ end
@@ -25,7 +25,7 @@ module Selenium
25
25
  end
26
26
 
27
27
  def initialize(jar, opts = {})
28
- opts.merge! :background => true, :port => PortProber.random
28
+ opts.merge! :background => true, :port => PortProber.above(4444)
29
29
  opts.merge! :log => !!$DEBUG if $DEBUG
30
30
  @server = Selenium::Server.new File.expand_path(jar), opts
31
31
  end
@@ -13,7 +13,6 @@ module Selenium
13
13
 
14
14
  def initialize
15
15
  super
16
- @proxy = nil
17
16
  end
18
17
 
19
18
  def http
@@ -82,10 +81,11 @@ module Selenium
82
81
  end
83
82
 
84
83
  def new_http_client
85
- if @proxy
86
- unless @proxy.respond_to?(:http) && url = @proxy.http
84
+ if proxy
85
+ unless proxy.respond_to?(:http) && url = @proxy.http
87
86
  raise Error::WebDriverError, "expected HTTP proxy, got #{@proxy.inspect}"
88
87
  end
88
+
89
89
  proxy = URI.parse(url)
90
90
 
91
91
  clazz = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password)
@@ -95,6 +95,16 @@ module Selenium
95
95
  end
96
96
  end
97
97
 
98
+ def proxy
99
+ @proxy ||= (
100
+ proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
101
+ if proxy
102
+ proxy = "http://#{proxy}" unless proxy.start_with?("http://")
103
+ Proxy.new(:http => proxy)
104
+ end
105
+ )
106
+ end
107
+
98
108
  end # Default
99
109
  end # Http
100
110
  end # Remote
@@ -5,6 +5,7 @@ module Selenium
5
5
  class Bridge < Remote::Bridge
6
6
  COMMAND_TIMEOUT = 60
7
7
 
8
+
8
9
  def initialize(opts = {})
9
10
  port = Integer(opts[:port] || PortProber.random)
10
11
  timeout = Integer(opts[:timeout] || COMMAND_TIMEOUT)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 7
5
- version: 2.22.0.rc1
5
+ version: 2.22.0.rc2
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-05-01 00:00:00 +02:00
13
+ date: 2012-05-29 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -206,6 +206,7 @@ files:
206
206
  - lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so
207
207
  - lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so
208
208
  - lib/selenium/webdriver/ie/bridge.rb
209
+ - lib/selenium/webdriver/ie/in_process_server.rb
209
210
  - lib/selenium/webdriver/ie/server.rb
210
211
  - lib/selenium/webdriver/ie/native/win32/IEDriver.dll
211
212
  - lib/selenium/webdriver/ie/native/x64/IEDriver.dll