rainux-selenium-webdriver 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. data/COPYING +204 -0
  2. data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
  3. data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
  4. data/chrome/src/extension/background.html +9 -0
  5. data/chrome/src/extension/background.js +995 -0
  6. data/chrome/src/extension/content_script.js +1321 -0
  7. data/chrome/src/extension/icons/busy.png +0 -0
  8. data/chrome/src/extension/icons/free.png +0 -0
  9. data/chrome/src/extension/manifest-nonwin.json +19 -0
  10. data/chrome/src/extension/manifest-win.json +20 -0
  11. data/chrome/src/extension/utils.js +231 -0
  12. data/chrome/src/rb/lib/selenium/webdriver/chrome.rb +8 -0
  13. data/chrome/src/rb/lib/selenium/webdriver/chrome/bridge.rb +358 -0
  14. data/chrome/src/rb/lib/selenium/webdriver/chrome/command_executor.rb +124 -0
  15. data/chrome/src/rb/lib/selenium/webdriver/chrome/launcher.rb +135 -0
  16. data/common/src/js/abstractcommandprocessor.js +134 -0
  17. data/common/src/js/asserts.js +296 -0
  18. data/common/src/js/by.js +149 -0
  19. data/common/src/js/command.js +304 -0
  20. data/common/src/js/context.js +58 -0
  21. data/common/src/js/core/Blank.html +7 -0
  22. data/common/src/js/core/InjectedRemoteRunner.html +8 -0
  23. data/common/src/js/core/RemoteRunner.html +101 -0
  24. data/common/src/js/core/SeleniumLog.html +109 -0
  25. data/common/src/js/core/TestPrompt.html +145 -0
  26. data/common/src/js/core/TestRunner-splash.html +55 -0
  27. data/common/src/js/core/TestRunner.html +165 -0
  28. data/common/src/js/core/icons/all.png +0 -0
  29. data/common/src/js/core/icons/continue.png +0 -0
  30. data/common/src/js/core/icons/continue_disabled.png +0 -0
  31. data/common/src/js/core/icons/pause.png +0 -0
  32. data/common/src/js/core/icons/pause_disabled.png +0 -0
  33. data/common/src/js/core/icons/selected.png +0 -0
  34. data/common/src/js/core/icons/step.png +0 -0
  35. data/common/src/js/core/icons/step_disabled.png +0 -0
  36. data/common/src/js/core/lib/cssQuery/cssQuery-p.js +6 -0
  37. data/common/src/js/core/lib/cssQuery/src/cssQuery-level2.js +142 -0
  38. data/common/src/js/core/lib/cssQuery/src/cssQuery-level3.js +150 -0
  39. data/common/src/js/core/lib/cssQuery/src/cssQuery-standard.js +53 -0
  40. data/common/src/js/core/lib/cssQuery/src/cssQuery.js +356 -0
  41. data/common/src/js/core/lib/prototype.js +2006 -0
  42. data/common/src/js/core/lib/scriptaculous/builder.js +101 -0
  43. data/common/src/js/core/lib/scriptaculous/controls.js +815 -0
  44. data/common/src/js/core/lib/scriptaculous/dragdrop.js +915 -0
  45. data/common/src/js/core/lib/scriptaculous/effects.js +958 -0
  46. data/common/src/js/core/lib/scriptaculous/scriptaculous.js +47 -0
  47. data/common/src/js/core/lib/scriptaculous/slider.js +283 -0
  48. data/common/src/js/core/lib/scriptaculous/unittest.js +383 -0
  49. data/common/src/js/core/lib/snapsie.js +91 -0
  50. data/common/src/js/core/scripts/find_matching_child.js +69 -0
  51. data/common/src/js/core/scripts/htmlutils.js +8716 -0
  52. data/common/src/js/core/scripts/injection.html +72 -0
  53. data/common/src/js/core/scripts/selenium-api.js +3291 -0
  54. data/common/src/js/core/scripts/selenium-browserbot.js +2457 -0
  55. data/common/src/js/core/scripts/selenium-browserdetect.js +153 -0
  56. data/common/src/js/core/scripts/selenium-commandhandlers.js +379 -0
  57. data/common/src/js/core/scripts/selenium-executionloop.js +175 -0
  58. data/common/src/js/core/scripts/selenium-logging.js +148 -0
  59. data/common/src/js/core/scripts/selenium-remoterunner.js +695 -0
  60. data/common/src/js/core/scripts/selenium-testrunner.js +1362 -0
  61. data/common/src/js/core/scripts/selenium-version.js +5 -0
  62. data/common/src/js/core/scripts/ui-doc.html +808 -0
  63. data/common/src/js/core/scripts/ui-element.js +1644 -0
  64. data/common/src/js/core/scripts/ui-map-sample.js +979 -0
  65. data/common/src/js/core/scripts/user-extensions.js +3 -0
  66. data/common/src/js/core/scripts/user-extensions.js.sample +75 -0
  67. data/common/src/js/core/scripts/xmlextras.js +153 -0
  68. data/common/src/js/core/selenium-logo.png +0 -0
  69. data/common/src/js/core/selenium-test.css +43 -0
  70. data/common/src/js/core/selenium.css +316 -0
  71. data/common/src/js/core/xpath/dom.js +566 -0
  72. data/common/src/js/core/xpath/javascript-xpath-0.1.11.js +2816 -0
  73. data/common/src/js/core/xpath/util.js +549 -0
  74. data/common/src/js/core/xpath/xmltoken.js +149 -0
  75. data/common/src/js/core/xpath/xpath.js +2481 -0
  76. data/common/src/js/extension/README +2 -0
  77. data/common/src/js/extension/dommessenger.js +152 -0
  78. data/common/src/js/factory.js +55 -0
  79. data/common/src/js/future.js +141 -0
  80. data/common/src/js/jsunit.js +40 -0
  81. data/common/src/js/jsunit/app/css/jsUnitStyle.css +50 -0
  82. data/common/src/js/jsunit/app/css/readme +10 -0
  83. data/common/src/js/jsunit/app/emptyPage.html +11 -0
  84. data/common/src/js/jsunit/app/jsUnitCore.js +534 -0
  85. data/common/src/js/jsunit/app/jsUnitMockTimeout.js +81 -0
  86. data/common/src/js/jsunit/app/jsUnitTestManager.js +705 -0
  87. data/common/src/js/jsunit/app/jsUnitTestSuite.js +44 -0
  88. data/common/src/js/jsunit/app/jsUnitTracer.js +102 -0
  89. data/common/src/js/jsunit/app/jsUnitVersionCheck.js +59 -0
  90. data/common/src/js/jsunit/app/main-counts-errors.html +12 -0
  91. data/common/src/js/jsunit/app/main-counts-failures.html +13 -0
  92. data/common/src/js/jsunit/app/main-counts-runs.html +13 -0
  93. data/common/src/js/jsunit/app/main-counts.html +21 -0
  94. data/common/src/js/jsunit/app/main-data.html +178 -0
  95. data/common/src/js/jsunit/app/main-errors.html +23 -0
  96. data/common/src/js/jsunit/app/main-frame.html +19 -0
  97. data/common/src/js/jsunit/app/main-loader.html +45 -0
  98. data/common/src/js/jsunit/app/main-progress.html +25 -0
  99. data/common/src/js/jsunit/app/main-results.html +67 -0
  100. data/common/src/js/jsunit/app/main-status.html +13 -0
  101. data/common/src/js/jsunit/app/testContainer.html +16 -0
  102. data/common/src/js/jsunit/app/testContainerController.html +77 -0
  103. data/common/src/js/jsunit/app/xbDebug.js +306 -0
  104. data/common/src/js/jsunit/changelog.txt +60 -0
  105. data/common/src/js/jsunit/css/jsUnitStyle.css +83 -0
  106. data/common/src/js/jsunit/images/green.gif +0 -0
  107. data/common/src/js/jsunit/images/logo_jsunit.gif +0 -0
  108. data/common/src/js/jsunit/images/powerby-transparent.gif +0 -0
  109. data/common/src/js/jsunit/images/red.gif +0 -0
  110. data/common/src/js/jsunit/licenses/JDOM_license.txt +56 -0
  111. data/common/src/js/jsunit/licenses/Jetty_license.html +213 -0
  112. data/common/src/js/jsunit/licenses/MPL-1.1.txt +470 -0
  113. data/common/src/js/jsunit/licenses/gpl-2.txt +340 -0
  114. data/common/src/js/jsunit/licenses/index.html +141 -0
  115. data/common/src/js/jsunit/licenses/lgpl-2.1.txt +504 -0
  116. data/common/src/js/jsunit/licenses/mpl-tri-license-c.txt +35 -0
  117. data/common/src/js/jsunit/licenses/mpl-tri-license-html.txt +35 -0
  118. data/common/src/js/jsunit/readme.txt +19 -0
  119. data/common/src/js/jsunit/testRunner.html +167 -0
  120. data/common/src/js/jsunit/version.txt +1 -0
  121. data/common/src/js/key.js +117 -0
  122. data/common/src/js/localcommandprocessor.js +185 -0
  123. data/common/src/js/testcase.js +217 -0
  124. data/common/src/js/timing.js +89 -0
  125. data/common/src/js/webdriver.js +890 -0
  126. data/common/src/js/webelement.js +485 -0
  127. data/common/src/rb/README +30 -0
  128. data/common/src/rb/lib/selenium-webdriver.rb +1 -0
  129. data/common/src/rb/lib/selenium/webdriver.rb +67 -0
  130. data/common/src/rb/lib/selenium/webdriver/bridge_helper.rb +91 -0
  131. data/common/src/rb/lib/selenium/webdriver/child_process.rb +180 -0
  132. data/common/src/rb/lib/selenium/webdriver/core_ext/dir.rb +41 -0
  133. data/common/src/rb/lib/selenium/webdriver/driver.rb +252 -0
  134. data/common/src/rb/lib/selenium/webdriver/driver_extensions/takes_screenshot.rb +24 -0
  135. data/common/src/rb/lib/selenium/webdriver/element.rb +262 -0
  136. data/common/src/rb/lib/selenium/webdriver/error.rb +67 -0
  137. data/common/src/rb/lib/selenium/webdriver/find.rb +89 -0
  138. data/common/src/rb/lib/selenium/webdriver/keys.rb +84 -0
  139. data/common/src/rb/lib/selenium/webdriver/navigation.rb +27 -0
  140. data/common/src/rb/lib/selenium/webdriver/options.rb +50 -0
  141. data/common/src/rb/lib/selenium/webdriver/platform.rb +86 -0
  142. data/common/src/rb/lib/selenium/webdriver/target_locator.rb +70 -0
  143. data/firefox/prebuilt/Win32/Release/webdriver-firefox.dll +0 -0
  144. data/firefox/prebuilt/linux/Release/libwebdriver-firefox.so +0 -0
  145. data/firefox/prebuilt/linux/Release/x_ignore_nofocus.so +0 -0
  146. data/firefox/prebuilt/linux64/Release/libwebdriver-firefox.so +0 -0
  147. data/firefox/prebuilt/linux64/Release/x_ignore_nofocus.so +0 -0
  148. data/firefox/prebuilt/nsICommandProcessor.xpt +0 -0
  149. data/firefox/prebuilt/nsINativeEvents.xpt +0 -0
  150. data/firefox/prebuilt/nsIResponseHandler.xpt +0 -0
  151. data/firefox/src/extension/chrome.manifest +3 -0
  152. data/firefox/src/extension/components/badCertListener.js +294 -0
  153. data/firefox/src/extension/components/context.js +37 -0
  154. data/firefox/src/extension/components/driver-component.js +127 -0
  155. data/firefox/src/extension/components/firefoxDriver.js +810 -0
  156. data/firefox/src/extension/components/json2.js +273 -0
  157. data/firefox/src/extension/components/keytest.html +554 -0
  158. data/firefox/src/extension/components/nsCommandProcessor.js +643 -0
  159. data/firefox/src/extension/components/promptService.js +208 -0
  160. data/firefox/src/extension/components/screenshooter.js +81 -0
  161. data/firefox/src/extension/components/socketListener.js +185 -0
  162. data/firefox/src/extension/components/utils.js +1263 -0
  163. data/firefox/src/extension/components/webLoadingListener.js +57 -0
  164. data/firefox/src/extension/components/webdriverserver.js +106 -0
  165. data/firefox/src/extension/components/wrappedElement.js +683 -0
  166. data/firefox/src/extension/content/fxdriver.xul +30 -0
  167. data/firefox/src/extension/content/server.js +95 -0
  168. data/firefox/src/extension/idl/nsICommandProcessor.idl +38 -0
  169. data/firefox/src/extension/idl/nsIResponseHandler.idl +34 -0
  170. data/firefox/src/extension/install.rdf +29 -0
  171. data/firefox/src/rb/lib/selenium/webdriver/firefox.rb +31 -0
  172. data/firefox/src/rb/lib/selenium/webdriver/firefox/binary.rb +107 -0
  173. data/firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb +484 -0
  174. data/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb +90 -0
  175. data/firefox/src/rb/lib/selenium/webdriver/firefox/launcher.rb +155 -0
  176. data/firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb +233 -0
  177. data/firefox/src/rb/lib/selenium/webdriver/firefox/profiles_ini.rb +59 -0
  178. data/firefox/src/rb/lib/selenium/webdriver/firefox/util.rb +23 -0
  179. data/jobbie/prebuilt/Win32/Release/InternetExplorerDriver.dll +0 -0
  180. data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
  181. data/jobbie/src/rb/lib/selenium/webdriver/ie.rb +14 -0
  182. data/jobbie/src/rb/lib/selenium/webdriver/ie/bridge.rb +565 -0
  183. data/jobbie/src/rb/lib/selenium/webdriver/ie/lib.rb +99 -0
  184. data/jobbie/src/rb/lib/selenium/webdriver/ie/util.rb +147 -0
  185. data/remote/client/src/rb/lib/selenium/webdriver/remote.rb +16 -0
  186. data/remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb +408 -0
  187. data/remote/client/src/rb/lib/selenium/webdriver/remote/capabilities.rb +105 -0
  188. data/remote/client/src/rb/lib/selenium/webdriver/remote/commands.rb +53 -0
  189. data/remote/client/src/rb/lib/selenium/webdriver/remote/default_http_client.rb +71 -0
  190. data/remote/client/src/rb/lib/selenium/webdriver/remote/response.rb +49 -0
  191. data/remote/client/src/rb/lib/selenium/webdriver/remote/server_error.rb +32 -0
  192. metadata +303 -0
@@ -0,0 +1,485 @@
1
+ /** @license
2
+ Copyright 2007-2009 WebDriver committers
3
+ Copyright 2007-2009 Google Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+
18
+ /**
19
+ * @fileoverview A class for working with elements on the page under test.
20
+ * @author jmleyba@gmail.com (Jason Leyba)
21
+ */
22
+
23
+ goog.provide('webdriver.WebElement');
24
+
25
+ goog.require('goog.array');
26
+ goog.require('webdriver.By.Locator');
27
+ goog.require('webdriver.By.Strategy');
28
+ goog.require('webdriver.CommandName');
29
+ goog.require('webdriver.Future');
30
+
31
+
32
+ /**
33
+ * Represents a DOM element. WebElements can be found by searching from the
34
+ * document root using a {@code webdriver.WebDriver}, or by searhcing under
35
+ * another {@code webdriver.WebElement}:
36
+ *
37
+ * driver.get('http://www.google.com');
38
+ * var searchForm = driver.findElement({tagName: 'form'});
39
+ * var searchBox = searchForm.findElement({name: 'q'});
40
+ * searchBox.sendKeys('webdriver');
41
+ *
42
+ * @param {webdriver.WebDriver} driver The WebDriver instance that will
43
+ * actually execute commands.
44
+ * @constructor
45
+ */
46
+ webdriver.WebElement = function(driver) {
47
+
48
+ /**
49
+ * The WebDriver instance to issue commands to.
50
+ * @type {webdriver.WebDriver}
51
+ * @private
52
+ */
53
+ this.driver_ = driver;
54
+
55
+ /**
56
+ * The UUID used by WebDriver to identify this element on the page. The ID is
57
+ * wrapped in a webdriver.Future instance so it can be determined
58
+ * asynchronously.
59
+ * @type {webdriver.Future}
60
+ * @private
61
+ */
62
+ this.elementId_ = new webdriver.Future(this.driver_);
63
+ };
64
+
65
+
66
+ /**
67
+ * Adds a command to determine if an element is present under this element in
68
+ * the DOM tree.
69
+ * @param {webdriver.By.Locator|{*: string}} locator The locator to use for
70
+ * finding the element, or a short-hand object that can be converted into a
71
+ * locator.
72
+ * @return {webdriver.Future} A future whose value will be set when the driver
73
+ * completes the search; value will be {@code true} if the element was
74
+ * found, false otherwise.
75
+ * @see webdriver.By.Locator.createFromObj
76
+ */
77
+ webdriver.WebElement.prototype.isElementPresent = function(locator) {
78
+ locator = webdriver.By.Locator.checkLocator(locator);
79
+ return this.driver_.callFunction(function() {
80
+ var findCommand = this.driver_.
81
+ addCommand(webdriver.CommandName.FIND_CHILD_ELEMENT).
82
+ setParameters({
83
+ 'id': this.getId(),
84
+ 'using': locator.type,
85
+ 'value': locator.target
86
+ });
87
+ var commandFailed = false;
88
+ var key = goog.events.listenOnce(findCommand,
89
+ webdriver.Command.ERROR_EVENT, function(e) {
90
+ commandFailed = true;
91
+ this.driver_.abortCommand(e.currentTarget);
92
+ e.preventDefault();
93
+ e.stopPropagation();
94
+ return false;
95
+ }, /*capture phase*/true, this);
96
+ return this.driver_.callFunction(function() {
97
+ goog.events.unlistenByKey(key);
98
+ return !commandFailed;
99
+ });
100
+ }, this);
101
+ };
102
+
103
+
104
+ /**
105
+ * Adds a command to search for a single element on the page, restricting the
106
+ * search to the descendants of the element represented by this instance.
107
+ * @param {webdriver.By.Locator|{*: string}} locator The locator to use for
108
+ * finding the element, or a short-hand object that can be converted into a
109
+ * locator.
110
+ * @return {webdriver.WebElement} A WebElement that can be used to issue
111
+ * commands on the found element. The element's ID will be set
112
+ * asynchronously once the element is successfully located.
113
+ * @see webdriver.By.Locator.createFromObj
114
+ */
115
+ webdriver.WebElement.prototype.findElement = function(locator) {
116
+ var webElement = new webdriver.WebElement(this.driver_);
117
+ locator = webdriver.By.Locator.checkLocator(locator);
118
+ var command = this.driver_.
119
+ addCommand(webdriver.CommandName.FIND_CHILD_ELEMENT).
120
+ setParameters({
121
+ 'id': this.getId(),
122
+ 'using': locator.type,
123
+ 'value': locator.target
124
+ });
125
+ webElement.getId().setValue(command.getFutureResult());
126
+ return webElement;
127
+ };
128
+
129
+
130
+ /**
131
+ * Adds a command to search for multiple elements on the page, restricting the
132
+ * search to the descendants of hte element represented by this instance.
133
+ * @param {webdriver.By.Locator|{*: string}} locator The locator to use for
134
+ * finding the element, or a short-hand object that can be converted into a
135
+ * locator.
136
+ * @see webdriver.By.Locator.createFromObj
137
+ */
138
+ webdriver.WebElement.prototype.findElements = function(locator) {
139
+ locator = webdriver.By.Locator.checkLocator(locator);
140
+ this.driver_.callFunction(function() {
141
+ this.driver_.addCommand(webdriver.CommandName.FIND_CHILD_ELEMENTS).
142
+ setParameters({
143
+ 'id': this.getId(),
144
+ 'using': locator.type,
145
+ 'value': locator.target
146
+ });
147
+ return this.driver_.callFunction(function(ids) {
148
+ var elements = [];
149
+ for (var i = 0; i < ids.length; i++) {
150
+ if (ids[i]) {
151
+ var element = new webdriver.WebElement(this.driver_);
152
+ element.getId().setValue(ids[i]);
153
+ elements.push(element);
154
+ }
155
+ }
156
+ return elements;
157
+ }, this);
158
+ }, this);
159
+ };
160
+
161
+
162
+ /**
163
+ * @return {webdriver.WebDriver} The driver that this element delegates commands
164
+ * to.
165
+ */
166
+ webdriver.WebElement.prototype.getDriver = function() {
167
+ return this.driver_;
168
+ };
169
+
170
+
171
+ /**
172
+ * @return {webdriver.Futur} The UUID of this element wrapped in a Future.
173
+ */
174
+ webdriver.WebElement.prototype.getId = function() {
175
+ return this.elementId_;
176
+ };
177
+
178
+
179
+ /**
180
+ * Creates a new {@code webdriver.Command} against the element represented by
181
+ * this instance.
182
+ * @param {string} name The name of the command to create.
183
+ * @return {webdriver.Command} The new command.
184
+ * @private
185
+ */
186
+ webdriver.WebElement.prototype.createCommand_ = function(name) {
187
+ return this.driver_.addCommand(name, this);
188
+ };
189
+
190
+
191
+ /**
192
+ * Adds a command to click on this element.
193
+ */
194
+ webdriver.WebElement.prototype.click = function() {
195
+ this.createCommand_(webdriver.CommandName.CLICK);
196
+ };
197
+
198
+
199
+ /**
200
+ * Types a sequence on the DOM element represented by this instance.
201
+ * <p/>
202
+ * Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is
203
+ * processed in the keysequence, that key state is toggled until one of the
204
+ * following occurs:
205
+ * <ul>
206
+ * <li>The modifier key is encountered again in the sequence. At this point the
207
+ * state of the key is toggled (along with the appropriate keyup/down events).
208
+ * </li>
209
+ * <li>The {@code webdriver.Key.NULL} key is encountered in the sequence. When
210
+ * this key is encountered, all modifier keys current in the down state are
211
+ * released (with accompanying keyup events). The NULL key can be used to
212
+ * simulate common keyboard shortcuts:
213
+ * <code>
214
+ * element.sendKeys("text was",
215
+ * webdriver.Key.CONTROL, "a", webdriver.Key.NULL,
216
+ * "now text is");
217
+ * // Alternatively:
218
+ * element.sendKeys("text was",
219
+ * webdriver.Key.chord(webdriver.Key.CONTROL, "a"),
220
+ * "now text is");
221
+ * </code></li>
222
+ * <li>The end of the keysequence is encountered. When there are no more keys
223
+ * to type, all depressed modifier keys are released (with accompanying keyup
224
+ * events).
225
+ * </li>
226
+ * </ul>
227
+ * If a certain character can only be generated by using the shift key, such as
228
+ * uppercase characters or certain punctuation marks, the shift key will be
229
+ * applied for that individual key. If the shift key was not depressed before
230
+ * typing that key, it will be released after typing the key. If the shift key
231
+ * was already depressed, the extra event will not be generated. For example:
232
+ * <code>
233
+ * // Expect shift down/up for each character.
234
+ * element.sendKeys("ABC");
235
+ * // Shift is already depressed, so it will not be pushed again for each
236
+ * // character.
237
+ * element.sendKeys(webdriver.Key.SHIFT, "ABC");
238
+ * </code>
239
+ * <p/>
240
+ * <strong>Note:</strong> On browsers where native keyboard events are not yet
241
+ * supported (e.g. Firefox on OS X), key events will be synthesized. Special
242
+ * punctionation keys will be synthesized according to a standard QWERTY English
243
+ * keyboard layout.
244
+ * @param {string|webdriver.Future} var_args The strings to type. All arguments
245
+ * will be joined into a single sequence (var_args is permitted for
246
+ * convenience).
247
+ */
248
+ webdriver.WebElement.prototype.sendKeys = function(var_args) {
249
+ var command = this.createCommand_(webdriver.CommandName.SEND_KEYS);
250
+ command.setParameters.apply(command, arguments);
251
+ };
252
+
253
+ /**
254
+ * Queries for the tag/node name of this element.
255
+ */
256
+ webdriver.WebElement.prototype.getTagName = function() {
257
+ return this.createCommand_(webdriver.CommandName.GET_TAG_NAME).
258
+ getFutureResult();
259
+ };
260
+
261
+
262
+ /**
263
+ * Queries for the computed style of the element represented by this instance.
264
+ * If the element inherits the named style from its parent, the parent will be
265
+ * queried for its value. Where possible, color values will be converted to
266
+ * their hex representation (#00ff00 instead of rgb(0, 255, 0)).
267
+ * <em>Warning:</em> the value returned will be as the browser interprets it, so
268
+ * it may be tricky to form a proper assertion.
269
+ * @param {string} cssStyleProperty The name of the CSS style property to look
270
+ * up.
271
+ * @return {webdriver.Future<string>} The computed style property wrapped in a
272
+ * Future.
273
+ */
274
+ webdriver.WebElement.prototype.getComputedStyle = function(cssStyleProperty) {
275
+ return this.createCommand_(webdriver.CommandName.GET_VALUE_OF_CSS_PROPERTY).
276
+ setParameters(cssStyleProperty).
277
+ getFutureResult();
278
+ };
279
+
280
+
281
+ /**
282
+ * Queries for the specified attribute.
283
+ * @param {string} attributeName The name of the attribute to query.
284
+ */
285
+ webdriver.WebElement.prototype.getAttribute = function(attributeName) {
286
+ return this.createCommand_(webdriver.CommandName.GET_ATTRIBUTE).
287
+ setParameters(attributeName).
288
+ getFutureResult();
289
+ };
290
+
291
+
292
+ /**
293
+ * @return {webdriver.Future} The value attribute for the element represented by
294
+ * this instance.
295
+ */
296
+ webdriver.WebElement.prototype.getValue = function() {
297
+ return this.createCommand_(webdriver.CommandName.GET_VALUE).
298
+ getFutureResult();
299
+ };
300
+
301
+
302
+ /**
303
+ * @return {webdriver.Future} The innerText of this element, without any leading
304
+ * or trailing whitespace.
305
+ */
306
+ webdriver.WebElement.prototype.getText = function() {
307
+ return this.createCommand_(webdriver.CommandName.GET_TEXT).
308
+ getFutureResult();
309
+ };
310
+
311
+
312
+ /**
313
+ * Selects this element.
314
+ */
315
+ webdriver.WebElement.prototype.setSelected = function() {
316
+ this.createCommand_(webdriver.CommandName.SET_SELECTED);
317
+ };
318
+
319
+
320
+ /**
321
+ * @return {webdriver.Future} The size of this element.
322
+ */
323
+ webdriver.WebElement.prototype.getSize = function() {
324
+ return this.createCommand_(webdriver.CommandName.GET_SIZE).
325
+ getFutureResult();
326
+ };
327
+
328
+
329
+ /**
330
+ * @return {webdriver.Future} The location of this element.
331
+ */
332
+ webdriver.WebElement.prototype.getLocation = function() {
333
+ return this.createCommand_(webdriver.CommandName.GET_LOCATION).
334
+ getFutureResult();
335
+ };
336
+
337
+
338
+ /**
339
+ * Drags this element by the given offset.
340
+ * @param {number} x The horizontal amount, in pixels, to drag this element.
341
+ * @param {number} y The vertical amount, in pixels, to drag this element.
342
+ * @return {webdriver.Future} The new location of the element.
343
+ */
344
+ webdriver.WebElement.prototype.dragAndDropBy = function(x, y) {
345
+ return this.createCommand_(webdriver.CommandName.DRAG_ELEMENT).
346
+ setParameters(x, y).
347
+ getFutureResult();
348
+ };
349
+
350
+
351
+ /**
352
+ * Drags this element to the location of another {@code webElement}. After this
353
+ * command executes, this element's upper-left hand corner should be the same
354
+ * location as the upper-left hand corner of the given {@code webElement}.
355
+ * @param {webdriver.WebElement} webElement The element to drag this element to.
356
+ * @return {webdriver.Future} This element's new location.
357
+ */
358
+ webdriver.WebElement.prototype.dragAndDropTo = function(webElement) {
359
+ if (this.driver_ != webElement.driver_) {
360
+ throw new Error(
361
+ 'WebElements created by different drivers cannot coordinate');
362
+ }
363
+
364
+ var toLocation = webElement.getLocation();
365
+ var thisLocation = this.getLocation();
366
+ return this.driver_.callFunction(function() {
367
+ var delta = goog.math.Coordinate.difference(
368
+ toLocation.getValue(), thisLocation.getValue());
369
+ return this.dragAndDropBy(delta.x, delta.y);
370
+ }, this);
371
+ };
372
+
373
+
374
+ /**
375
+ * @return {boolean} Whether the DOM element represented by this instance is
376
+ * enabled, as dictated by the {@code disabled} attribute.
377
+ */
378
+ webdriver.WebElement.prototype.isEnabled = function() {
379
+ return this.driver_.callFunction(function() {
380
+ this.getAttribute('disabled');
381
+ return this.driver_.callFunction(function(value) {
382
+ return !!!value;
383
+ });
384
+ }, this);
385
+ };
386
+
387
+
388
+ /**
389
+ * Determines if this element is checked or selected; will generate an error if
390
+ * the DOM element represented by this instance is not an OPTION or checkbox
391
+ * INPUT element.
392
+ * @return {webdriver.Future} Whether this element is checked or selected.
393
+ * @private
394
+ */
395
+ webdriver.WebElement.prototype.isCheckedOrSelected_ = function() {
396
+ return this.driver_.callFunction(function() {
397
+ this.createCommand_(webdriver.CommandName.GET_TAG_NAME);
398
+ return this.driver_.callFunction(function(prevResult) {
399
+ var attribute = prevResult == 'input' ? 'checked' : 'selected';
400
+ return this.getAttribute(attribute);
401
+ }, this);
402
+ }, this);
403
+ };
404
+
405
+
406
+ /**
407
+ * @return {webdriver.Future} Whether this element is selected.
408
+ */
409
+ webdriver.WebElement.prototype.isSelected = function() {
410
+ return this.isCheckedOrSelected_();
411
+ };
412
+
413
+
414
+ /**
415
+ * @return {webdriver.Future} Whether this element is checked.
416
+ */
417
+ webdriver.WebElement.prototype.isChecked = function() {
418
+ return this.isCheckedOrSelected_();
419
+ };
420
+
421
+
422
+ /**
423
+ * Toggles the checked/selected state of this element; will generate an error if
424
+ * the DOM element represented by this instance is not an OPTION or checkbox
425
+ * input element.
426
+ * @return {webdriver.Future} The new checked/selected state of this element.
427
+ */
428
+ webdriver.WebElement.prototype.toggle = function() {
429
+ return this.driver_.callFunction(function() {
430
+ this.createCommand_(webdriver.CommandName.TOGGLE);
431
+ return this.isCheckedOrSelected_();
432
+ }, this);
433
+ };
434
+
435
+
436
+ /**
437
+ * If this current element is a form, or an element within a form, then this
438
+ * will that form.
439
+ */
440
+ webdriver.WebElement.prototype.submit = function() {
441
+ this.createCommand_(webdriver.CommandName.SUBMIT);
442
+ };
443
+
444
+
445
+ /**
446
+ * If this instance represents a text INPUT element, or a TEXTAREA element, this
447
+ * will clear its {@code value}.
448
+ */
449
+ webdriver.WebElement.prototype.clear = function() {
450
+ this.createCommand_(webdriver.CommandName.CLEAR);
451
+ };
452
+
453
+
454
+ /**
455
+ * @return {webdriver.Future} Whether this element is currently displayed.
456
+ */
457
+ webdriver.WebElement.prototype.isDisplayed = function() {
458
+ return this.createCommand_(webdriver.CommandName.IS_DISPLAYED).
459
+ getFutureResult();
460
+ };
461
+
462
+
463
+ /**
464
+ * @return {webdriver.Future} The outer HTML of this element.
465
+ */
466
+ webdriver.WebElement.prototype.getOuterHtml = function() {
467
+ return this.driver_.executeScript(
468
+ ['var element = arguments[0];',
469
+ 'if ("outerHTML" in element) {',
470
+ ' return element.outerHTML;',
471
+ '} else {',
472
+ ' var div = document.createElement("div");',
473
+ ' div.appendChild(element.cloneNode(true));',
474
+ ' return div.innerHTML;',
475
+ '}'].join(''), this);
476
+ };
477
+
478
+
479
+ /**
480
+ * @return {webdriver.Future} The inner HTML of this element.
481
+ */
482
+ webdriver.WebElement.prototype.getInnerHtml = function() {
483
+ return this.driver_.executeScript('return arguments[0].innerHTML', this);
484
+ };
485
+