ydim-html 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.travis.yml +29 -0
  4. data/Gemfile +12 -0
  5. data/History.txt +11 -0
  6. data/LICENSE.txt +339 -0
  7. data/Manifest.txt +47 -0
  8. data/Rakefile +21 -0
  9. data/bin/ydim-htmld +38 -0
  10. data/doc/favicon.ico +0 -0
  11. data/doc/index.rbx +16 -0
  12. data/doc/resources/javascript/dojo.js +5940 -0
  13. data/doc/resources/javascript/iframe_history.html +53 -0
  14. data/doc/resources/javascript/ydim.js +67 -0
  15. data/doc/resources/ydim/ydim.css +113 -0
  16. data/lib/ydim/html.rb +10 -0
  17. data/lib/ydim/html/config.rb +37 -0
  18. data/lib/ydim/html/state/ajax_values.rb +17 -0
  19. data/lib/ydim/html/state/autoinvoice.rb +94 -0
  20. data/lib/ydim/html/state/confirm.rb +16 -0
  21. data/lib/ydim/html/state/debitor.rb +82 -0
  22. data/lib/ydim/html/state/debitors.rb +24 -0
  23. data/lib/ydim/html/state/global.rb +100 -0
  24. data/lib/ydim/html/state/global_predefine.rb +14 -0
  25. data/lib/ydim/html/state/init.rb +21 -0
  26. data/lib/ydim/html/state/invoice.rb +180 -0
  27. data/lib/ydim/html/state/invoices.rb +70 -0
  28. data/lib/ydim/html/state/pdf.rb +17 -0
  29. data/lib/ydim/html/util/lookandfeel.rb +133 -0
  30. data/lib/ydim/html/util/server.rb +37 -0
  31. data/lib/ydim/html/util/session.rb +29 -0
  32. data/lib/ydim/html/util/validator.rb +63 -0
  33. data/lib/ydim/html/version.rb +7 -0
  34. data/lib/ydim/html/view/ajax_values.rb +27 -0
  35. data/lib/ydim/html/view/autoinvoice.rb +80 -0
  36. data/lib/ydim/html/view/autoinvoices.rb +42 -0
  37. data/lib/ydim/html/view/confirm.rb +28 -0
  38. data/lib/ydim/html/view/debitor.rb +118 -0
  39. data/lib/ydim/html/view/debitors.rb +45 -0
  40. data/lib/ydim/html/view/htmlgrid.rb +104 -0
  41. data/lib/ydim/html/view/init.rb +30 -0
  42. data/lib/ydim/html/view/invoice.rb +218 -0
  43. data/lib/ydim/html/view/invoices.rb +159 -0
  44. data/lib/ydim/html/view/navigation.rb +29 -0
  45. data/lib/ydim/html/view/pdf.rb +24 -0
  46. data/lib/ydim/html/view/template.rb +71 -0
  47. data/readme.md +28 -0
  48. data/spec/smoketest_spec.rb +234 -0
  49. data/spec/spec_helper.rb +117 -0
  50. data/spec/stub/http_server.rb +157 -0
  51. data/test/selenium.rb +1690 -0
  52. data/test/selenium/selenium-server.jar +0 -0
  53. data/test/selenium/test_autoinvoice.rb +319 -0
  54. data/test/selenium/test_debitor.rb +344 -0
  55. data/test/selenium/test_debitors.rb +47 -0
  56. data/test/selenium/test_init.rb +105 -0
  57. data/test/selenium/test_invoice.rb +296 -0
  58. data/test/selenium/test_invoices.rb +176 -0
  59. data/test/selenium/unit.rb +125 -0
  60. data/test/stub/http_server.rb +141 -0
  61. data/test/suite.rb +15 -0
  62. data/ydim-html.gemspec +36 -0
  63. metadata +302 -0
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Stub.http_server -- de.oddb.org -- 21.11.2006 -- hwyss@ywesee.com
4
+
5
+ require 'sbsm/request'
6
+ require 'sbsm/trans_handler'
7
+ require 'webrick'
8
+
9
+ class Object
10
+ def meta_class; class << self; self; end; end
11
+ def meta_eval &blk; meta_class.instance_eval &blk; end
12
+ end
13
+
14
+ def trace(msg)
15
+ $stderr.puts msg
16
+ end
17
+ ## compatibility-brainfuck for integrating Apache-SBSM-Requests with WEBrick
18
+ module YDIM
19
+ module Html
20
+ YDIM_VERSION = "test-version"
21
+ module Stub
22
+ class Notes < Hash
23
+ alias :add :store
24
+ end
25
+ class Output < String
26
+ alias :write :<<
27
+ alias :print :<<
28
+ end
29
+ class HTTPServer < WEBrick::HTTPServer
30
+ attr_accessor :document_root
31
+ def method_missing(method, *args, &block)
32
+ @logger.warn "ignoring method: #{method}"
33
+ end
34
+ end
35
+ def Stub.http_server(drburi, log_level=0)
36
+ doc = File.expand_path('../../doc', File.dirname(__FILE__))
37
+ logger = WEBrick::Log.new
38
+ logger.level = log_level
39
+ config = {
40
+ :Host => 'localhost',
41
+ :Port => 10080,
42
+ :DocumentRoot => doc,
43
+ :Logger => logger
44
+ }
45
+ if(log_level == 0)
46
+ config.store(:AccessLog, [])
47
+ end
48
+ server = HTTPServer.new(config)
49
+ server.document_root = doc
50
+ application = Proc.new { |req, resp|
51
+ if(req.uri == '/favicon.ico')
52
+ resp.body = File.open(File.join(doc, req.uri))
53
+ else
54
+ ARGV.push('')
55
+ req.server = server
56
+ # ignore selenium/dojo-added GET-Parameters
57
+ $stderr.puts "drburi is #{drburi} req.uri #{req.uri}"
58
+ req.uri = CGI.unescape(req.uri[/^[^?]*/])
59
+ SBSM::TransHandler.instance.translate_uri(req)
60
+ ## not Threadsafe!
61
+ SBSM::Apache.request = req
62
+ output = Output.new
63
+ sbsm = SBSM::Request.new(drburi)
64
+ sbsm.meta_eval { define_method(:handle_exception) { |e| raise e } }
65
+ sbsm.cgi.params.update(req.query)
66
+ sbsm.cgi.env_table['SERVER_NAME'] =
67
+ YDIM::Html.config.http_server.gsub('http://', '') + ':10080'
68
+ sbsm.cgi.env_table['REQUEST_METHOD'] = req.request_method
69
+ sbsm.cgi.cookies['_session_id'] = 'test:preset-session-id'
70
+ sbsm.cgi.output = output
71
+ sbsm.process
72
+ if(/^location:/i.match(output))
73
+ resp.status = 303
74
+ end
75
+ resp.rawdata = true
76
+ resp.body = output
77
+ end
78
+ }
79
+ server.mount_proc('/', &application)
80
+ server.mount_proc('/de', &application)
81
+ server.mount_proc('/de/.*', &application)
82
+ res = File.join(doc, 'resources')
83
+ server.mount('/resources', WEBrick::HTTPServlet::FileHandler, res, {})
84
+ server
85
+ end
86
+ end
87
+ end
88
+ end
89
+ module WEBrick
90
+ class HTTPRequest
91
+ attr_accessor :server, :uri, :notes
92
+ alias :__old_initialize__ :initialize
93
+ def initialize(*args)
94
+ trace("#{__FILE__}:#{__LINE__} #{args}")
95
+ __old_initialize__(*args)
96
+ @notes = YDIM::Html::Stub::Notes.new
97
+ end
98
+ def headers_in
99
+ trace("#{__FILE__}:#{__LINE__}")
100
+ headers = {}
101
+ if(@header)
102
+ @header.each { |key, vals| headers.store(key, vals.join(';')) }
103
+ end
104
+ headers
105
+ end
106
+ def uri
107
+ trace("#{__FILE__}:#{__LINE__} #{unparsed_uri}")
108
+ @uri || unparsed_uri
109
+ end
110
+ end
111
+ class HTTPResponse
112
+ attr_accessor :rawdata
113
+ alias :__old_send_header__ :send_header
114
+ def send_header(socket)
115
+ # trace("#{__FILE__}:#{__LINE__}")
116
+ reason_phrase = 'OK'
117
+ if(@rawdata)
118
+ _write_data(socket, status_line)
119
+ else
120
+ __old_send_header__(socket)
121
+ end
122
+ end
123
+ alias :__old_setup_header__ :setup_header
124
+ def setup_header()
125
+ # trace("#{__FILE__}:#{__LINE__}")
126
+ unless(@rawdata)
127
+ __old_setup_header__
128
+ end
129
+ end
130
+ end
131
+ end
132
+ module SBSM
133
+ class Request
134
+ def handle_exception(e)
135
+ trace("#{__FILE__}:#{__LINE__}")
136
+ raise e
137
+ end
138
+ end
139
+ module Apache
140
+ DECLINED = nil
141
+ def Apache.request=(request)
142
+ trace("#{__FILE__}:#{__LINE__} #{request}")
143
+ @request = request
144
+ end
145
+ def Apache.request
146
+ trace("#{__FILE__}:#{__LINE__}")
147
+ @request
148
+ end
149
+ end
150
+ end
151
+ class CGI
152
+ attr_accessor :output
153
+ def stdoutput
154
+ output
155
+ end
156
+ public :env_table
157
+ end
@@ -0,0 +1,1690 @@
1
+ #!/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ # Copyright 2006 ThoughtWorks, Inc
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ # -----------------
20
+ # Original code by Aslak Hellesoy and Darren Hobbs
21
+ # This file has been automatically generated via XSL
22
+ # -----------------
23
+
24
+ require 'net/http'
25
+ require 'uri'
26
+ require 'cgi'
27
+
28
+ # Defines an object that runs Selenium commands.
29
+ #
30
+ # ===Element Locators
31
+ # Element Locators tell Selenium which HTML element a command refers to.
32
+ # The format of a locator is:
33
+ # <em>locatorType</em><b>=</b><em>argument</em>
34
+ # We support the following strategies for locating elements:
35
+ #
36
+ # * <b>identifier</b>=<em>id</em>:
37
+ # Select the element with the specified @id attribute. If no match is
38
+ # found, select the first element whose @name attribute is <em>id</em>.
39
+ # (This is normally the default; see below.)
40
+ # * <b>id</b>=<em>id</em>:
41
+ # Select the element with the specified @id attribute.
42
+ # * <b>name</b>=<em>name</em>:
43
+ # Select the first element with the specified @name attribute.
44
+ # * username
45
+ # * name=username
46
+ #
47
+ # The name may optionally be followed by one or more <em>element-filters</em>, separated from the name by whitespace. If the <em>filterType</em> is not specified, <b>value</b> is assumed.
48
+ # * name=flavour value=chocolate
49
+ #
50
+ #
51
+ # * <b>dom</b>=<em>javascriptExpression</em>:
52
+ #
53
+ # Find an element by evaluating the specified string. This allows you to traverse the HTML Document Object
54
+ # Model using JavaScript. Note that you must not return a value in this string; simply make it the last expression in the block.
55
+ # * dom=document.forms['myForm'].myDropdown
56
+ # * dom=document.images[56]
57
+ # * dom=function foo() { return document.links[1]; }; foo();
58
+ #
59
+ #
60
+ # * <b>xpath</b>=<em>xpathExpression</em>:
61
+ # Locate an element using an XPath expression.
62
+ # * xpath=//img[@alt='The image alt text']
63
+ # * xpath=//table[@id='table1']//tr[4]/td[2]
64
+ # * xpath=//a[contains(@href,'#id1')]
65
+ # * xpath=//a[contains(@href,'#id1')]/@class
66
+ # * xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td
67
+ # * xpath=//input[@name='name2' and @value='yes']
68
+ # * xpath=//*[text()="right"]
69
+ #
70
+ #
71
+ # * <b>link</b>=<em>textPattern</em>:
72
+ # Select the link (anchor) element which contains text matching the
73
+ # specified <em>pattern</em>.
74
+ # * link=The link text
75
+ #
76
+ #
77
+ # * <b>css</b>=<em>cssSelectorSyntax</em>:
78
+ # Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors for more information. You can also check the TestCssLocators test in the selenium test suite for an example of usage, which is included in the downloaded selenium core package.
79
+ # * css=a[href="#id3"]
80
+ # * css=span#firstChild + span
81
+ #
82
+ # Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, :only-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after).
83
+ #
84
+ #
85
+ #
86
+ # Without an explicit locator prefix, Selenium uses the following default
87
+ # strategies:
88
+ #
89
+ # * <b>dom</b>, for locators starting with "document."
90
+ # * <b>xpath</b>, for locators starting with "//"
91
+ # * <b>identifier</b>, otherwise
92
+ #
93
+ # ===Element FiltersElement filters can be used with a locator to refine a list of candidate elements. They are currently used only in the 'name' element-locator.
94
+ # Filters look much like locators, ie.
95
+ # <em>filterType</em><b>=</b><em>argument</em>Supported element-filters are:
96
+ # <b>value=</b><em>valuePattern</em>
97
+ #
98
+ # Matches elements based on their values. This is particularly useful for refining a list of similarly-named toggle-buttons.<b>index=</b><em>index</em>
99
+ #
100
+ # Selects a single element based on its position in the list (offset from zero).===String-match Patterns
101
+ # Various Pattern syntaxes are available for matching string values:
102
+ #
103
+ # * <b>glob:</b><em>pattern</em>:
104
+ # Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a
105
+ # kind of limited regular-expression syntax typically used in command-line
106
+ # shells. In a glob pattern, "*" represents any sequence of characters, and "?"
107
+ # represents any single character. Glob patterns match against the entire
108
+ # string.
109
+ # * <b>regexp:</b><em>regexp</em>:
110
+ # Match a string using a regular-expression. The full power of JavaScript
111
+ # regular-expressions is available.
112
+ # * <b>regexpi:</b><em>regexpi</em>:
113
+ # Match a string using a case-insensitive regular-expression.
114
+ # * <b>exact:</b><em>string</em>:
115
+ #
116
+ # Match a string exactly, verbatim, without any of that fancy wildcard
117
+ # stuff.
118
+ #
119
+ #
120
+ # If no pattern prefix is specified, Selenium assumes that it's a "glob"
121
+ # pattern.
122
+ #
123
+ #
124
+ # For commands that return multiple values (such as verifySelectOptions),
125
+ # the string being matched is a comma-separated list of the return values,
126
+ # where both commas and backslashes in the values are backslash-escaped.
127
+ # When providing a pattern, the optional matching syntax (i.e. glob,
128
+ # regexp, etc.) is specified once, as usual, at the beginning of the
129
+ # pattern.
130
+ #
131
+ #
132
+ module Selenium
133
+
134
+ class SeleniumDriver
135
+ include Selenium
136
+
137
+ def initialize(server_host, server_port, browserStartCommand, browserURL, timeout=30000)
138
+ @server_host = server_host
139
+ @server_port = server_port
140
+ @browserStartCommand = browserStartCommand
141
+ @browserURL = browserURL
142
+ @timeout = timeout
143
+ end
144
+
145
+ def to_s
146
+ "SeleniumDriver"
147
+ end
148
+
149
+ def start()
150
+ result = get_string("getNewBrowserSession", [@browserStartCommand, @browserURL])
151
+ @session_id = result
152
+ end
153
+
154
+ def stop()
155
+ do_command("testComplete", [])
156
+ @session_id = nil
157
+ end
158
+
159
+ def do_command(verb, args)
160
+ Timeout.timeout(@timeout) do
161
+ http = Net::HTTP.new(@server_host, @server_port)
162
+ command_string = '/selenium-server/driver/?cmd=' + CGI::escape(verb)
163
+ args.length.times do |i|
164
+ arg_num = (i+1).to_s
165
+ command_string = command_string + "&" + arg_num + "=" + CGI::escape(args[i].to_s)
166
+ end
167
+ if @session_id != nil
168
+ command_string = command_string + "&sessionId=" + @session_id.to_s
169
+ end
170
+ #print "Requesting --->" + command_string + "\n"
171
+ response = http.get(command_string)
172
+ #print "RESULT: " + response.body + "\n\n"
173
+ if (response.body[0..1] != "OK")
174
+ require 'pry'; binding.pry
175
+ raise SeleniumCommandError, response.body
176
+ end
177
+ return response.body
178
+ end
179
+ end
180
+
181
+ def get_string(verb, args)
182
+ result = do_command(verb, args)
183
+ return result[3..result.length]
184
+ end
185
+
186
+ def get_string_array(verb, args)
187
+ csv = get_string(verb, args)
188
+ token = ""
189
+ tokens = []
190
+ escape = false
191
+ csv.split(//).each do |letter|
192
+ if escape
193
+ token = token + letter
194
+ escape = false
195
+ next
196
+ end
197
+ if (letter == '\\')
198
+ escape = true
199
+ elsif (letter == ',')
200
+ tokens.push(token)
201
+ token = ""
202
+ else
203
+ token = token + letter
204
+ end
205
+ end
206
+ tokens.push(token)
207
+ return tokens
208
+ end
209
+
210
+ def get_number(verb, args)
211
+ # Is there something I need to do here?
212
+ return get_string(verb, args)
213
+ end
214
+
215
+ def get_number_array(verb, args)
216
+ # Is there something I need to do here?
217
+ return get_string_array(verb, args)
218
+ end
219
+
220
+ def get_boolean(verb, args)
221
+ boolstr = get_string(verb, args)
222
+ if ("true" == boolstr)
223
+ return true
224
+ end
225
+ if ("false" == boolstr)
226
+ return false
227
+ end
228
+ raise ValueError, "result is neither 'true' nor 'false': " + boolstr
229
+ end
230
+
231
+ def get_boolean_array(verb, args)
232
+ boolarr = get_string_array(verb, args)
233
+ boolarr.length.times do |i|
234
+ if ("true" == boolstr)
235
+ boolarr[i] = true
236
+ next
237
+ end
238
+ if ("false" == boolstr)
239
+ boolarr[i] = false
240
+ next
241
+ end
242
+ raise ValueError, "result is neither 'true' nor 'false': " + boolarr[i]
243
+ end
244
+ return boolarr
245
+ end
246
+
247
+
248
+
249
+ # Clicks on a link, button, checkbox or radio button. If the click action
250
+ # causes a new page to load (like a link usually does), call
251
+ # waitForPageToLoad.
252
+ #
253
+ # 'locator' is an element locator
254
+ def click(locator)
255
+ do_command("click", [locator,])
256
+ end
257
+
258
+
259
+ # Double clicks on a link, button, checkbox or radio button. If the double click action
260
+ # causes a new page to load (like a link usually does), call
261
+ # waitForPageToLoad.
262
+ #
263
+ # 'locator' is an element locator
264
+ def double_click(locator)
265
+ do_command("doubleClick", [locator,])
266
+ end
267
+
268
+
269
+ # Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element).
270
+ #
271
+ # 'locator' is an element locator
272
+ def context_menu(locator)
273
+ do_command("contextMenu", [locator,])
274
+ end
275
+
276
+
277
+ # Clicks on a link, button, checkbox or radio button. If the click action
278
+ # causes a new page to load (like a link usually does), call
279
+ # waitForPageToLoad.
280
+ #
281
+ # 'locator' is an element locator
282
+ # 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
283
+ def click_at(locator,coordString)
284
+ do_command("clickAt", [locator,coordString,])
285
+ end
286
+
287
+
288
+ # Doubleclicks on a link, button, checkbox or radio button. If the action
289
+ # causes a new page to load (like a link usually does), call
290
+ # waitForPageToLoad.
291
+ #
292
+ # 'locator' is an element locator
293
+ # 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
294
+ def double_click_at(locator,coordString)
295
+ do_command("doubleClickAt", [locator,coordString,])
296
+ end
297
+
298
+
299
+ # Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element).
300
+ #
301
+ # 'locator' is an element locator
302
+ # 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
303
+ def context_menu_at(locator,coordString)
304
+ do_command("contextMenuAt", [locator,coordString,])
305
+ end
306
+
307
+
308
+ # Explicitly simulate an event, to trigger the corresponding "on<em>event</em>"
309
+ # handler.
310
+ #
311
+ # 'locator' is an element locator
312
+ # 'eventName' is the event name, e.g. "focus" or "blur"
313
+ def fire_event(locator,eventName)
314
+ do_command("fireEvent", [locator,eventName,])
315
+ end
316
+
317
+
318
+ # Move the focus to the specified element; for example, if the element is an input field, move the cursor to that field.
319
+ #
320
+ # 'locator' is an element locator
321
+ def focus(locator)
322
+ do_command("focus", [locator,])
323
+ end
324
+
325
+
326
+ # Simulates a user pressing and releasing a key.
327
+ #
328
+ # 'locator' is an element locator
329
+ # 'keySequence' is Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119".
330
+ def key_press(locator,keySequence)
331
+ do_command("keyPress", [locator,keySequence,])
332
+ end
333
+
334
+
335
+ # Press the shift key and hold it down until doShiftUp() is called or a new page is loaded.
336
+ #
337
+ def shift_key_down()
338
+ do_command("shiftKeyDown", [])
339
+ end
340
+
341
+
342
+ # Release the shift key.
343
+ #
344
+ def shift_key_up()
345
+ do_command("shiftKeyUp", [])
346
+ end
347
+
348
+
349
+ # Press the meta key and hold it down until doMetaUp() is called or a new page is loaded.
350
+ #
351
+ def meta_key_down()
352
+ do_command("metaKeyDown", [])
353
+ end
354
+
355
+
356
+ # Release the meta key.
357
+ #
358
+ def meta_key_up()
359
+ do_command("metaKeyUp", [])
360
+ end
361
+
362
+
363
+ # Press the alt key and hold it down until doAltUp() is called or a new page is loaded.
364
+ #
365
+ def alt_key_down()
366
+ do_command("altKeyDown", [])
367
+ end
368
+
369
+
370
+ # Release the alt key.
371
+ #
372
+ def alt_key_up()
373
+ do_command("altKeyUp", [])
374
+ end
375
+
376
+
377
+ # Press the control key and hold it down until doControlUp() is called or a new page is loaded.
378
+ #
379
+ def control_key_down()
380
+ do_command("controlKeyDown", [])
381
+ end
382
+
383
+
384
+ # Release the control key.
385
+ #
386
+ def control_key_up()
387
+ do_command("controlKeyUp", [])
388
+ end
389
+
390
+
391
+ # Simulates a user pressing a key (without releasing it yet).
392
+ #
393
+ # 'locator' is an element locator
394
+ # 'keySequence' is Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119".
395
+ def key_down(locator,keySequence)
396
+ do_command("keyDown", [locator,keySequence,])
397
+ end
398
+
399
+
400
+ # Simulates a user releasing a key.
401
+ #
402
+ # 'locator' is an element locator
403
+ # 'keySequence' is Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119".
404
+ def key_up(locator,keySequence)
405
+ do_command("keyUp", [locator,keySequence,])
406
+ end
407
+
408
+
409
+ # Simulates a user hovering a mouse over the specified element.
410
+ #
411
+ # 'locator' is an element locator
412
+ def mouse_over(locator)
413
+ do_command("mouseOver", [locator,])
414
+ end
415
+
416
+
417
+ # Simulates a user moving the mouse pointer away from the specified element.
418
+ #
419
+ # 'locator' is an element locator
420
+ def mouse_out(locator)
421
+ do_command("mouseOut", [locator,])
422
+ end
423
+
424
+
425
+ # Simulates a user pressing the mouse button (without releasing it yet) on
426
+ # the specified element.
427
+ #
428
+ # 'locator' is an element locator
429
+ def mouse_down(locator)
430
+ do_command("mouseDown", [locator,])
431
+ end
432
+
433
+
434
+ # Simulates a user pressing the mouse button (without releasing it yet) at
435
+ # the specified location.
436
+ #
437
+ # 'locator' is an element locator
438
+ # 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
439
+ def mouse_down_at(locator,coordString)
440
+ do_command("mouseDownAt", [locator,coordString,])
441
+ end
442
+
443
+
444
+ # Simulates the event that occurs when the user releases the mouse button (i.e., stops
445
+ # holding the button down) on the specified element.
446
+ #
447
+ # 'locator' is an element locator
448
+ def mouse_up(locator)
449
+ do_command("mouseUp", [locator,])
450
+ end
451
+
452
+
453
+ # Simulates the event that occurs when the user releases the mouse button (i.e., stops
454
+ # holding the button down) at the specified location.
455
+ #
456
+ # 'locator' is an element locator
457
+ # 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
458
+ def mouse_up_at(locator,coordString)
459
+ do_command("mouseUpAt", [locator,coordString,])
460
+ end
461
+
462
+
463
+ # Simulates a user pressing the mouse button (without releasing it yet) on
464
+ # the specified element.
465
+ #
466
+ # 'locator' is an element locator
467
+ def mouse_move(locator)
468
+ do_command("mouseMove", [locator,])
469
+ end
470
+
471
+
472
+ # Simulates a user pressing the mouse button (without releasing it yet) on
473
+ # the specified element.
474
+ #
475
+ # 'locator' is an element locator
476
+ # 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
477
+ def mouse_move_at(locator,coordString)
478
+ do_command("mouseMoveAt", [locator,coordString,])
479
+ end
480
+
481
+
482
+ # Sets the value of an input field, as though you typed it in.
483
+ #
484
+ # Can also be used to set the value of combo boxes, check boxes, etc. In these cases,
485
+ # value should be the value of the option selected, not the visible text.
486
+ #
487
+ #
488
+ # 'locator' is an element locator
489
+ # 'value' is the value to type
490
+ def type(locator,value)
491
+ do_command("type", [locator,value,])
492
+ end
493
+
494
+
495
+ # Simulates keystroke events on the specified element, as though you typed the value key-by-key.
496
+ #
497
+ # This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string;
498
+ # this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.
499
+ # Unlike the simple "type" command, which forces the specified value into the page directly, this command
500
+ # may or may not have any visible effect, even in cases where typing keys would normally have a visible effect.
501
+ # For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in
502
+ # the field.
503
+ # In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to
504
+ # send the keystroke events corresponding to what you just typed.
505
+ #
506
+ #
507
+ # 'locator' is an element locator
508
+ # 'value' is the value to type
509
+ def type_keys(locator,value)
510
+ do_command("typeKeys", [locator,value,])
511
+ end
512
+
513
+
514
+ # Set execution speed (i.e., set the millisecond length of a delay which will follow each selenium operation). By default, there is no such delay, i.e.,
515
+ # the delay is 0 milliseconds.
516
+ #
517
+ # 'value' is the number of milliseconds to pause after operation
518
+ def set_speed(value)
519
+ do_command("setSpeed", [value,])
520
+ end
521
+
522
+
523
+ # Get execution speed (i.e., get the millisecond length of the delay following each selenium operation). By default, there is no such delay, i.e.,
524
+ # the delay is 0 milliseconds.
525
+ #
526
+ # See also setSpeed.
527
+ #
528
+ def get_speed()
529
+ return get_string("getSpeed", [])
530
+ end
531
+
532
+
533
+ # Check a toggle-button (checkbox/radio)
534
+ #
535
+ # 'locator' is an element locator
536
+ def check(locator)
537
+ do_command("check", [locator,])
538
+ end
539
+
540
+
541
+ # Uncheck a toggle-button (checkbox/radio)
542
+ #
543
+ # 'locator' is an element locator
544
+ def uncheck(locator)
545
+ do_command("uncheck", [locator,])
546
+ end
547
+
548
+
549
+ # Select an option from a drop-down using an option locator.
550
+ #
551
+ #
552
+ # Option locators provide different ways of specifying options of an HTML
553
+ # Select element (e.g. for selecting a specific option, or for asserting
554
+ # that the selected option satisfies a specification). There are several
555
+ # forms of Select Option Locator.
556
+ #
557
+ # * <b>label</b>=<em>labelPattern</em>:
558
+ # matches options based on their labels, i.e. the visible text. (This
559
+ # is the default.)
560
+ # * label=regexp:^[Oo]ther
561
+ #
562
+ #
563
+ # * <b>value</b>=<em>valuePattern</em>:
564
+ # matches options based on their values.
565
+ # * value=other
566
+ #
567
+ #
568
+ # * <b>id</b>=<em>id</em>:
569
+ #
570
+ # matches options based on their ids.
571
+ # * id=option1
572
+ #
573
+ #
574
+ # * <b>index</b>=<em>index</em>:
575
+ # matches an option based on its index (offset from zero).
576
+ # * index=2
577
+ #
578
+ #
579
+ #
580
+ #
581
+ # If no option locator prefix is provided, the default behaviour is to match on <b>label</b>.
582
+ #
583
+ #
584
+ #
585
+ # 'selectLocator' is an element locator identifying a drop-down menu
586
+ # 'optionLocator' is an option locator (a label by default)
587
+ def select(selectLocator,optionLocator)
588
+ do_command("select", [selectLocator,optionLocator,])
589
+ end
590
+
591
+
592
+ # Add a selection to the set of selected options in a multi-select element using an option locator.
593
+ #
594
+ # @see #doSelect for details of option locators
595
+ #
596
+ # 'locator' is an element locator identifying a multi-select box
597
+ # 'optionLocator' is an option locator (a label by default)
598
+ def add_selection(locator,optionLocator)
599
+ do_command("addSelection", [locator,optionLocator,])
600
+ end
601
+
602
+
603
+ # Remove a selection from the set of selected options in a multi-select element using an option locator.
604
+ #
605
+ # @see #doSelect for details of option locators
606
+ #
607
+ # 'locator' is an element locator identifying a multi-select box
608
+ # 'optionLocator' is an option locator (a label by default)
609
+ def remove_selection(locator,optionLocator)
610
+ do_command("removeSelection", [locator,optionLocator,])
611
+ end
612
+
613
+
614
+ # Unselects all of the selected options in a multi-select element.
615
+ #
616
+ # 'locator' is an element locator identifying a multi-select box
617
+ def remove_all_selections(locator)
618
+ do_command("removeAllSelections", [locator,])
619
+ end
620
+
621
+
622
+ # Submit the specified form. This is particularly useful for forms without
623
+ # submit buttons, e.g. single-input "Search" forms.
624
+ #
625
+ # 'formLocator' is an element locator for the form you want to submit
626
+ def submit(formLocator)
627
+ do_command("submit", [formLocator,])
628
+ end
629
+
630
+
631
+ # Opens an URL in the test frame. This accepts both relative and absolute
632
+ # URLs.
633
+ #
634
+ # The "open" command waits for the page to load before proceeding,
635
+ # ie. the "AndWait" suffix is implicit.
636
+ #
637
+ # <em>Note</em>: The URL must be on the same domain as the runner HTML
638
+ # due to security restrictions in the browser (Same Origin Policy). If you
639
+ # need to open an URL on another domain, use the Selenium Server to start a
640
+ # new browser session on that domain.
641
+ #
642
+ # 'url' is the URL to open; may be relative or absolute
643
+ def open(url)
644
+ do_command("open", [url,])
645
+ end
646
+
647
+
648
+ # Opens a popup window (if a window with that ID isn't already open).
649
+ # After opening the window, you'll need to select it using the selectWindow
650
+ # command.
651
+ #
652
+ # This command can also be a useful workaround for bug SEL-339. In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example).
653
+ # In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
654
+ # an empty (blank) url, like this: openWindow("", "myFunnyWindow").
655
+ #
656
+ #
657
+ # 'url' is the URL to open, which can be blank
658
+ # 'windowID' is the JavaScript window ID of the window to select
659
+ def open_window(url,windowID)
660
+ do_command("openWindow", [url,windowID,])
661
+ end
662
+
663
+
664
+ # Selects a popup window using a window locator; once a popup window has been selected, all
665
+ # commands go to that window. To select the main window again, use null
666
+ # as the target.
667
+ #
668
+ #
669
+ #
670
+ # Window locators provide different ways of specifying the window object:
671
+ # by title, by internal JavaScript "name," or by JavaScript variable.
672
+ #
673
+ # * <b>title</b>=<em>My Special Window</em>:
674
+ # Finds the window using the text that appears in the title bar. Be careful;
675
+ # two windows can share the same title. If that happens, this locator will
676
+ # just pick one.
677
+ #
678
+ # * <b>name</b>=<em>myWindow</em>:
679
+ # Finds the window using its internal JavaScript "name" property. This is the second
680
+ # parameter "windowName" passed to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag)
681
+ # (which Selenium intercepts).
682
+ #
683
+ # * <b>var</b>=<em>variableName</em>:
684
+ # Some pop-up windows are unnamed (anonymous), but are associated with a JavaScript variable name in the current
685
+ # application window, e.g. "window.foo = window.open(url);". In those cases, you can open the window using
686
+ # "var=foo".
687
+ #
688
+ #
689
+ #
690
+ # If no window locator prefix is provided, we'll try to guess what you mean like this:
691
+ # 1.) if windowID is null, (or the string "null") then it is assumed the user is referring to the original window instantiated by the browser).
692
+ # 2.) if the value of the "windowID" parameter is a JavaScript variable name in the current application window, then it is assumed
693
+ # that this variable contains the return value from a call to the JavaScript window.open() method.
694
+ # 3.) Otherwise, selenium looks in a hash it maintains that maps string names to window "names".
695
+ # 4.) If <em>that</em> fails, we'll try looping over all of the known windows to try to find the appropriate "title".
696
+ # Since "title" is not necessarily unique, this may have unexpected behavior.
697
+ # If you're having trouble figuring out the name of a window that you want to manipulate, look at the Selenium log messages
698
+ # which identify the names of windows created via window.open (and therefore intercepted by Selenium). You will see messages
699
+ # like the following for each window as it is opened:
700
+ # <tt>debug: window.open call intercepted; window ID (which you can use with selectWindow()) is "myNewWindow"</tt>
701
+ # In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example).
702
+ # (This is bug SEL-339.) In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
703
+ # an empty (blank) url, like this: openWindow("", "myFunnyWindow").
704
+ #
705
+ #
706
+ # 'windowID' is the JavaScript window ID of the window to select
707
+ def select_window(windowID)
708
+ do_command("selectWindow", [windowID,])
709
+ end
710
+
711
+
712
+ # Selects a frame within the current window. (You may invoke this command
713
+ # multiple times to select nested frames.) To select the parent frame, use
714
+ # "relative=parent" as a locator; to select the top frame, use "relative=top".
715
+ # You can also select a frame by its 0-based index number; select the first frame with
716
+ # "index=0", or the third frame with "index=2".
717
+ #
718
+ # You may also use a DOM expression to identify the frame you want directly,
719
+ # like this: <tt>dom=frames["main"].frames["subframe"]</tt>
720
+ #
721
+ #
722
+ # 'locator' is an element locator identifying a frame or iframe
723
+ def select_frame(locator)
724
+ do_command("selectFrame", [locator,])
725
+ end
726
+
727
+
728
+ # Determine whether current/locator identify the frame containing this running code.
729
+ #
730
+ # This is useful in proxy injection mode, where this code runs in every
731
+ # browser frame and window, and sometimes the selenium server needs to identify
732
+ # the "current" frame. In this case, when the test calls selectFrame, this
733
+ # routine is called for each frame to figure out which one has been selected.
734
+ # The selected frame will return true, while all others will return false.
735
+ #
736
+ #
737
+ # 'currentFrameString' is starting frame
738
+ # 'target' is new frame (which might be relative to the current one)
739
+ def get_whether_this_frame_match_frame_expression(currentFrameString,target)
740
+ return get_boolean("getWhetherThisFrameMatchFrameExpression", [currentFrameString,target,])
741
+ end
742
+
743
+
744
+ # Determine whether currentWindowString plus target identify the window containing this running code.
745
+ #
746
+ # This is useful in proxy injection mode, where this code runs in every
747
+ # browser frame and window, and sometimes the selenium server needs to identify
748
+ # the "current" window. In this case, when the test calls selectWindow, this
749
+ # routine is called for each window to figure out which one has been selected.
750
+ # The selected window will return true, while all others will return false.
751
+ #
752
+ #
753
+ # 'currentWindowString' is starting window
754
+ # 'target' is new window (which might be relative to the current one, e.g., "_parent")
755
+ def get_whether_this_window_match_window_expression(currentWindowString,target)
756
+ return get_boolean("getWhetherThisWindowMatchWindowExpression", [currentWindowString,target,])
757
+ end
758
+
759
+
760
+ # Waits for a popup window to appear and load up.
761
+ #
762
+ # 'windowID' is the JavaScript window "name" of the window that will appear (not the text of the title bar)
763
+ # 'timeout' is a timeout in milliseconds, after which the action will return with an error
764
+ def wait_for_pop_up(windowID,timeout)
765
+ do_command("waitForPopUp", [windowID,timeout,])
766
+ end
767
+
768
+
769
+ # By default, Selenium's overridden window.confirm() function will
770
+ # return true, as if the user had manually clicked OK; after running
771
+ # this command, the next call to confirm() will return false, as if
772
+ # the user had clicked Cancel. Selenium will then resume using the
773
+ # default behavior for future confirmations, automatically returning
774
+ # true (OK) unless/until you explicitly call this command for each
775
+ # confirmation.
776
+ #
777
+ def choose_cancel_on_next_confirmation()
778
+ do_command("chooseCancelOnNextConfirmation", [])
779
+ end
780
+
781
+
782
+ # Undo the effect of calling chooseCancelOnNextConfirmation. Note
783
+ # that Selenium's overridden window.confirm() function will normally automatically
784
+ # return true, as if the user had manually clicked OK, so you shouldn't
785
+ # need to use this command unless for some reason you need to change
786
+ # your mind prior to the next confirmation. After any confirmation, Selenium will resume using the
787
+ # default behavior for future confirmations, automatically returning
788
+ # true (OK) unless/until you explicitly call chooseCancelOnNextConfirmation for each
789
+ # confirmation.
790
+ #
791
+ def choose_ok_on_next_confirmation()
792
+ do_command("chooseOkOnNextConfirmation", [])
793
+ end
794
+
795
+
796
+ # Instructs Selenium to return the specified answer string in response to
797
+ # the next JavaScript prompt [window.prompt()].
798
+ #
799
+ # 'answer' is the answer to give in response to the prompt pop-up
800
+ def answer_on_next_prompt(answer)
801
+ do_command("answerOnNextPrompt", [answer,])
802
+ end
803
+
804
+
805
+ # Simulates the user clicking the "back" button on their browser.
806
+ #
807
+ def go_back()
808
+ do_command("goBack", [])
809
+ end
810
+
811
+
812
+ # Simulates the user clicking the "Refresh" button on their browser.
813
+ #
814
+ def refresh()
815
+ do_command("refresh", [])
816
+ end
817
+
818
+
819
+ # Simulates the user clicking the "close" button in the titlebar of a popup
820
+ # window or tab.
821
+ #
822
+ def close()
823
+ do_command("close", [])
824
+ end
825
+
826
+
827
+ # Has an alert occurred?
828
+ #
829
+ #
830
+ # This function never throws an exception
831
+ #
832
+ #
833
+ #
834
+ def is_alert_present()
835
+ return get_boolean("isAlertPresent", [])
836
+ end
837
+
838
+
839
+ # Has a prompt occurred?
840
+ #
841
+ #
842
+ # This function never throws an exception
843
+ #
844
+ #
845
+ #
846
+ def is_prompt_present()
847
+ return get_boolean("isPromptPresent", [])
848
+ end
849
+
850
+
851
+ # Has confirm() been called?
852
+ #
853
+ #
854
+ # This function never throws an exception
855
+ #
856
+ #
857
+ #
858
+ def is_confirmation_present()
859
+ return get_boolean("isConfirmationPresent", [])
860
+ end
861
+
862
+
863
+ # Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
864
+ #
865
+ # Getting an alert has the same effect as manually clicking OK. If an
866
+ # alert is generated but you do not get/verify it, the next Selenium action
867
+ # will fail.
868
+ # NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert
869
+ # dialog.
870
+ # NOTE: Selenium does NOT support JavaScript alerts that are generated in a
871
+ # page's onload() event handler. In this case a visible dialog WILL be
872
+ # generated and Selenium will hang until someone manually clicks OK.
873
+ #
874
+ #
875
+ def get_alert()
876
+ return get_string("getAlert", [])
877
+ end
878
+
879
+
880
+ # Retrieves the message of a JavaScript confirmation dialog generated during
881
+ # the previous action.
882
+ #
883
+ #
884
+ # By default, the confirm function will return true, having the same effect
885
+ # as manually clicking OK. This can be changed by prior execution of the
886
+ # chooseCancelOnNextConfirmation command. If an confirmation is generated
887
+ # but you do not get/verify it, the next Selenium action will fail.
888
+ #
889
+ #
890
+ # NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible
891
+ # dialog.
892
+ #
893
+ #
894
+ # NOTE: Selenium does NOT support JavaScript confirmations that are
895
+ # generated in a page's onload() event handler. In this case a visible
896
+ # dialog WILL be generated and Selenium will hang until you manually click
897
+ # OK.
898
+ #
899
+ #
900
+ #
901
+ def get_confirmation()
902
+ return get_string("getConfirmation", [])
903
+ end
904
+
905
+
906
+ # Retrieves the message of a JavaScript question prompt dialog generated during
907
+ # the previous action.
908
+ #
909
+ # Successful handling of the prompt requires prior execution of the
910
+ # answerOnNextPrompt command. If a prompt is generated but you
911
+ # do not get/verify it, the next Selenium action will fail.
912
+ # NOTE: under Selenium, JavaScript prompts will NOT pop up a visible
913
+ # dialog.
914
+ # NOTE: Selenium does NOT support JavaScript prompts that are generated in a
915
+ # page's onload() event handler. In this case a visible dialog WILL be
916
+ # generated and Selenium will hang until someone manually clicks OK.
917
+ #
918
+ #
919
+ def get_prompt()
920
+ return get_string("getPrompt", [])
921
+ end
922
+
923
+
924
+ # Gets the absolute URL of the current page.
925
+ #
926
+ def get_location()
927
+ return get_string("getLocation", [])
928
+ end
929
+
930
+
931
+ # Gets the title of the current page.
932
+ #
933
+ def get_title()
934
+ return get_string("getTitle", [])
935
+ end
936
+
937
+
938
+ # Gets the entire text of the page.
939
+ #
940
+ def get_body_text()
941
+ return get_string("getBodyText", [])
942
+ end
943
+
944
+
945
+ # Gets the (whitespace-trimmed) value of an input field (or anything else with a value parameter).
946
+ # For checkbox/radio elements, the value will be "on" or "off" depending on
947
+ # whether the element is checked or not.
948
+ #
949
+ # 'locator' is an element locator
950
+ def get_value(locator)
951
+ return get_string("getValue", [locator,])
952
+ end
953
+
954
+
955
+ # Gets the text of an element. This works for any element that contains
956
+ # text. This command uses either the textContent (Mozilla-like browsers) or
957
+ # the innerText (IE-like browsers) of the element, which is the rendered
958
+ # text shown to the user.
959
+ #
960
+ # 'locator' is an element locator
961
+ def get_text(locator)
962
+ return get_string("getText", [locator,])
963
+ end
964
+
965
+
966
+ # Briefly changes the backgroundColor of the specified element yellow. Useful for debugging.
967
+ #
968
+ # 'locator' is an element locator
969
+ def highlight(locator)
970
+ do_command("highlight", [locator,])
971
+ end
972
+
973
+
974
+ # Gets the result of evaluating the specified JavaScript snippet. The snippet may
975
+ # have multiple lines, but only the result of the last line will be returned.
976
+ #
977
+ # Note that, by default, the snippet will run in the context of the "selenium"
978
+ # object itself, so <tt>this</tt> will refer to the Selenium object. Use <tt>window</tt> to
979
+ # refer to the window of your application, e.g. <tt>window.document.getElementById('foo')</tt>
980
+ # If you need to use
981
+ # a locator to refer to a single element in your application page, you can
982
+ # use <tt>this.browserbot.findElement("id=foo")</tt> where "id=foo" is your locator.
983
+ #
984
+ #
985
+ # 'script' is the JavaScript snippet to run
986
+ def get_eval(script)
987
+ return get_string("getEval", [script,])
988
+ end
989
+
990
+
991
+ # Gets whether a toggle-button (checkbox/radio) is checked. Fails if the specified element doesn't exist or isn't a toggle-button.
992
+ #
993
+ # 'locator' is an element locator pointing to a checkbox or radio button
994
+ def is_checked(locator)
995
+ return get_boolean("isChecked", [locator,])
996
+ end
997
+
998
+
999
+ # Gets the text from a cell of a table. The cellAddress syntax
1000
+ # tableLocator.row.column, where row and column start at 0.
1001
+ #
1002
+ # 'tableCellAddress' is a cell address, e.g. "foo.1.4"
1003
+ def get_table(tableCellAddress)
1004
+ return get_string("getTable", [tableCellAddress,])
1005
+ end
1006
+
1007
+
1008
+ # Gets all option labels (visible text) for selected options in the specified select or multi-select element.
1009
+ #
1010
+ # 'selectLocator' is an element locator identifying a drop-down menu
1011
+ def get_selected_labels(selectLocator)
1012
+ return get_string_array("getSelectedLabels", [selectLocator,])
1013
+ end
1014
+
1015
+
1016
+ # Gets option label (visible text) for selected option in the specified select element.
1017
+ #
1018
+ # 'selectLocator' is an element locator identifying a drop-down menu
1019
+ def get_selected_label(selectLocator)
1020
+ return get_string("getSelectedLabel", [selectLocator,])
1021
+ end
1022
+
1023
+
1024
+ # Gets all option values (value attributes) for selected options in the specified select or multi-select element.
1025
+ #
1026
+ # 'selectLocator' is an element locator identifying a drop-down menu
1027
+ def get_selected_values(selectLocator)
1028
+ return get_string_array("getSelectedValues", [selectLocator,])
1029
+ end
1030
+
1031
+
1032
+ # Gets option value (value attribute) for selected option in the specified select element.
1033
+ #
1034
+ # 'selectLocator' is an element locator identifying a drop-down menu
1035
+ def get_selected_value(selectLocator)
1036
+ return get_string("getSelectedValue", [selectLocator,])
1037
+ end
1038
+
1039
+
1040
+ # Gets all option indexes (option number, starting at 0) for selected options in the specified select or multi-select element.
1041
+ #
1042
+ # 'selectLocator' is an element locator identifying a drop-down menu
1043
+ def get_selected_indexes(selectLocator)
1044
+ return get_string_array("getSelectedIndexes", [selectLocator,])
1045
+ end
1046
+
1047
+
1048
+ # Gets option index (option number, starting at 0) for selected option in the specified select element.
1049
+ #
1050
+ # 'selectLocator' is an element locator identifying a drop-down menu
1051
+ def get_selected_index(selectLocator)
1052
+ return get_string("getSelectedIndex", [selectLocator,])
1053
+ end
1054
+
1055
+
1056
+ # Gets all option element IDs for selected options in the specified select or multi-select element.
1057
+ #
1058
+ # 'selectLocator' is an element locator identifying a drop-down menu
1059
+ def get_selected_ids(selectLocator)
1060
+ return get_string_array("getSelectedIds", [selectLocator,])
1061
+ end
1062
+
1063
+
1064
+ # Gets option element ID for selected option in the specified select element.
1065
+ #
1066
+ # 'selectLocator' is an element locator identifying a drop-down menu
1067
+ def get_selected_id(selectLocator)
1068
+ return get_string("getSelectedId", [selectLocator,])
1069
+ end
1070
+
1071
+
1072
+ # Determines whether some option in a drop-down menu is selected.
1073
+ #
1074
+ # 'selectLocator' is an element locator identifying a drop-down menu
1075
+ def is_something_selected(selectLocator)
1076
+ return get_boolean("isSomethingSelected", [selectLocator,])
1077
+ end
1078
+
1079
+
1080
+ # Gets all option labels in the specified select drop-down.
1081
+ #
1082
+ # 'selectLocator' is an element locator identifying a drop-down menu
1083
+ def get_select_options(selectLocator)
1084
+ return get_string_array("getSelectOptions", [selectLocator,])
1085
+ end
1086
+
1087
+
1088
+ # Gets the value of an element attribute. The value of the attribute may
1089
+ # differ across browsers (this is the case for the "style" attribute, for
1090
+ # example).
1091
+ #
1092
+ # 'attributeLocator' is an element locator followed by an @ sign and then the name of the attribute, e.g. "foo@bar"
1093
+ def get_attribute(attributeLocator)
1094
+ return get_string("getAttribute", [attributeLocator,])
1095
+ end
1096
+
1097
+
1098
+ # Verifies that the specified text pattern appears somewhere on the rendered page shown to the user.
1099
+ #
1100
+ # 'pattern' is a pattern to match with the text of the page
1101
+ def is_text_present(pattern)
1102
+ return get_boolean("isTextPresent", [pattern,])
1103
+ end
1104
+
1105
+
1106
+ # Verifies that the specified element is somewhere on the page.
1107
+ #
1108
+ # 'locator' is an element locator
1109
+ def is_element_present(locator)
1110
+ return get_boolean("isElementPresent", [locator,])
1111
+ end
1112
+
1113
+
1114
+ # Determines if the specified element is visible. An
1115
+ # element can be rendered invisible by setting the CSS "visibility"
1116
+ # property to "hidden", or the "display" property to "none", either for the
1117
+ # element itself or one if its ancestors. This method will fail if
1118
+ # the element is not present.
1119
+ #
1120
+ # 'locator' is an element locator
1121
+ def is_visible(locator)
1122
+ return get_boolean("isVisible", [locator,])
1123
+ end
1124
+
1125
+
1126
+ # Determines whether the specified input element is editable, ie hasn't been disabled.
1127
+ # This method will fail if the specified element isn't an input element.
1128
+ #
1129
+ # 'locator' is an element locator
1130
+ def is_editable(locator)
1131
+ return get_boolean("isEditable", [locator,])
1132
+ end
1133
+
1134
+
1135
+ # Returns the IDs of all buttons on the page.
1136
+ #
1137
+ # If a given button has no ID, it will appear as "" in this array.
1138
+ #
1139
+ #
1140
+ def get_all_buttons()
1141
+ return get_string_array("getAllButtons", [])
1142
+ end
1143
+
1144
+
1145
+ # Returns the IDs of all links on the page.
1146
+ #
1147
+ # If a given link has no ID, it will appear as "" in this array.
1148
+ #
1149
+ #
1150
+ def get_all_links()
1151
+ return get_string_array("getAllLinks", [])
1152
+ end
1153
+
1154
+
1155
+ # Returns the IDs of all input fields on the page.
1156
+ #
1157
+ # If a given field has no ID, it will appear as "" in this array.
1158
+ #
1159
+ #
1160
+ def get_all_fields()
1161
+ return get_string_array("getAllFields", [])
1162
+ end
1163
+
1164
+
1165
+ # Returns every instance of some attribute from all known windows.
1166
+ #
1167
+ # 'attributeName' is name of an attribute on the windows
1168
+ def get_attribute_from_all_windows(attributeName)
1169
+ return get_string_array("getAttributeFromAllWindows", [attributeName,])
1170
+ end
1171
+
1172
+
1173
+ # deprecated - use dragAndDrop instead
1174
+ #
1175
+ # 'locator' is an element locator
1176
+ # 'movementsString' is offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"
1177
+ def dragdrop(locator,movementsString)
1178
+ do_command("dragdrop", [locator,movementsString,])
1179
+ end
1180
+
1181
+
1182
+ # Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
1183
+ # Setting this value to 0 means that we'll send a "mousemove" event to every single pixel
1184
+ # in between the start location and the end location; that can be very slow, and may
1185
+ # cause some browsers to force the JavaScript to timeout.
1186
+ # If the mouse speed is greater than the distance between the two dragged objects, we'll
1187
+ # just send one "mousemove" at the start location and then one final one at the end location.
1188
+ #
1189
+ #
1190
+ # 'pixels' is the number of pixels between "mousemove" events
1191
+ def set_mouse_speed(pixels)
1192
+ do_command("setMouseSpeed", [pixels,])
1193
+ end
1194
+
1195
+
1196
+ # Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
1197
+ #
1198
+ def get_mouse_speed()
1199
+ return get_number("getMouseSpeed", [])
1200
+ end
1201
+
1202
+
1203
+ # Drags an element a certain distance and then drops it
1204
+ #
1205
+ # 'locator' is an element locator
1206
+ # 'movementsString' is offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"
1207
+ def drag_and_drop(locator,movementsString)
1208
+ do_command("dragAndDrop", [locator,movementsString,])
1209
+ end
1210
+
1211
+
1212
+ # Drags an element and drops it on another element
1213
+ #
1214
+ # 'locatorOfObjectToBeDragged' is an element to be dragged
1215
+ # 'locatorOfDragDestinationObject' is an element whose location (i.e., whose center-most pixel) will be the point where locatorOfObjectToBeDragged is dropped
1216
+ def drag_and_drop_to_object(locatorOfObjectToBeDragged,locatorOfDragDestinationObject)
1217
+ do_command("dragAndDropToObject", [locatorOfObjectToBeDragged,locatorOfDragDestinationObject,])
1218
+ end
1219
+
1220
+
1221
+ # Gives focus to the currently selected window
1222
+ #
1223
+ def window_focus()
1224
+ do_command("windowFocus", [])
1225
+ end
1226
+
1227
+
1228
+ # Resize currently selected window to take up the entire screen
1229
+ #
1230
+ def window_maximize()
1231
+ do_command("windowMaximize", [])
1232
+ end
1233
+
1234
+
1235
+ # Returns the IDs of all windows that the browser knows about.
1236
+ #
1237
+ def get_all_window_ids()
1238
+ return get_string_array("getAllWindowIds", [])
1239
+ end
1240
+
1241
+
1242
+ # Returns the names of all windows that the browser knows about.
1243
+ #
1244
+ def get_all_window_names()
1245
+ return get_string_array("getAllWindowNames", [])
1246
+ end
1247
+
1248
+
1249
+ # Returns the titles of all windows that the browser knows about.
1250
+ #
1251
+ def get_all_window_titles()
1252
+ return get_string_array("getAllWindowTitles", [])
1253
+ end
1254
+
1255
+
1256
+ # Returns the entire HTML source between the opening and
1257
+ # closing "html" tags.
1258
+ #
1259
+ def get_html_source()
1260
+ return get_string("getHtmlSource", [])
1261
+ end
1262
+
1263
+
1264
+ # Moves the text cursor to the specified position in the given input element or textarea.
1265
+ # This method will fail if the specified element isn't an input element or textarea.
1266
+ #
1267
+ # 'locator' is an element locator pointing to an input element or textarea
1268
+ # 'position' is the numerical position of the cursor in the field; position should be 0 to move the position to the beginning of the field. You can also set the cursor to -1 to move it to the end of the field.
1269
+ def set_cursor_position(locator,position)
1270
+ do_command("setCursorPosition", [locator,position,])
1271
+ end
1272
+
1273
+
1274
+ # Get the relative index of an element to its parent (starting from 0). The comment node and empty text node
1275
+ # will be ignored.
1276
+ #
1277
+ # 'locator' is an element locator pointing to an element
1278
+ def get_element_index(locator)
1279
+ return get_number("getElementIndex", [locator,])
1280
+ end
1281
+
1282
+
1283
+ # Check if these two elements have same parent and are ordered siblings in the DOM. Two same elements will
1284
+ # not be considered ordered.
1285
+ #
1286
+ # 'locator1' is an element locator pointing to the first element
1287
+ # 'locator2' is an element locator pointing to the second element
1288
+ def is_ordered(locator1,locator2)
1289
+ return get_boolean("isOrdered", [locator1,locator2,])
1290
+ end
1291
+
1292
+
1293
+ # Retrieves the horizontal position of an element
1294
+ #
1295
+ # 'locator' is an element locator pointing to an element OR an element itself
1296
+ def get_element_position_left(locator)
1297
+ return get_number("getElementPositionLeft", [locator,])
1298
+ end
1299
+
1300
+
1301
+ # Retrieves the vertical position of an element
1302
+ #
1303
+ # 'locator' is an element locator pointing to an element OR an element itself
1304
+ def get_element_position_top(locator)
1305
+ return get_number("getElementPositionTop", [locator,])
1306
+ end
1307
+
1308
+
1309
+ # Retrieves the width of an element
1310
+ #
1311
+ # 'locator' is an element locator pointing to an element
1312
+ def get_element_width(locator)
1313
+ return get_number("getElementWidth", [locator,])
1314
+ end
1315
+
1316
+
1317
+ # Retrieves the height of an element
1318
+ #
1319
+ # 'locator' is an element locator pointing to an element
1320
+ def get_element_height(locator)
1321
+ return get_number("getElementHeight", [locator,])
1322
+ end
1323
+
1324
+
1325
+ # Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
1326
+ #
1327
+ # Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to
1328
+ # return the position of the last location of the cursor, even though the cursor is now gone from the page. This is filed as SEL-243.
1329
+ #
1330
+ # This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.
1331
+ #
1332
+ # 'locator' is an element locator pointing to an input element or textarea
1333
+ def get_cursor_position(locator)
1334
+ return get_number("getCursorPosition", [locator,])
1335
+ end
1336
+
1337
+
1338
+ # Returns the specified expression.
1339
+ #
1340
+ # This is useful because of JavaScript preprocessing.
1341
+ # It is used to generate commands like assertExpression and waitForExpression.
1342
+ #
1343
+ #
1344
+ # 'expression' is the value to return
1345
+ def get_expression(expression)
1346
+ return get_string("getExpression", [expression,])
1347
+ end
1348
+
1349
+
1350
+ # Returns the number of nodes that match the specified xpath, eg. "//table" would give
1351
+ # the number of tables.
1352
+ #
1353
+ # 'xpath' is the xpath expression to evaluate. do NOT wrap this expression in a 'count()' function; we will do that for you.
1354
+ def get_xpath_count(xpath)
1355
+ return get_number("getXpathCount", [xpath,])
1356
+ end
1357
+
1358
+
1359
+ # Temporarily sets the "id" attribute of the specified element, so you can locate it in the future
1360
+ # using its ID rather than a slow/complicated XPath. This ID will disappear once the page is
1361
+ # reloaded.
1362
+ #
1363
+ # 'locator' is an element locator pointing to an element
1364
+ # 'identifier' is a string to be used as the ID of the specified element
1365
+ def assign_id(locator,identifier)
1366
+ do_command("assignId", [locator,identifier,])
1367
+ end
1368
+
1369
+
1370
+ # Specifies whether Selenium should use the native in-browser implementation
1371
+ # of XPath (if any native version is available); if you pass "false" to
1372
+ # this function, we will always use our pure-JavaScript xpath library.
1373
+ # Using the pure-JS xpath library can improve the consistency of xpath
1374
+ # element locators between different browser vendors, but the pure-JS
1375
+ # version is much slower than the native implementations.
1376
+ #
1377
+ # 'allow' is boolean, true means we'll prefer to use native XPath; false means we'll only use JS XPath
1378
+ def allow_native_xpath(allow)
1379
+ do_command("allowNativeXpath", [allow,])
1380
+ end
1381
+
1382
+
1383
+ # Specifies whether Selenium will ignore xpath attributes that have no
1384
+ # value, i.e. are the empty string, when using the non-native xpath
1385
+ # evaluation engine. You'd want to do this for performance reasons in IE.
1386
+ # However, this could break certain xpaths, for example an xpath that looks
1387
+ # for an attribute whose value is NOT the empty string.
1388
+ #
1389
+ # The hope is that such xpaths are relatively rare, but the user should
1390
+ # have the option of using them. Note that this only influences xpath
1391
+ # evaluation when using the ajaxslt engine (i.e. not "javascript-xpath").
1392
+ #
1393
+ # 'ignore' is boolean, true means we'll ignore attributes without value at the expense of xpath "correctness"; false means we'll sacrifice speed for correctness.
1394
+ def ignore_attributes_without_value(ignore)
1395
+ do_command("ignoreAttributesWithoutValue", [ignore,])
1396
+ end
1397
+
1398
+
1399
+ # Runs the specified JavaScript snippet repeatedly until it evaluates to "true".
1400
+ # The snippet may have multiple lines, but only the result of the last line
1401
+ # will be considered.
1402
+ #
1403
+ # Note that, by default, the snippet will be run in the runner's test window, not in the window
1404
+ # of your application. To get the window of your application, you can use
1405
+ # the JavaScript snippet <tt>selenium.browserbot.getCurrentWindow()</tt>, and then
1406
+ # run your JavaScript in there
1407
+ #
1408
+ #
1409
+ # 'script' is the JavaScript snippet to run
1410
+ # 'timeout' is a timeout in milliseconds, after which this command will return with an error
1411
+ def wait_for_condition(script,timeout)
1412
+ do_command("waitForCondition", [script,timeout,])
1413
+ end
1414
+
1415
+
1416
+ # Specifies the amount of time that Selenium will wait for actions to complete.
1417
+ #
1418
+ # Actions that require waiting include "open" and the "waitFor*" actions.
1419
+ #
1420
+ # The default timeout is 30 seconds.
1421
+ #
1422
+ # 'timeout' is a timeout in milliseconds, after which the action will return with an error
1423
+ def set_timeout(timeout)
1424
+ do_command("setTimeout", [timeout,])
1425
+ end
1426
+
1427
+
1428
+ # Waits for a new page to load.
1429
+ #
1430
+ # You can use this command instead of the "AndWait" suffixes, "clickAndWait", "selectAndWait", "typeAndWait" etc.
1431
+ # (which are only available in the JS API).
1432
+ # Selenium constantly keeps track of new pages loading, and sets a "newPageLoaded"
1433
+ # flag when it first notices a page load. Running any other Selenium command after
1434
+ # turns the flag to false. Hence, if you want to wait for a page to load, you must
1435
+ # wait immediately after a Selenium command that caused a page-load.
1436
+ #
1437
+ #
1438
+ # 'timeout' is a timeout in milliseconds, after which this command will return with an error
1439
+ def wait_for_page_to_load(timeout)
1440
+ do_command("waitForPageToLoad", [timeout,])
1441
+ end
1442
+
1443
+
1444
+ # Waits for a new frame to load.
1445
+ #
1446
+ # Selenium constantly keeps track of new pages and frames loading,
1447
+ # and sets a "newPageLoaded" flag when it first notices a page load.
1448
+ #
1449
+ #
1450
+ # See waitForPageToLoad for more information.
1451
+ #
1452
+ # 'frameAddress' is FrameAddress from the server side
1453
+ # 'timeout' is a timeout in milliseconds, after which this command will return with an error
1454
+ def wait_for_frame_to_load(frameAddress,timeout)
1455
+ do_command("waitForFrameToLoad", [frameAddress,timeout,])
1456
+ end
1457
+
1458
+
1459
+ # Return all cookies of the current page under test.
1460
+ #
1461
+ def get_cookie()
1462
+ return get_string("getCookie", [])
1463
+ end
1464
+
1465
+
1466
+ # Returns the value of the cookie with the specified name, or throws an error if the cookie is not present.
1467
+ #
1468
+ # 'name' is the name of the cookie
1469
+ def get_cookie_by_name(name)
1470
+ return get_string("getCookieByName", [name,])
1471
+ end
1472
+
1473
+
1474
+ # Returns true if a cookie with the specified name is present, or false otherwise.
1475
+ #
1476
+ # 'name' is the name of the cookie
1477
+ def is_cookie_present(name)
1478
+ return get_boolean("isCookiePresent", [name,])
1479
+ end
1480
+
1481
+
1482
+ # Create a new cookie whose path and domain are same with those of current page
1483
+ # under test, unless you specified a path for this cookie explicitly.
1484
+ #
1485
+ # 'nameValuePair' is name and value of the cookie in a format "name=value"
1486
+ # 'optionsString' is options for the cookie. Currently supported options include 'path', 'max_age' and 'domain'. 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.
1487
+ def create_cookie(nameValuePair,optionsString)
1488
+ do_command("createCookie", [nameValuePair,optionsString,])
1489
+ end
1490
+
1491
+
1492
+ # Delete a named cookie with specified path and domain. Be careful; to delete a cookie, you
1493
+ # need to delete it using the exact same path and domain that were used to create the cookie.
1494
+ # If the path is wrong, or the domain is wrong, the cookie simply won't be deleted. Also
1495
+ # note that specifying a domain that isn't a subset of the current domain will usually fail.
1496
+ #
1497
+ # Since there's no way to discover at runtime the original path and domain of a given cookie,
1498
+ # we've added an option called 'recurse' to try all sub-domains of the current domain with
1499
+ # all paths that are a subset of the current path. Beware; this option can be slow. In
1500
+ # big-O notation, it operates in O(n*m) time, where n is the number of dots in the domain
1501
+ # name and m is the number of slashes in the path.
1502
+ #
1503
+ # 'name' is the name of the cookie to be deleted
1504
+ # '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.
1505
+ def delete_cookie(name,optionsString)
1506
+ do_command("deleteCookie", [name,optionsString,])
1507
+ end
1508
+
1509
+
1510
+ # Calls deleteCookie with recurse=true on all cookies visible to the current page.
1511
+ # As noted on the documentation for deleteCookie, recurse=true can be much slower
1512
+ # than simply deleting the cookies using a known domain/path.
1513
+ #
1514
+ def delete_all_visible_cookies()
1515
+ do_command("deleteAllVisibleCookies", [])
1516
+ end
1517
+
1518
+
1519
+ # Sets the threshold for browser-side logging messages; log messages beneath this threshold will be discarded.
1520
+ # Valid logLevel strings are: "debug", "info", "warn", "error" or "off".
1521
+ # To see the browser logs, you need to
1522
+ # either show the log window in GUI mode, or enable browser-side logging in Selenium RC.
1523
+ #
1524
+ # 'logLevel' is one of the following: "debug", "info", "warn", "error" or "off"
1525
+ def set_browser_log_level(logLevel)
1526
+ do_command("setBrowserLogLevel", [logLevel,])
1527
+ end
1528
+
1529
+
1530
+ # Creates a new "script" tag in the body of the current test window, and
1531
+ # adds the specified text into the body of the command. Scripts run in
1532
+ # this way can often be debugged more easily than scripts executed using
1533
+ # Selenium's "getEval" command. Beware that JS exceptions thrown in these script
1534
+ # tags aren't managed by Selenium, so you should probably wrap your script
1535
+ # in try/catch blocks if there is any chance that the script will throw
1536
+ # an exception.
1537
+ #
1538
+ # 'script' is the JavaScript snippet to run
1539
+ def run_script(script)
1540
+ do_command("runScript", [script,])
1541
+ end
1542
+
1543
+
1544
+ # Defines a new function for Selenium to locate elements on the page.
1545
+ # For example,
1546
+ # if you define the strategy "foo", and someone runs click("foo=blah"), we'll
1547
+ # run your function, passing you the string "blah", and click on the element
1548
+ # that your function
1549
+ # returns, or throw an "Element not found" error if your function returns null.
1550
+ #
1551
+ # We'll pass three arguments to your function:
1552
+ # * locator: the string the user passed in
1553
+ # * inWindow: the currently selected window
1554
+ # * inDocument: the currently selected document
1555
+ #
1556
+ #
1557
+ # The function must return null if the element can't be found.
1558
+ #
1559
+ # 'strategyName' is the name of the strategy to define; this should use only letters [a-zA-Z] with no spaces or other punctuation.
1560
+ # 'functionDefinition' is a string defining the body of a function in JavaScript. For example: <tt>return inDocument.getElementById(locator);</tt>
1561
+ def add_location_strategy(strategyName,functionDefinition)
1562
+ do_command("addLocationStrategy", [strategyName,functionDefinition,])
1563
+ end
1564
+
1565
+
1566
+ # Saves the entire contents of the current window canvas to a PNG file.
1567
+ # Currently this only works in Mozilla and when running in chrome mode.
1568
+ # Contrast this with the captureScreenshot command, which captures the
1569
+ # contents of the OS viewport (i.e. whatever is currently being displayed
1570
+ # on the monitor), and is implemented in the RC only. Implementation
1571
+ # mostly borrowed from the Screengrab! Firefox extension. Please see
1572
+ # http://www.screengrab.org for details.
1573
+ #
1574
+ # 'filename' is the path to the file to persist the screenshot as. No filename extension will be appended by default. Directories will not be created if they do not exist, and an exception will be thrown, possibly by native code.
1575
+ def capture_entire_page_screenshot(filename)
1576
+ do_command("captureEntirePageScreenshot", [filename,])
1577
+ end
1578
+
1579
+
1580
+ # Writes a message to the status bar and adds a note to the browser-side
1581
+ # log.
1582
+ #
1583
+ # 'context' is the message to be sent to the browser
1584
+ def set_context(context)
1585
+ do_command("setContext", [context,])
1586
+ end
1587
+
1588
+
1589
+ # Sets a file input (upload) field to the file listed in fileLocator
1590
+ #
1591
+ # 'fieldLocator' is an element locator
1592
+ # 'fileLocator' is a URL pointing to the specified file. Before the file can be set in the input field (fieldLocator), Selenium RC may need to transfer the file to the local machine before attaching the file in a web page form. This is common in selenium grid configurations where the RC server driving the browser is not the same machine that started the test. Supported Browsers: Firefox ("*chrome") only.
1593
+ def attach_file(fieldLocator,fileLocator)
1594
+ do_command("attachFile", [fieldLocator,fileLocator,])
1595
+ end
1596
+
1597
+
1598
+ # Captures a PNG screenshot to the specified file.
1599
+ #
1600
+ # 'filename' is the absolute path to the file to be written, e.g. "c:\blah\screenshot.png"
1601
+ def capture_screenshot(filename)
1602
+ do_command("captureScreenshot", [filename,])
1603
+ end
1604
+
1605
+
1606
+ # Kills the running Selenium Server and all browser sessions. After you run this command, you will no longer be able to send
1607
+ # commands to the server; you can't remotely start the server once it has been stopped. Normally
1608
+ # you should prefer to run the "stop" command, which terminates the current browser session, rather than
1609
+ # shutting down the entire server.
1610
+ #
1611
+ def shut_down_selenium_server()
1612
+ do_command("shutDownSeleniumServer", [])
1613
+ end
1614
+
1615
+
1616
+ # Simulates a user pressing a key (without releasing it yet) by sending a native operating system keystroke.
1617
+ # This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
1618
+ # a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
1619
+ # metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular
1620
+ # element, focus on the element first before running this command.
1621
+ #
1622
+ # 'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!
1623
+ def key_down_native(keycode)
1624
+ do_command("keyDownNative", [keycode,])
1625
+ end
1626
+
1627
+
1628
+ # Simulates a user releasing a key by sending a native operating system keystroke.
1629
+ # This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
1630
+ # a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
1631
+ # metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular
1632
+ # element, focus on the element first before running this command.
1633
+ #
1634
+ # 'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!
1635
+ def key_up_native(keycode)
1636
+ do_command("keyUpNative", [keycode,])
1637
+ end
1638
+
1639
+
1640
+ # Simulates a user pressing and releasing a key by sending a native operating system keystroke.
1641
+ # This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
1642
+ # a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
1643
+ # metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular
1644
+ # element, focus on the element first before running this command.
1645
+ #
1646
+ # 'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!
1647
+ def key_press_native(keycode)
1648
+ do_command("keyPressNative", [keycode,])
1649
+ end
1650
+
1651
+
1652
+ end
1653
+
1654
+ SeleneseInterpreter = SeleniumDriver # for backward compatibility
1655
+
1656
+ end
1657
+
1658
+ class SeleniumCommandError < RuntimeError
1659
+ end
1660
+
1661
+ # Defines a mixin module that you can use to write Selenium tests
1662
+ # without typing "@selenium." in front of every command. Every
1663
+ # call to a missing method will be automatically sent to the @selenium
1664
+ # object.
1665
+ module SeleniumHelper
1666
+
1667
+ # Overrides standard "open" method with @selenium.open
1668
+ def open(addr)
1669
+ @selenium.open(addr)
1670
+ end
1671
+
1672
+ # Overrides standard "type" method with @selenium.type
1673
+ def type(inputLocator, value)
1674
+ @selenium.type(inputLocator, value)
1675
+ end
1676
+
1677
+ # Overrides standard "select" method with @selenium.select
1678
+ def select(inputLocator, optionLocator)
1679
+ @selenium.select(inputLocator, optionLocator)
1680
+ end
1681
+
1682
+ # Passes all calls to missing methods to @selenium
1683
+ def method_missing(method_name, *args)
1684
+ if args.empty?
1685
+ @selenium.send(method_name)
1686
+ else
1687
+ @selenium.send(method_name, *args)
1688
+ end
1689
+ end
1690
+ end