selenium-client 1.1 → 1.2

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