selenium-webdriver 2.53.4 → 3.0.0.beta1

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