selenium-client 1.2.15 → 1.2.16
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.
- data/README.markdown +10 -8
- data/examples/rspec/google_spec.rb +1 -1
- data/examples/script/google.rb +1 -1
- data/examples/testunit/google_test.rb +1 -1
- data/lib/nautilus/shell.rb +1 -1
- data/lib/selenium/client/base.rb +17 -6
- data/lib/selenium/client/extensions.rb +1 -1
- data/lib/selenium/client/idiomatic.rb +29 -5
- data/lib/selenium/client/javascript_expression_builder.rb +1 -1
- data/lib/selenium/client/selenium_helper.rb +1 -1
- data/lib/selenium/rake/remote_control_start_task.rb +4 -4
- data/lib/selenium/rake/remote_control_stop_task.rb +10 -6
- data/lib/selenium/remote_control/remote_control.rb +6 -4
- data/test/all_unit_tests.rb +1 -1
- metadata +2 -2
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.
|
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.
|
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.
|
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
|
200
|
-
a standalone packaging of Selenium Remote
|
201
|
-
You will find the
|
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
|
+
|
data/examples/script/google.rb
CHANGED
data/lib/nautilus/shell.rb
CHANGED
data/lib/selenium/client/base.rb
CHANGED
@@ -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,
|
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
|
-
|
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
|
-
|
369
|
+
if options.kind_of? Hash
|
370
370
|
options = options.keys.collect {|key| "#{key}=#{options[key]}" }.sort.join(", ")
|
371
|
-
|
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
|
-
|
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
|
-
|
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
|
@@ -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
|
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
|
24
|
-
# http://
|
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 =
|
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 #{
|
29
|
-
remote_control = Selenium::RemoteControl::RemoteControl.new(
|
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 =>
|
36
|
+
TCPSocket.wait_for_service_termination :host => host, :port => port
|
33
37
|
end
|
34
|
-
puts "Stopped Selenium Remote Control running at #{
|
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,
|
9
|
-
@host, @port
|
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,
|
27
|
+
Net::HTTP.get(@host, "/selenium-server/driver/?cmd=#{shutdown_command}", @port)
|
26
28
|
end
|
27
29
|
|
28
30
|
end
|
data/test/all_unit_tests.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2009-06-20 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|