selenium-webdriver 0.2.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,4 +1,14 @@
1
- 0.2.2 (???)
1
+ 2.0.0 (2011-07-08)
2
+ ==================
3
+
4
+ * Remove deprecated methods Element#{toggle,select,drag_and_drop_*,value}.
5
+ * Add ability to pass :verbose, :native_events to the Chrome driver.
6
+ * Synthetic mouse implementation for Firefox - improves drag and drop support platforms without native events.
7
+ * Added Selenium::WebDriver::Opera (requires the remote server).
8
+ * Fix for locating Firefox on 64-bit Windows when missing from the registry.
9
+ * Fix native events on Firefox 4, 5.
10
+
11
+ 0.2.2 (2011-06-22)
2
12
  ==================
3
13
 
4
14
  * Deprecate Element#{toggle,select,drag_and_drop_*}
@@ -39,6 +39,7 @@ module Selenium
39
39
  autoload :IPhone, 'selenium/webdriver/iphone'
40
40
  autoload :Remote, 'selenium/webdriver/remote'
41
41
  autoload :Firefox, 'selenium/webdriver/firefox'
42
+ autoload :Opera, 'selenium/webdriver/opera'
42
43
 
43
44
  # @api private
44
45
 
@@ -49,7 +50,7 @@ module Selenium
49
50
  #
50
51
  # Create a new Driver instance with the correct bridge for the given browser
51
52
  #
52
- # @param browser [:ie, :internet_explorer, :remote, :chrome, :firefox, :ff, :android, :iphone]
53
+ # @param browser [:ie, :internet_explorer, :remote, :chrome, :firefox, :ff, :android, :iphone, :opera]
53
54
  # the driver type to use
54
55
  # @param *rest
55
56
  # arguments passed to Bridge.new
@@ -62,6 +63,7 @@ module Selenium
62
63
  # @see Selenium::WebDriver::Chrome::Bridge
63
64
  # @see Selenium::WebDriver::Android::Bridge
64
65
  # @see Selenium::WebDriver::IPhone::Bridge
66
+ # @see Selenium::WebDriver::Opera::Bridge
65
67
  #
66
68
  # @example
67
69
  #
@@ -6,8 +6,10 @@ module Selenium
6
6
  class Bridge < Remote::Bridge
7
7
 
8
8
  def initialize(opts = {})
9
- http_client = opts.delete(:http_client)
10
- switches = opts.delete(:switches)
9
+ http_client = opts.delete(:http_client)
10
+ switches = opts.delete(:switches)
11
+ native_events = opts.delete(:native_events)
12
+ verbose = opts.delete(:verbose)
11
13
 
12
14
  unless opts.empty?
13
15
  raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
@@ -23,9 +25,9 @@ module Selenium
23
25
  caps.merge! 'chrome.switches' => switches.map { |e| e.to_s }
24
26
  end
25
27
 
26
- if Chrome.path
27
- caps.merge! 'chrome.binary' => Chrome.path
28
- end
28
+ caps.merge! 'chrome.binary' => Chrome.path if Chrome.path
29
+ caps.merge! 'chrome.nativeEvents' => true if native_events
30
+ caps.merge! 'chrome.verbose' => true if verbose
29
31
 
30
32
  @service = Service.default_service
31
33
  @service.start
@@ -9,7 +9,7 @@ module Selenium
9
9
  class Service
10
10
  START_TIMEOUT = 20
11
11
  STOP_TIMEOUT = 5
12
- MISSING_TEXT = "Unable to find the chromedriver executable. Please download the server from http://code.google.com/p/selenium/downloads/list and place it somewhere on your PATH. More info at http://code.google.com/p/selenium/wiki/ChromeDriver."
12
+ MISSING_TEXT = "Unable to find the chromedriver executable. Please download the server from http://code.google.com/p/chromium/downloads/list and place it somewhere on your PATH. More info at http://code.google.com/p/selenium/wiki/ChromeDriver."
13
13
 
14
14
  attr_reader :uri
15
15
 
@@ -35,6 +35,8 @@ module Selenium
35
35
  Android::Bridge.new(*args)
36
36
  when :iphone
37
37
  IPhone::Bridge.new(*args)
38
+ when :opera
39
+ Opera::Bridge.new(*args)
38
40
  else
39
41
  raise ArgumentError, "unknown driver: #{browser.inspect}"
40
42
  end
@@ -46,17 +46,6 @@ module Selenium
46
46
  bridge.getElementTagName @id
47
47
  end
48
48
 
49
- #
50
- # Get the value of this element
51
- #
52
- # @return [String]
53
- #
54
-
55
- def value
56
- warn "#{self.class}#value is deprecated, please use #{self.class}#attribute('value')"
57
- bridge.getElementValue @id
58
- end
59
-
60
49
  #
61
50
  # Get the value of a the given attribute of the element. Will return the current value, even if
62
51
  # this has been modified after the page has been loaded. More exactly, this method will return
@@ -168,28 +157,6 @@ module Selenium
168
157
  bridge.isElementDisplayed @id
169
158
  end
170
159
 
171
- #
172
- # Select this element
173
- #
174
-
175
- def select
176
- warn "#{self.class}#select is deprecated. Please use #{self.class}#click and determine the current state with #{self.class}#selected?"
177
-
178
- unless displayed?
179
- raise Error::ElementNotDisplayedError, "you may not select an element that is not displayed"
180
- end
181
-
182
- unless enabled?
183
- raise Error::InvalidElementStateError, "cannot select a disabled element"
184
- end
185
-
186
- unless selectable?
187
- raise Error::InvalidElementStateError, "you may only select options, radios or checkboxes"
188
- end
189
-
190
- click unless selected?
191
- end
192
-
193
160
  #
194
161
  # Submit this element
195
162
  #
@@ -198,15 +165,6 @@ module Selenium
198
165
  bridge.submitElement @id
199
166
  end
200
167
 
201
- #
202
- # Toggle this element
203
- #
204
-
205
- def toggle
206
- warn "#{self.class}#toggle is deprecated. Please use #{self.class}#click and determine the current state with #{self.class}#selected?"
207
- bridge.toggleElement @id
208
- end
209
-
210
168
  #
211
169
  # Get the value of the given CSS property
212
170
  #
@@ -245,36 +203,6 @@ module Selenium
245
203
  bridge.getElementSize @id
246
204
  end
247
205
 
248
- #
249
- # Drag and drop this element
250
- #
251
- # @param [Integer] right_by
252
- # number of pixels to drag right
253
- # @param [Integer] down_by
254
- # number of pixels to drag down
255
- #
256
-
257
- def drag_and_drop_by(right_by, down_by)
258
- warn "#{self.class}#drag_and_drop_{by,on} is deprecated. Please use Selenium::WebDriver::Driver#action (and Selenium::WebDriver::ActionBuilder) instead."
259
- bridge.dragElement @id, right_by, down_by
260
- end
261
-
262
- #
263
- # Drag and drop this element on the given element
264
- #
265
- # @param [WebDriver::Element] other
266
- #
267
-
268
- def drag_and_drop_on(other)
269
- current_location = location()
270
- destination = other.location
271
-
272
- right = destination.x - current_location.x
273
- down = destination.y - current_location.y
274
-
275
- drag_and_drop_by right, down
276
- end
277
-
278
206
  #-------------------------------- sugar --------------------------------
279
207
 
280
208
  #
@@ -103,10 +103,14 @@ module Selenium
103
103
  File.chmod 0766, file
104
104
  end
105
105
 
106
- def assert_executable(path)
106
+ def assert_file(path)
107
107
  unless File.file? path
108
108
  raise Error::WebDriverError, "not a file: #{path.inspect}"
109
109
  end
110
+ end
111
+
112
+ def assert_executable(path)
113
+ assert_file(path)
110
114
 
111
115
  unless File.executable? path
112
116
  raise Error::WebDriverError, "not executable: #{path.inspect}"
@@ -131,7 +135,7 @@ module Selenium
131
135
  info = Socket.getaddrinfo "localhost", 80, Socket::AF_INET, Socket::SOCK_STREAM
132
136
 
133
137
  if info.empty?
134
- raise Error::WebDriverError, "unable to translate 'localhost' for TCP+IPv6"
138
+ raise Error::WebDriverError, "unable to translate 'localhost' for TCP + IPv4"
135
139
  end
136
140
 
137
141
  info[0][3]
@@ -148,8 +148,10 @@ module Selenium
148
148
  end
149
149
 
150
150
  def likely_windows_path
151
- path = "#{ ENV['PROGRAMFILES'] || "\\Program Files" }\\Mozilla Firefox\\firefox.exe"
152
- path if File.executable?(path)
151
+ [
152
+ "#{ ENV['PROGRAMFILES'] || "\\Program Files" }\\Mozilla Firefox\\firefox.exe",
153
+ "#{ ENV['ProgramFiles(x86)'] || "\\Program Files (x86)" }\\Mozilla Firefox\\firefox.exe"
154
+ ].find { |path| File.executable?(path) }
153
155
  end
154
156
  end # class << self
155
157
 
@@ -0,0 +1,12 @@
1
+ require 'selenium/server'
2
+ require 'selenium/webdriver/opera/service'
3
+ require 'selenium/webdriver/opera/bridge'
4
+
5
+ module Selenium
6
+ module WebDriver
7
+
8
+ module Opera
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,54 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module Opera
4
+
5
+ #
6
+ # @api private
7
+ #
8
+
9
+ class Bridge < Remote::Bridge
10
+
11
+ def initialize(opts = {})
12
+ http_client = opts.delete(:http_client)
13
+
14
+ unless opts.empty?
15
+ raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
16
+ end
17
+
18
+ caps = Remote::Capabilities.opera
19
+
20
+ @service = Service.default_service
21
+ @service.start
22
+
23
+ remote_opts = {
24
+ :url => @service.uri,
25
+ :desired_capabilities => caps
26
+ }
27
+
28
+ remote_opts.merge!(:http_client => http_client) if http_client
29
+
30
+ super(remote_opts)
31
+ end
32
+
33
+ def browser
34
+ :opera
35
+ end
36
+
37
+ def driver_extensions
38
+ [DriverExtensions::TakesScreenshot]
39
+ end
40
+
41
+ def capabilities
42
+ @capabilities ||= Remote::Capabilities.opera
43
+ end
44
+
45
+ def quit
46
+ super
47
+ ensure
48
+ @service.stop
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,48 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module Opera
4
+
5
+ #
6
+ # @api private
7
+ #
8
+
9
+ class Service
10
+ MISSING_TEXT = 'Unable to find the Selenium server jar. Please download the standalone server from http://code.google.com/p/selenium/downloads/list and set the SELENIUM_SERVER_JAR environmental variable to its location. More info at http://code.google.com/p/selenium/wiki/OperaDriver.'
11
+
12
+ def self.selenium_server_jar
13
+ @selenium_server_jar ||= (
14
+ ENV['SELENIUM_SERVER_JAR'] or raise Error::WebDriverError, MISSING_TEXT
15
+ )
16
+ end
17
+
18
+ def self.selenium_server_jar=(path)
19
+ Platform.assert_file path
20
+ @selenium_server_jar = path
21
+ end
22
+
23
+ def self.default_service
24
+ new selenium_server_jar
25
+ end
26
+
27
+ def initialize(jar, opts = {})
28
+ opts.merge! :background => true, :port => PortProber.random, :log => !!$DEBUG
29
+ @server = Selenium::Server.new File.expand_path(jar), opts
30
+ end
31
+
32
+ def uri
33
+ @server.webdriver_url
34
+ end
35
+
36
+ def start
37
+ @server.start
38
+ at_exit { stop } # make sure we don't leave the server running
39
+ end
40
+
41
+ def stop
42
+ @server.stop
43
+ end
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -390,10 +390,6 @@ module Selenium
390
390
  execute :submitElement, :id => element
391
391
  end
392
392
 
393
- def toggleElement(element)
394
- execute :toggleElement, :id => element
395
- end
396
-
397
393
  def setElementSelected(element)
398
394
  execute :setElementSelected, :id => element
399
395
  end
@@ -93,8 +93,10 @@ module Selenium
93
93
 
94
94
  def opera(opts = {})
95
95
  new({
96
- :browser_name => "opera",
97
- :javascript_enabled => true
96
+ :browser_name => "opera",
97
+ :javascript_enabled => true,
98
+ :takes_screenshot => true,
99
+ :css_selectors_enabled => true,
98
100
  }.merge(opts))
99
101
  end
100
102
 
@@ -228,4 +230,4 @@ module Selenium
228
230
  end # Capabilities
229
231
  end # Remote
230
232
  end # WebDriver
231
- end # Selenium
233
+ end # Selenium
@@ -46,7 +46,6 @@ class Selenium::WebDriver::Remote::Bridge
46
46
  command :clearElement, :post, "session/:session_id/element/:id/clear"
47
47
  command :isElementSelected, :get, "session/:session_id/element/:id/selected"
48
48
  command :setElementSelected, :post, "session/:session_id/element/:id/selected"
49
- command :toggleElement, :post, "session/:session_id/element/:id/toggle"
50
49
  command :isElementEnabled, :get, "session/:session_id/element/:id/enabled"
51
50
  command :getElementAttribute, :get, "session/:session_id/element/:id/attribute/:name"
52
51
  command :elementEquals, :get, "session/:session_id/element/:id/equals/:other"
@@ -7,12 +7,6 @@ module Selenium
7
7
  CONTENT_TYPE = "application/json"
8
8
  DEFAULT_HEADERS = { "Accept" => CONTENT_TYPE }
9
9
 
10
- # deprecated.
11
- def self.timeout=(timeout)
12
- raise Error::WebDriverError,
13
- "Configuration of HTTP timeouts has changed. See http://code.google.com/p/selenium/wiki/RubyBindings for updated intructions."
14
- end
15
-
16
10
  attr_accessor :timeout
17
11
  attr_writer :server_url
18
12
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.2
5
+ version: 2.0.0
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: 2011-06-22 00:00:00 +02:00
13
+ date: 2011-07-08 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -122,6 +122,7 @@ files:
122
122
  - lib/selenium/webdriver/firefox.rb
123
123
  - lib/selenium/webdriver/ie.rb
124
124
  - lib/selenium/webdriver/iphone.rb
125
+ - lib/selenium/webdriver/opera.rb
125
126
  - lib/selenium/webdriver/remote.rb
126
127
  - lib/selenium/webdriver/android/bridge.rb
127
128
  - lib/selenium/webdriver/chrome/bridge.rb
@@ -168,6 +169,8 @@ files:
168
169
  - lib/selenium/webdriver/ie/native/win32/IEDriver.dll
169
170
  - lib/selenium/webdriver/ie/native/x64/IEDriver.dll
170
171
  - lib/selenium/webdriver/iphone/bridge.rb
172
+ - lib/selenium/webdriver/opera/bridge.rb
173
+ - lib/selenium/webdriver/opera/service.rb
171
174
  - lib/selenium/webdriver/remote/bridge.rb
172
175
  - lib/selenium/webdriver/remote/capabilities.rb
173
176
  - lib/selenium/webdriver/remote/commands.rb