selenium-webdriver 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ gem install selenium-webdriver
9
9
  = LINKS
10
10
 
11
11
  * http://gemcutter.org/gems/selenium-webdriver
12
+ * http://selenium.googlecode.com/svn/trunk/docs/api/rb/index.html
12
13
  * http://code.google.com/p/selenium/wiki/RubyBindings
13
14
  * http://code.google.com/p/selenium/issues/list
14
15
 
@@ -44,6 +44,8 @@ module Selenium
44
44
  def wait
45
45
  raise "called wait with no pid" unless @pid
46
46
  Process.waitpid2 @pid
47
+ rescue Errno::ECHILD
48
+ nil
47
49
  end
48
50
 
49
51
  def kill
@@ -8,10 +8,14 @@ module Selenium
8
8
  @binary = Binary.new
9
9
  @launcher = Launcher.new(
10
10
  @binary,
11
- opts[:port] || DEFAULT_PORT,
12
- opts[:profile] || DEFAULT_PROFILE_NAME
11
+ opts.delete(:port) || DEFAULT_PORT,
12
+ opts.delete(:profile) || DEFAULT_PROFILE_NAME
13
13
  )
14
14
 
15
+ unless opts.empty?
16
+ raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
17
+ end
18
+
15
19
  @launcher.launch
16
20
  @connection = @launcher.connection
17
21
  @context = newSession
@@ -28,7 +32,7 @@ module Selenium
28
32
  def quit
29
33
  @connection.quit
30
34
  @binary.wait rescue nil # might raise on windows
31
-
35
+
32
36
  nil
33
37
  end
34
38
 
@@ -1,7 +1,6 @@
1
1
  module Selenium
2
2
  module WebDriver
3
3
  module Remote
4
- DEBUG = $VERBOSE == true
5
4
 
6
5
  COMMANDS = {}
7
6
 
@@ -16,7 +15,7 @@ module Selenium
16
15
  include BridgeHelper
17
16
 
18
17
  DEFAULT_OPTIONS = {
19
- :server_url => "http://localhost:7055/",
18
+ :url => "http://localhost:7055/",
20
19
  :http_client => DefaultHttpClient,
21
20
  :desired_capabilities => Capabilities.firefox
22
21
  }
@@ -46,14 +45,27 @@ module Selenium
46
45
  #
47
46
  # Initializes the bridge with the given server URL.
48
47
  #
49
- # @param server_url [String] base URL for all commands. FIXME: Note that a trailing '/' is very important!
48
+ # @param url [String] url for the remote server
49
+ # @param http_client [Class] an HTTP client class that implements the same interface as DefaultHttpClient
50
+ # @param desired_capabilities [Capabilities] an instance of Remote::Capabilities describing the capabilities you want
50
51
  #
51
52
 
52
53
  def initialize(opts = {})
53
- opts = DEFAULT_OPTIONS.merge(opts)
54
+ opts = DEFAULT_OPTIONS.merge(opts)
55
+ http_client_class = opts.delete(:http_client)
56
+ desired_capabilities = opts.delete(:desired_capabilities)
57
+ url = opts.delete(:url)
58
+
59
+ unless opts.empty?
60
+ raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
61
+ end
62
+
63
+ uri = URI.parse(url)
64
+ uri.path += "/" unless uri.path =~ /\/$/
65
+
54
66
  @context = "context"
55
- @http = opts[:http_client].new URI.parse(opts[:server_url])
56
- @capabilities = create_session opts[:desired_capabilities]
67
+ @http = http_client_class.new uri
68
+ @capabilities = create_session(desired_capabilities)
57
69
  end
58
70
 
59
71
  def browser
@@ -370,7 +382,7 @@ module Selenium
370
382
  raise ArgumentError, "#{opts.inspect} invalid for #{command.inspect}"
371
383
  end
372
384
 
373
- puts "-> #{verb.to_s.upcase} #{path}" if DEBUG
385
+ puts "-> #{verb.to_s.upcase} #{path}" if $DEBUG
374
386
  http.call verb, path, *args
375
387
  end
376
388
 
@@ -5,7 +5,6 @@ module Selenium
5
5
  module Remote
6
6
  class DefaultHttpClient
7
7
  CONTENT_TYPE = "application/json"
8
- DEBUG = $VERBOSE == true
9
8
 
10
9
  class RetryException < StandardError; end
11
10
 
@@ -21,7 +20,7 @@ module Selenium
21
20
  if args.any?
22
21
  headers.merge!("Content-Type" => "#{CONTENT_TYPE}; charset=utf-8")
23
22
  payload = args.to_json
24
- puts " >>> #{payload}" if DEBUG
23
+ puts " >>> #{payload}" if $DEBUG
25
24
  end
26
25
 
27
26
  begin
@@ -52,7 +51,7 @@ module Selenium
52
51
  end
53
52
 
54
53
  def create_response(res)
55
- puts "<- #{res.body}\n" if DEBUG
54
+ puts "<- #{res.body}\n" if $DEBUG
56
55
  if res.content_type == CONTENT_TYPE
57
56
  Response.new do |r|
58
57
  r.code = res.code.to_i
@@ -30,7 +30,10 @@ module Selenium
30
30
  def assert_ok
31
31
  if @code.nil? || @code > 400
32
32
  if e = error()
33
- raise Error.for_remote_class(e['class']), e['message']
33
+ raise(
34
+ Error.for_remote_class(e['class']),
35
+ e['message'] || self
36
+ )
34
37
  else
35
38
  raise ServerError, self
36
39
  end
@@ -6,8 +6,8 @@ module Selenium
6
6
  def initialize(response)
7
7
  return super(response) if response.kind_of?(String)
8
8
 
9
- if response.error
10
- super(response.error["message"])
9
+ if response.respond_to?(:error) && err = response.error
10
+ super(err["message"] || err['class'])
11
11
  else
12
12
  super("status code #{response.code}")
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-15 00:00:00 +01:00
12
+ date: 2009-12-17 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency