selenium-client 1.2.16 → 1.2.17

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.
@@ -46,7 +46,9 @@ Features
46
46
  * `click 'the_button_id', :wait_for => :no_text, :element => 'notification_box', :text => 'Disappearing Text'`
47
47
  * `click 'the_button_id', :wait_for => :effects`
48
48
  * `click 'the_button_id', :wait_for => :value, :element => 'a_locator', :value => 'some value'`
49
- * `click 'the_button_id', :wait_for => :no_value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to not be 'some value'`
49
+ * `click 'the_button_id', :wait_for => :no_value, :element => 'a_locator', :value => 'some value'`
50
+ * `click 'the_button_id', :wait_for => :visible, :element => 'a_locator'`
51
+ * `click 'the_button_id', :wait_for => :not_visible, :element => 'a_locator'`
50
52
  * `click 'the_button_id', :wait_for => :condition, :javascript => "some arbitrary javascript expression"`
51
53
 
52
54
  Check out the `click`, `go_back` and `wait_for` methods of the [Idiomatic Module](http://selenium-client.rubyforge.org/classes/Selenium/Client/Idiomatic.html)
@@ -151,7 +153,7 @@ Writing Tests
151
153
  If BDD is more your style, here is how you can achieve the same thing using RSpec:
152
154
 
153
155
  require 'rubygems'
154
- gem "rspec", "=1.2.6"
156
+ gem "rspec", "=1.2.8"
155
157
  gem "selenium-client", ">=1.2.16"
156
158
  require "selenium/client"
157
159
  require "selenium/rspec/spec_helper"
@@ -316,4 +318,11 @@ Contributors
316
318
  * [Adam Greene](http://blog.sweetspot.dm) (`skippy`)
317
319
  - Added the ability to redirect output to a log file, when
318
320
  launching Selenium Remote Control with the Rake task
319
-
321
+
322
+ * [Eliot Sykes](http://blog.eliotsykes.com) (`eliotsykes`)
323
+ - wait_for_visibility [patch](http://github.com/eliotsykes/selenium-client/commit/4c7f3d01aa75a6b1917fbf71335b0069392ed546)
324
+
325
+ * [Frederik Fix](http://github.com/derfred)(`derfred`)
326
+ - Fix escaping bug when dealing with embedded regexes such as
327
+ "webratlink=evalregex:/Pastry Lovers \\(Organizer\\)/"
328
+ [patch](http://github.com/derfred/selenium-client/commit/4342cbb39d1a92b8db8f26ee0dc6c1a8f3287737)
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
- gem "rspec", "=1.2.6"
3
- gem "selenium-client", ">=1.2.16"
2
+ gem "rspec", "=1.2.8"
3
+ gem "selenium-client", ">=1.2.17"
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.16"
6
+ gem "selenium-client", ">=1.2.17"
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.16"
7
+ gem "selenium-client", ">=1.2.17"
8
8
  require "selenium/client"
9
9
 
10
10
  class ExampleTest < Test::Unit::TestCase
@@ -4,7 +4,7 @@ module Selenium
4
4
  # Convenience methods not explicitely part of the protocol
5
5
  module Extensions
6
6
 
7
- # These for all Ajax request to finish (Only works if you are using prototype, the wait in happenning browser side)
7
+ # These for all Ajax request to finish (Only works if you are using prototype, the wait happens in the browser)
8
8
  #
9
9
  # See http://davidvollbracht.com/2008/6/4/30-days-of-tech-day-3-waitforajax for
10
10
  # more background.
@@ -14,7 +14,7 @@ module Selenium
14
14
  options[:timeout_in_seconds]
15
15
  end
16
16
 
17
- # Wait for all Prototype effects to be processed (the wait in happenning browser side).
17
+ # Wait for all Prototype effects to be processed (the wait happens in the browser).
18
18
  #
19
19
  # Credits to http://github.com/brynary/webrat/tree/master
20
20
  def wait_for_effects(options={})
@@ -23,19 +23,19 @@ module Selenium
23
23
  options[:timeout_in_seconds]
24
24
  end
25
25
 
26
- # Wait for an element to be present (the wait in happenning browser side).
27
- def wait_for_element(locator, options={})
28
- builder = JavascriptExpressionBuilder.new
29
- builder.find_element(locator).append("element != null;")
30
- wait_for_condition builder.script, options[:timeout_in_seconds]
31
- end
26
+ # Wait for an element to be present (the wait happens in the browser).
27
+ def wait_for_element(locator, options={})
28
+ builder = JavascriptExpressionBuilder.new
29
+ builder.find_element(locator).append("element != null;")
30
+ wait_for_condition builder.script, options[:timeout_in_seconds]
31
+ end
32
32
 
33
- # Wait for an element to NOT be present (the wait in happenning browser side).
34
- def wait_for_no_element(locator, options={})
35
- builder = JavascriptExpressionBuilder.new
36
- builder.find_element(locator).append("element == null;")
37
- wait_for_condition builder.script, options[:timeout_in_seconds]
38
- end
33
+ # Wait for an element to NOT be present (the wait happens in the browser).
34
+ def wait_for_no_element(locator, options={})
35
+ builder = JavascriptExpressionBuilder.new
36
+ builder.find_element(locator).append("element == null;")
37
+ wait_for_condition builder.script, options[:timeout_in_seconds]
38
+ end
39
39
 
40
40
  # Wait for some text to be present (the wait is happening browser side).
41
41
  #
@@ -73,7 +73,7 @@ module Selenium
73
73
  wait_for_condition builder.script, options[:timeout_in_seconds]
74
74
  end
75
75
 
76
- # Wait for some text to NOT be present (the wait in happenning browser side).
76
+ # Wait for some text to NOT be present (the wait happens in the browser).
77
77
  #
78
78
  # See wait_for_text for usage details.
79
79
  def wait_for_no_text(pattern, options={})
@@ -82,19 +82,32 @@ module Selenium
82
82
  wait_for_condition builder.script, options[:timeout_in_seconds]
83
83
  end
84
84
 
85
- # Wait for a field to get a specific value (the wait in happenning browser side).
85
+ # Wait for a field to get a specific value (the wait happens in the browser).
86
86
  def wait_for_field_value(locator, expected_value, options={})
87
87
  builder = JavascriptExpressionBuilder.new
88
88
  builder.find_element(locator).element_value_is(expected_value)
89
89
  wait_for_condition builder.script, options[:timeout_in_seconds]
90
90
  end
91
91
 
92
+ # Wait for a field to not have a specific value (the wait happens in the browser).
92
93
  def wait_for_no_field_value(locator, expected_value, options={})
93
94
  builder = JavascriptExpressionBuilder.new
94
95
  builder.find_element(locator).element_value_is_not(expected_value)
95
96
  wait_for_condition builder.script, options[:timeout_in_seconds]
96
97
  end
97
98
 
99
+ # Wait for something to be visible (the wait happens in the browser).
100
+ def wait_for_visible(locator, options={})
101
+ builder = JavascriptExpressionBuilder.new
102
+ wait_for_condition builder.visible(locator).script, options[:timeout_in_seconds]
103
+ end
104
+
105
+ # Wait for something to not be visible (the wait happens in the browser).
106
+ def wait_for_not_visible(locator, options={})
107
+ builder = JavascriptExpressionBuilder.new
108
+ wait_for_condition builder.not_visible(locator).script, options[:timeout_in_seconds]
109
+ end
110
+
98
111
  def active_javascript_framework(options)
99
112
  options[:javascript_framework] || default_javascript_framework
100
113
  end
@@ -42,8 +42,8 @@ module Selenium
42
42
  # * 'timeout_in_seconds' is a timeout in seconds, after which this
43
43
  # command will return with an error
44
44
  def wait_for_page(timeout_in_seconds=nil)
45
- actual_timeout = timeout_in_seconds || default_timeout_in_seconds
46
- remote_control_command "waitForPageToLoad", [actual_timeout * 1000,]
45
+ remote_control_command "waitForPageToLoad",
46
+ [actual_timeout_in_milliseconds(timeout_in_seconds),]
47
47
  end
48
48
  alias_method :wait_for_page_to_load, :wait_for_page
49
49
 
@@ -52,8 +52,8 @@ module Selenium
52
52
  # window_id is the JavaScript window "name" of the window that will appear (not the text of the title bar)
53
53
  # timeout_in_seconds is a timeout in seconds, after which the action will return with an error
54
54
  def wait_for_popup(window_id, timeout_in_seconds=nil)
55
- actual_timeout = timeout_in_seconds || default_timeout_in_seconds
56
- remote_control_command "waitForPopUp", [window_id, actual_timeout * 1000 ,]
55
+ remote_control_command "waitForPopUp",
56
+ [window_id, actual_timeout_in_milliseconds(timeout_in_seconds) ,]
57
57
  end
58
58
 
59
59
  # Flexible wait semantics. ait is happening browser side. Useful for testing AJAX application.
@@ -74,6 +74,8 @@ module Selenium
74
74
  # * wait :wait_for => :no_text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to not be 'some text'
75
75
  # * wait :wait_for => :value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to be 'some value'
76
76
  # * wait :wait_for => :no_value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to not be 'some value'
77
+ # * wait :wait_for => :visible, :element => 'a_locator' # will wait for element to be visible
78
+ # * wait :wait_for => :not_visible, :element => 'a_locator' # will wait for element to not be visible
77
79
  # * wait :wait_for => :condition, :javascript => 'some expression' # will wait for the javascript expression to be true
78
80
  #
79
81
  # Using options you can also define an explicit timeout (:timeout_in_seconds key). Otherwise the default driver timeout
@@ -100,6 +102,10 @@ module Selenium
100
102
  wait_for_field_value options[:element], options[:value], options
101
103
  elsif options[:wait_for] == :no_value
102
104
  wait_for_no_field_value options[:element], options[:value], options
105
+ elsif options[:wait_for] == :visible
106
+ wait_for_visible options[:element], options
107
+ elsif options[:wait_for] == :not_visible
108
+ wait_for_not_visible options[:element], options
103
109
  elsif options[:wait_for] == :condition
104
110
  wait_for_condition options[:javascript], options[:timeout_in_seconds]
105
111
  end
@@ -133,6 +139,8 @@ module Selenium
133
139
  # * click "a_locator", :wait_for => :no_text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to not be 'some text'
134
140
  # * click "a_locator", :wait_for => :value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to be 'some value'
135
141
  # * click "a_locator", :wait_for => :no_value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to not be 'some value'
142
+ # * click "a_locator", :wait_for => :visible, :element => 'a_locator' # will wait for element to be visible
143
+ # * click "a_locator", :wait_for => :not_visible, :element => 'a_locator' # will wait for element to not be visible
136
144
  # * click "a_locator", :wait_for => :condition, :javascript => 'some expression' # will wait for the javascript expression to be true
137
145
  #
138
146
  # Using options you can also define an explicit timeout (:timeout_in_seconds key). Otherwise the default driver timeout
@@ -284,7 +292,7 @@ module Selenium
284
292
  #
285
293
  # Actions that require waiting include "open" and the "waitFor*" actions.
286
294
  def remote_control_timeout_in_seconds=(timeout_in_seconds)
287
- remote_control_command "setTimeout", [timeout_in_seconds * 1000,]
295
+ remote_control_command "setTimeout", [actual_timeout_in_milliseconds(timeout_in_seconds),]
288
296
  end
289
297
 
290
298
  # Returns the text from a cell of a table. The cellAddress syntax
@@ -308,7 +316,8 @@ module Selenium
308
316
  # * 'script' is the JavaScript snippet to run
309
317
  # * 'timeout_in_seconds' is a timeout in seconds, after which this command will return with an error
310
318
  def wait_for_condition(script, timeout_in_seconds = nil)
311
- remote_control_command "waitForCondition", [script, (timeout_in_seconds || default_timeout_in_seconds) * 1000,]
319
+ remote_control_command "waitForCondition",
320
+ [script, actual_timeout_in_milliseconds(timeout_in_seconds),]
312
321
  end
313
322
 
314
323
  # Simulates the user clicking the "back" button on their browser.
@@ -331,6 +340,8 @@ module Selenium
331
340
  # * go_back :wait_for => :no_text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to not be 'some text'
332
341
  # * go_back :wait_for => :condition, :javascript => 'some expression' # will wait for the javascript expression to be true
333
342
  # * go_back :wait_for => :value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to be 'some value'
343
+ # * go_back :wait_for => :visible, :element => 'a_locator' # will wait for element to be visible
344
+ # * go_back :wait_for => :not_visible, :element => 'a_locator' # will wait for element to not be visible
334
345
  # * go_back :wait_for => :no_value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to not be 'some value'
335
346
  #
336
347
  # Using options you can also define an explicit timeout (:timeout_in_seconds key). Otherwise the default driver timeout
@@ -466,6 +477,11 @@ module Selenium
466
477
  remote_control_command "setSpeed", [delay_in_milliseconds]
467
478
  end
468
479
 
480
+ def actual_timeout_in_milliseconds(timeout_in_seconds)
481
+ actual_timeout = (timeout_in_seconds ||
482
+ default_timeout_in_seconds).to_i
483
+ actual_timeout * 1000
484
+ end
469
485
  end
470
486
 
471
487
  end
@@ -22,6 +22,14 @@ module Selenium
22
22
  append window_script("Effect.Queue.size() == 0")
23
23
  end
24
24
 
25
+ def visible(locator)
26
+ append "selenium.isVisible('#{quote_escaped(locator)}')"
27
+ end
28
+
29
+ def not_visible(locator)
30
+ append "!selenium.isVisible('#{quote_escaped(locator)}')"
31
+ end
32
+
25
33
  def find_element(locator)
26
34
  append <<-EOS
27
35
  var element;
@@ -101,7 +109,7 @@ module Selenium
101
109
  end
102
110
 
103
111
  def quote_escaped(a_string)
104
- a_string.gsub(/'/, %q<\\\'>)
112
+ a_string.gsub(/\\/, "\\\\\\").gsub(/'/, %q<\\\'>)
105
113
  end
106
114
  end
107
115
  end
@@ -0,0 +1,16 @@
1
+ require 'selenium/rake/tasks'
2
+
3
+ Selenium::Rake::RemoteControlStartTask.new do |rc|
4
+ rc.timeout_in_seconds = 3 * 60
5
+ rc.background = true
6
+ rc.wait_until_up_and_running = true
7
+ rc.additional_args << "-singleWindow"
8
+ end
9
+
10
+ Selenium::Rake::RemoteControlStopTask.new
11
+
12
+ desc "Restart Selenium Remote Control"
13
+ task :'selenium:rc:restart' do
14
+ Rake::Task[:'selenium:rc:stop'].execute [] rescue nil
15
+ Rake::Task[:'selenium:rc:start'].execute []
16
+ end
@@ -28,11 +28,13 @@ module Selenium
28
28
  :log_to
29
29
  attr_reader :jar_file
30
30
 
31
+ JAR_FILE_PATTERN = "vendor/selenium-remote-control/selenium-server-*.jar"
32
+
31
33
  def initialize(name = :'selenium:rc:start')
32
34
  @name = name
33
35
  @port = 4444
34
36
  @timeout_in_seconds = 5
35
- project_specific_jar = Dir["vendor/selenium-remote-control/selenium-server*-standalone.jar"].first
37
+ project_specific_jar = Dir[JAR_FILE_PATTERN].first
36
38
  @jar_file = project_specific_jar
37
39
  @additional_args = []
38
40
  @background = false
@@ -49,6 +51,7 @@ module Selenium
49
51
  desc "Launch Selenium Remote Control"
50
52
  task @name do
51
53
  puts "Starting Selenium Remote Control at 0.0.0.0:#{@port}..."
54
+ raise "Could not find jar file '#{@jar_file}'. Expected it under #{JAR_FILE_PATTERN}" unless @jar_file && File.exists?(@jar_file)
52
55
  remote_control = Selenium::RemoteControl::RemoteControl.new("0.0.0.0", @port, :timeout => @timeout_in_seconds)
53
56
  remote_control.jar_file = @jar_file
54
57
  remote_control.additional_args = @additional_args
@@ -7,7 +7,7 @@ require "digest/md5"
7
7
  require "base64"
8
8
  require 'tmpdir'
9
9
  require "rubygems"
10
- gem "rspec", "1.2.6"
10
+ gem "rspec", "1.2.8"
11
11
  require "spec"
12
12
  require 'spec/runner/formatter/html_formatter'
13
13
  require File.expand_path(File.dirname(__FILE__) + "/file_path_strategy")
@@ -1,5 +1,5 @@
1
1
  require "rubygems"
2
- gem "rspec", "=1.2.6"
2
+ gem "rspec", "=1.2.8"
3
3
  require 'spec'
4
4
  require 'spec/example/example_group'
5
5
 
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.16
4
+ version: 1.2.17
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-06-20 00:00:00 -07:00
12
+ date: 2009-09-28 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -36,6 +36,7 @@ files:
36
36
  - lib/selenium/client.rb
37
37
  - lib/selenium/command_error.rb
38
38
  - lib/selenium/protocol_error.rb
39
+ - lib/selenium/rake/default_tasks.rb
39
40
  - lib/selenium/rake/remote_control_start_task.rb
40
41
  - lib/selenium/rake/remote_control_stop_task.rb
41
42
  - lib/selenium/rake/tasks.rb
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
81
  requirements: []
81
82
 
82
83
  rubyforge_project: selenium-client
83
- rubygems_version: 1.3.2
84
+ rubygems_version: 1.3.5
84
85
  signing_key:
85
86
  specification_version: 3
86
87
  summary: Official Ruby Client for Selenium RC.