selenium-client 1.2.15 → 1.2.16

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -81,7 +81,7 @@ Plain API
81
81
  # Sample Ruby script using the Selenium client API
82
82
  #
83
83
  require "rubygems"
84
- gem "selenium-client", ">=1.2.15"
84
+ gem "selenium-client", ">=1.2.16"
85
85
  require "selenium/client"
86
86
 
87
87
  begin
@@ -114,7 +114,7 @@ Writing Tests
114
114
  #
115
115
  require "test/unit"
116
116
  require "rubygems"
117
- gem "selenium-client", ">=1.2.15"
117
+ gem "selenium-client", ">=1.2.16"
118
118
  require "selenium/client"
119
119
 
120
120
  class ExampleTest < Test::Unit::TestCase
@@ -152,7 +152,7 @@ Writing Tests
152
152
 
153
153
  require 'rubygems'
154
154
  gem "rspec", "=1.2.6"
155
- gem "selenium-client", ">=1.2.15"
155
+ gem "selenium-client", ">=1.2.16"
156
156
  require "selenium/client"
157
157
  require "selenium/rspec/spec_helper"
158
158
 
@@ -196,10 +196,11 @@ Start/Stop a Selenium Remote Control Server
196
196
  ===========================================
197
197
 
198
198
  Selenium client comes with some convenient Rake tasks to start/stop a Remote Control server.
199
- To leverage all selenium-client capabilities I recommend downloading a recent nightly build of
200
- a standalone packaging of Selenium Remote Control (great for kick-ass Safari and Firefox 3 support anyway).
201
- You will find the mightly build at [OpenQA.org](http://archiva.openqa.org/repository/snapshots/org/openqa/selenium/selenium-remote-control/1.0-SNAPSHOT/)
202
-
199
+ To leverage the latest selenium-client capabilities, you may need to download
200
+ a recent nightly build of a standalone packaging of Selenium Remote
201
+ Control. You will find the nightly build at
202
+ http://nexus.openqa.org/content/repositories/snapshots/org/seleniumhq/selenium/server/selenium-server/
203
+
203
204
  You typically "freeze" the Selenium Remote Control jar in your `vendor`
204
205
  directory.
205
206
 
@@ -302,6 +303,7 @@ Contributors
302
303
  - Support for locator including single quotes in `wait_for_...` methods
303
304
  - Do not capture system state on execution errors for pending examples
304
305
  (ExamplePendingError, NotYetImplementedError)
306
+ - Auto-highlighting support
305
307
 
306
308
  * Rick Lee-Morlang (`rleemorlang`):
307
309
  - Fix for incremental calls to `wait_for_text`
@@ -314,4 +316,4 @@ Contributors
314
316
  * [Adam Greene](http://blog.sweetspot.dm) (`skippy`)
315
317
  - Added the ability to redirect output to a log file, when
316
318
  launching Selenium Remote Control with the Rake task
317
-
319
+
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  gem "rspec", "=1.2.6"
3
- gem "selenium-client", ">=1.2.15"
3
+ gem "selenium-client", ">=1.2.16"
4
4
  require "selenium/client"
5
5
  require "selenium/rspec/spec_helper"
6
6
 
@@ -3,7 +3,7 @@
3
3
  # Sample Ruby script using the Selenium client API
4
4
  #
5
5
  require "rubygems"
6
- gem "selenium-client", ">=1.2.15"
6
+ gem "selenium-client", ">=1.2.16"
7
7
  require "selenium/client"
8
8
 
9
9
  begin
@@ -4,7 +4,7 @@
4
4
  #
5
5
  require "test/unit"
6
6
  require "rubygems"
7
- gem "selenium-client", ">=1.2.15"
7
+ gem "selenium-client", ">=1.2.16"
8
8
  require "selenium/client"
9
9
 
10
10
  class ExampleTest < Test::Unit::TestCase
@@ -19,7 +19,7 @@ module Nautilus
19
19
  end
20
20
 
21
21
  def windows?
22
- PLATFORM['win32']
22
+ RUBY_PLATFORM =~ /mswin/
23
23
  end
24
24
 
25
25
  def sh(command)
@@ -9,7 +9,9 @@ module Selenium
9
9
  include Selenium::Client::Idiomatic
10
10
 
11
11
  attr_reader :host, :port, :browser_string, :browser_url,
12
- :default_timeout_in_seconds, :default_javascript_framework
12
+ :default_timeout_in_seconds,
13
+ :default_javascript_framework,
14
+ :highlight_located_element_by_default
13
15
 
14
16
  #
15
17
  # Create a new client driver
@@ -34,6 +36,15 @@ module Selenium
34
36
  # :url => "http://localhost:3000",
35
37
  # :javascript_framework => :jquery
36
38
  #
39
+ # You can also enables automatic highlighting of located elements
40
+ # by passing the highlight_located_element option, e.g.
41
+ #
42
+ # Selenium::Client::Driver.new \
43
+ # :host => "localhost",
44
+ # :port => 4444,
45
+ # :browser => "*firefox",
46
+ # :highlight_located_element => true
47
+ #
37
48
  def initialize(*args)
38
49
  if args[0].kind_of?(Hash)
39
50
  options = args[0]
@@ -43,6 +54,7 @@ module Selenium
43
54
  @browser_url = options[:url]
44
55
  @default_timeout_in_seconds = (options[:timeout_in_seconds] || 300).to_i
45
56
  @default_javascript_framework = options[:javascript_framework] || :prototype
57
+ @highlight_located_element_by_default = options[:highlight_located_element] || false
46
58
  else
47
59
  @host = args[0]
48
60
  @port = args[1].to_i
@@ -50,6 +62,7 @@ module Selenium
50
62
  @browser_url = args[3]
51
63
  @default_timeout_in_seconds = (args[4] || 300).to_i
52
64
  @default_javascript_framework = :prototype
65
+ @highlight_located_element_by_default = false
53
66
  end
54
67
 
55
68
  @extension_js = ""
@@ -73,7 +86,8 @@ module Selenium
73
86
  @session_id = result
74
87
  # Consistent timeout on the remote control and driver side.
75
88
  # Intuitive and this is what you want 90% of the time
76
- self.remote_control_timeout_in_seconds = @default_timeout_in_seconds
89
+ self.remote_control_timeout_in_seconds = @default_timeout_in_seconds
90
+ self.highlight_located_element = true if highlight_located_element_by_default
77
91
  end
78
92
 
79
93
  def close_current_browser_session
@@ -95,11 +109,8 @@ module Selenium
95
109
 
96
110
  def javascript_extension=(new_javascript_extension)
97
111
  @extension_js = new_javascript_extension
98
- end
99
-
100
- def set_extension_js(new_javascript_extension)
101
- javascript_extension = new_javascript_extension
102
112
  end
113
+ alias :set_extension_js :javascript_extension=
103
114
 
104
115
  end
105
116
 
@@ -12,7 +12,7 @@ module Selenium
12
12
  builder = JavascriptExpressionBuilder.new active_javascript_framework(options)
13
13
  wait_for_condition builder.no_pending_ajax_requests.script,
14
14
  options[:timeout_in_seconds]
15
- end
15
+ end
16
16
 
17
17
  # Wait for all Prototype effects to be processed (the wait in happenning browser side).
18
18
  #
@@ -366,9 +366,9 @@ module Selenium
366
366
  # 'optionsString' is options for the cookie. Currently supported options include 'path', 'max_age' and 'domain'.
367
367
  # the optionsString's format is "path=/path/, max_age=60, domain=.foo.com". The order of options are irrelevant, the unit of the value of 'max_age' is second. Note that specifying a domain that isn't a subset of the current domain will usually fail.
368
368
  def create_cookie(name_value_pair, options="")
369
- if options.kind_of? Hash
369
+ if options.kind_of? Hash
370
370
  options = options.keys.collect {|key| "#{key}=#{options[key]}" }.sort.join(", ")
371
- end
371
+ end
372
372
  remote_control_command "createCookie", [name_value_pair,options,]
373
373
  end
374
374
 
@@ -386,10 +386,10 @@ module Selenium
386
386
  # 'name' is the name of the cookie to be deleted
387
387
  # 'optionsString' is options for the cookie. Currently supported options include 'path', 'domain' and 'recurse.' The optionsString's format is "path=/path/, domain=.foo.com, recurse=true". The order of options are irrelevant. Note that specifying a domain that isn't a subset of the current domain will usually fail.
388
388
  def delete_cookie(name, options="")
389
- if options.kind_of? Hash
389
+ if options.kind_of? Hash
390
390
  ordered_keys = options.keys.sort {|a,b| a.to_s <=> b.to_s }
391
391
  options = ordered_keys.collect {|key| "#{key}=#{options[key]}" }.join(", ")
392
- end
392
+ end
393
393
  remote_control_command "deleteCookie", [name,options,]
394
394
  end
395
395
 
@@ -442,7 +442,31 @@ module Selenium
442
442
  remote_control_command "useXpathLibrary", [library_name.to_s]
443
443
  end
444
444
 
445
+ #
446
+ # Turn on/off the automatic hightlighting of the element driven or
447
+ # inspected by Selenium core. Useful when recording videos
448
+ #
449
+ def highlight_located_element=(enabled)
450
+ boolean = (true == enabled)
451
+ js_eval "selenium.browserbot.shouldHighlightLocatedElement = #{boolean}"
452
+ end
453
+
454
+ # Get execution delay in milliseconds, i.e. a pause delay following
455
+ # each selenium operation. By default, there is no such delay
456
+ # (value is 0).
457
+ def execution_delay
458
+ string_command "getSpeed"
459
+ end
460
+
461
+ # Set the execution delay in milliseconds, i.e. a pause delay following
462
+ # each selenium operation. By default, there is no such delay.
463
+ #
464
+ # Setting an execution can be useful to troubleshoot of capture videos
465
+ def execution_delay=(delay_in_milliseconds)
466
+ remote_control_command "setSpeed", [delay_in_milliseconds]
467
+ end
468
+
445
469
  end
446
-
470
+
447
471
  end
448
472
  end
@@ -7,7 +7,7 @@ module Selenium
7
7
  def initialize(javascript_framework_name=nil)
8
8
  @framework = javascript_framework_for(javascript_framework_name) if javascript_framework_name
9
9
  @script = ""
10
- end
10
+ end
11
11
 
12
12
  def append(text)
13
13
  @script << text
@@ -5,7 +5,7 @@
5
5
  module Selenium
6
6
  module Client
7
7
 
8
- module SeleniumHelper
8
+ module SeleniumHelper
9
9
 
10
10
  # Overrides default open method to actually delegates to @selenium
11
11
  def open(url)
@@ -18,10 +18,10 @@ module Selenium
18
18
  # it will be "auto-discovered" in `vendor` directory using the following
19
19
  # path : `vendor/selenium-remote-control/selenium-server*-standalone.jar`
20
20
  #
21
- # To leverage all selenium-client capabilities I recommend downloading
21
+ # To leverage the latest selenium-client capabilities, you may need to download
22
22
  # a recent nightly build of a standalone packaging of Selenium Remote
23
- # Control. You will find the mightly build at
24
- # http://archiva.openqa.org/repository/snapshots/org/openqa/selenium/selenium-remote-control/1.0-SNAPSHOT/
23
+ # Control. You will find the nightly build at
24
+ # http://nexus.openqa.org/content/repositories/snapshots/org/seleniumhq/selenium/server/selenium-server/
25
25
  class RemoteControlStartTask
26
26
  attr_accessor :port, :timeout_in_seconds, :background,
27
27
  :wait_until_up_and_running, :additional_args,
@@ -49,7 +49,7 @@ module Selenium
49
49
  desc "Launch Selenium Remote Control"
50
50
  task @name do
51
51
  puts "Starting Selenium Remote Control at 0.0.0.0:#{@port}..."
52
- remote_control = Selenium::RemoteControl::RemoteControl.new("0.0.0.0", @port, @timeout_in_seconds)
52
+ remote_control = Selenium::RemoteControl::RemoteControl.new("0.0.0.0", @port, :timeout => @timeout_in_seconds)
53
53
  remote_control.jar_file = @jar_file
54
54
  remote_control.additional_args = @additional_args
55
55
  remote_control.log_to = @log_to
@@ -10,13 +10,15 @@ module Selenium
10
10
  # end
11
11
  #
12
12
  class RemoteControlStopTask
13
- attr_accessor :host, :port, :timeout_in_seconds, :wait_until_stopped
13
+ attr_accessor :host, :port, :timeout_in_seconds, :wait_until_stopped,
14
+ :shutdown_command
14
15
 
15
16
  def initialize(name = :'selenium:rc:stop')
16
17
  @host = "localhost"
17
18
  @name = name
18
19
  @port = 4444
19
- @timeout_in_seconds = 5
20
+ @timeout_in_seconds = nil
21
+ @shutdown_command = nil
20
22
  @wait_until_stopped = true
21
23
  yield self if block_given?
22
24
  define
@@ -25,13 +27,15 @@ module Selenium
25
27
  def define
26
28
  desc "Stop Selenium Remote Control running"
27
29
  task @name do
28
- puts "Stopping Selenium Remote Control running at #{@host}:#{@port}..."
29
- remote_control = Selenium::RemoteControl::RemoteControl.new(@host, @port, @timeout_in_seconds)
30
+ puts "Stopping Selenium Remote Control running at #{host}:#{port}..."
31
+ remote_control = Selenium::RemoteControl::RemoteControl.new(
32
+ host, port, :timeout => timeout_in_seconds,
33
+ :shutdown_command => shutdown_command)
30
34
  remote_control.stop
31
35
  if @wait_until_stopped
32
- TCPSocket.wait_for_service_termination :host => @host, :port => @port
36
+ TCPSocket.wait_for_service_termination :host => host, :port => port
33
37
  end
34
- puts "Stopped Selenium Remote Control running at #{@host}:#{@port}"
38
+ puts "Stopped Selenium Remote Control running at #{host}:#{port}"
35
39
  end
36
40
  end
37
41
 
@@ -2,11 +2,13 @@ module Selenium
2
2
  module RemoteControl
3
3
 
4
4
  class RemoteControl
5
- attr_reader :host, :port, :timeout_in_seconds
5
+ attr_reader :host, :port, :timeout_in_seconds, :shutdown_command
6
6
  attr_accessor :additional_args, :jar_file, :log_to
7
7
 
8
- def initialize(host, port, timeout_in_seconds = 2 * 60)
9
- @host, @port, @timeout_in_seconds = host, port, timeout_in_seconds
8
+ def initialize(host, port, options={})
9
+ @host, @port = host, port
10
+ @timeout_in_seconds = options[:timeout] || (2 * 60)
11
+ @shutdown_command = options[:shutdown_command] || "shutDownSeleniumServer"
10
12
  @additional_args = []
11
13
  @shell = Nautilus::Shell.new
12
14
  end
@@ -22,7 +24,7 @@ module Selenium
22
24
  end
23
25
 
24
26
  def stop
25
- Net::HTTP.get(@host, '/selenium-server/driver/?cmd=shutDown', @port)
27
+ Net::HTTP.get(@host, "/selenium-server/driver/?cmd=#{shutdown_command}", @port)
26
28
  end
27
29
 
28
30
  end
@@ -1,3 +1,3 @@
1
- Dir["#{File.dirname __FILE__}/unit/**/*_test.rb"].each do |test_case|
1
+ Dir["#{File.dirname __FILE__}/unit/**/*_tests.rb"].each do |test_case|
2
2
  require test_case
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.15
4
+ version: 1.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenQA
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-12 00:00:00 -07:00
12
+ date: 2009-06-20 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15