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,149 @@
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 Factory methods for the supported locator strategies.
20
+ * @author jmleyba@gmail.com (Jason Leyba)
21
+ */
22
+
23
+ goog.provide('webdriver.By');
24
+ goog.provide('webdriver.By.Locator');
25
+ goog.provide('webdriver.By.Strategy');
26
+
27
+ goog.require('goog.object');
28
+ goog.require('goog.string');
29
+
30
+
31
+
32
+ /**
33
+ * An element locator.
34
+ * @param {webdriver.By.Strategy} type The type of strategy to use for this
35
+ * locator.
36
+ * @param {string} target The target of this locator.
37
+ * @constructor
38
+ */
39
+ webdriver.By.Locator = function(type, target) {
40
+ this.type = type;
41
+ this.target = target;
42
+ };
43
+
44
+
45
+ /**
46
+ * Creates a new Locator from an object whose only property is also a key in
47
+ * the {@code webdriver.By.Strategy} enumeration. This property will be the
48
+ * locator type; its value will be the locator target.
49
+ * @param {{*: string}} obj The object to convert into a Locator.
50
+ * @return {webdriver.By.Locator} The new locator object.
51
+ * @throws If {@code obj} could not be converted.
52
+ */
53
+ webdriver.By.Locator.createFromObj = function(obj) {
54
+ var key = goog.object.getAnyKey(obj);
55
+ if (key && key in webdriver.By.Strategy) {
56
+ return new webdriver.By.Locator(webdriver.By.Strategy[key], obj[key]);
57
+ }
58
+ throw new Error('Unsupported locator strategy: ' + key);
59
+ };
60
+
61
+
62
+ /**
63
+ * Verifies that a {@code locator} is a valid locator to use for searching for
64
+ * elements on the page.
65
+ * @param {webdriver.By.Locator|{*: string}} locator The locator to verify, or
66
+ * a short-hand object that can be converted into a locator to verify.
67
+ * @return {webdriver.By.Locator} The validated locator.
68
+ * @throws If the {@code locator} is not valid.
69
+ */
70
+ webdriver.By.Locator.checkLocator = function(locator) {
71
+ if (!locator.type || !locator.target) {
72
+ locator = webdriver.By.Locator.createFromObj(locator);
73
+ }
74
+
75
+ if (locator.type == webdriver.By.Strategy.className) {
76
+ var normalized = goog.string.normalizeWhitespace(locator.target);
77
+ locator.target = goog.string.trim(normalized);
78
+ if (locator.target.search(/\s/) >= 0) {
79
+ throw new Error('Compound class names are not allowed for searches: ' +
80
+ goog.string.quote(locator.target));
81
+ }
82
+ }
83
+
84
+ return locator;
85
+ };
86
+
87
+
88
+ /**
89
+ * Enumeration of the supported strategies for finding {@code Element}s on the
90
+ * page. For all strategies, if there is more than one possible match, the
91
+ * first element encountered will be returned.
92
+ * @enum {string}
93
+ */
94
+ webdriver.By.Strategy = {
95
+
96
+ /**
97
+ * Find an element by its ID.
98
+ */
99
+ id: 'id',
100
+
101
+ /**
102
+ * Find an element by the value of its name attribute.
103
+ */
104
+ name: 'name',
105
+
106
+ /**
107
+ * Find an element by one of its class names. Only one class name may be
108
+ * specified per search.
109
+ */
110
+ className: 'class name',
111
+
112
+ /**
113
+ * Find an A tag by its text context.
114
+ */
115
+ linkText: 'link text',
116
+
117
+ /**
118
+ * Find an A tag by partially matching its text context.
119
+ */
120
+ partialLinkText: 'partial link text',
121
+
122
+ /**
123
+ * Find an element by its tagName property.
124
+ */
125
+ tagName: 'tag name',
126
+
127
+ /**
128
+ * Find an element by evaluating an XPath expression.
129
+ */
130
+ xpath: 'xpath',
131
+
132
+ /**
133
+ * Find an element by evaluating a javascript expression.
134
+ */
135
+ js: 'js'
136
+ };
137
+
138
+
139
+ /**
140
+ * Map each of the supported strategies to a factory function in the
141
+ * {@code webdriver.By} namespace.
142
+ */
143
+ goog.object.forEach(webdriver.By.Strategy, function(name, key) {
144
+ webdriver.By[key] = function(target) {
145
+ return new webdriver.By.Locator(name, target);
146
+ };
147
+ });
148
+
149
+ goog.exportSymbol('By', webdriver.By);
@@ -0,0 +1,304 @@
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 Contains several classes for handling commands.
20
+ * @author jmleyba@gmail.com (Jason Leyba)
21
+ */
22
+
23
+ goog.provide('webdriver.Command');
24
+ goog.provide('webdriver.CommandName');
25
+ goog.provide('webdriver.Response');
26
+
27
+ goog.require('goog.array');
28
+ goog.require('goog.events.EventTarget');
29
+ goog.require('goog.testing.stacktrace');
30
+ goog.require('webdriver.Future');
31
+
32
+
33
+ /**
34
+ * Describes a command to be executed by a
35
+ * {@code webdriver.AbstractCommandProcessor}.
36
+ * @param {webdriver.WebDriver} driver The driver that this is a command for.
37
+ * @param {webdriver.CommandName} name The name of this command.
38
+ * @param {webdriver.WebElement} opt_element The element to perform this
39
+ * command on. If not defined, the command will be performed relative to
40
+ * the document root.
41
+ * @constructor
42
+ * @extends {goog.events.EventTarget}
43
+ */
44
+ webdriver.Command = function(driver, name, opt_element) {
45
+ goog.events.EventTarget.call(this);
46
+
47
+ /**
48
+ * The driver that this is a command to.
49
+ * @type {webdriver.WebDriver}
50
+ * @private
51
+ */
52
+ this.driver_ = driver;
53
+
54
+ /**
55
+ * A future that will be automatically updated with the value of this
56
+ * command's response when it is ready. If the command fails, the
57
+ * future's value will not be set.
58
+ * @type {webdriver.Future}
59
+ * @private
60
+ */
61
+ this.futureResult_ = new webdriver.Future(this.driver_);
62
+
63
+ /**
64
+ * The name of this command.
65
+ * @type {webdriver.CommandName}
66
+ */
67
+ this.name = name;
68
+
69
+ /**
70
+ * The element to perform this command on. If not defined, the command will be
71
+ * performed relative to the document root.
72
+ * @type {webdriver.WebElement}
73
+ */
74
+ this.element = opt_element;
75
+
76
+ /**
77
+ * The parameters to this command.
78
+ * @type {Array.<*>}
79
+ */
80
+ this.parameters = [];
81
+
82
+ /**
83
+ * The response to this command.
84
+ * @type {?webdriver.Response}
85
+ */
86
+ this.response = null;
87
+
88
+ };
89
+ goog.inherits(webdriver.Command, goog.events.EventTarget);
90
+
91
+
92
+ /**
93
+ * The event dispatched by a command when it fails.
94
+ * @type {string}
95
+ */
96
+ webdriver.Command.ERROR_EVENT = 'ERROR';
97
+
98
+
99
+ /** @override */
100
+ webdriver.Command.prototype.disposeInternal = function() {
101
+ webdriver.Command.superClass_.disposeInternal.call(this);
102
+ this.futureResult_.dispose();
103
+ delete this.driver_;
104
+ delete this.futureResult_;
105
+ delete this.name;
106
+ delete this.element;
107
+ delete this.parameters;
108
+ delete this.response;
109
+ };
110
+
111
+
112
+ /** @override */
113
+ webdriver.Command.prototype.toString = function() {
114
+ return this.name;
115
+ };
116
+
117
+
118
+ /**
119
+ * @return {webdriver.WebDriver} The driver that this is a command to.
120
+ */
121
+ webdriver.Command.prototype.getDriver = function() {
122
+ return this.driver_;
123
+ };
124
+
125
+
126
+ /**
127
+ * @return {webdriver.CommandName} This command's name.
128
+ */
129
+ webdriver.Command.prototype.getName = function() {
130
+ return this.name;
131
+ };
132
+
133
+
134
+ /**
135
+ * @return {webdriver.Future} The future result (value-only) of this command.
136
+ */
137
+ webdriver.Command.prototype.getFutureResult = function() {
138
+ return this.futureResult_;
139
+ };
140
+
141
+
142
+ /**
143
+ * @return {boolean} Whether this command has finished; aborted commands are
144
+ * never considered finished.
145
+ */
146
+ webdriver.Command.prototype.isFinished = function() {
147
+ return !!this.response;
148
+ };
149
+
150
+
151
+ /**
152
+ * Set the parameters to send with this command.
153
+ * @param {*} var_args The arguments to send to this command.
154
+ * @return {webdriver.Command} A self reference.
155
+ */
156
+ webdriver.Command.prototype.setParameters = function(var_args) {
157
+ this.parameters = goog.array.slice(arguments, 0);
158
+ return this;
159
+ };
160
+
161
+
162
+ /**
163
+ * @return {Array.<*>} The parameters to send with this command.
164
+ */
165
+ webdriver.Command.prototype.getParameters = function() {
166
+ return this.parameters;
167
+ };
168
+
169
+
170
+ /**
171
+ * @return {?webdriver.Response} The response to this command if it is ready.
172
+ */
173
+ webdriver.Command.prototype.getResponse = function() {
174
+ return this.response;
175
+ };
176
+
177
+
178
+ /**
179
+ * Set the response for this command. The response may only be set once; any
180
+ * repeat calls will be ignored.
181
+ * @param {webdriver.Response} response The response.
182
+ * @throws If the response was already set.
183
+ */
184
+ webdriver.Command.prototype.setResponse = function(response) {
185
+ if (this.isDisposed() || this.isFinished()) {
186
+ return;
187
+ }
188
+ this.response = response;
189
+ this.driver_.setContext(this.response.context);
190
+ if (!this.response.isFailure) {
191
+ this.futureResult_.setValue(this.response.value);
192
+ } else {
193
+ this.dispatchEvent(webdriver.Command.ERROR_EVENT);
194
+ }
195
+ };
196
+
197
+
198
+ /**
199
+ * Enumeration of predefined names command names that all command processors
200
+ * will support.
201
+ * @enum {string}
202
+ */
203
+ webdriver.CommandName = {
204
+ // Commands executed directly by the JS API. --------------------------------
205
+ FUNCTION: 'function',
206
+ SLEEP: 'sleep',
207
+ WAIT: 'wait',
208
+ PAUSE: 'pause',
209
+
210
+ // Commands dispatched to the browser driver. -------------------------------
211
+ NEW_SESSION: 'newSession',
212
+ DELETE_SESSION: 'deleteSession',
213
+ QUIT: 'quit',
214
+ GET_CURRENT_WINDOW_HANDLE: 'getCurrentWindowHandle',
215
+ GET_WINDOW_HANDLES: 'getWindowHandles',
216
+ GET_CURRENT_URL: 'getCurrentUrl',
217
+ CLOSE: 'close',
218
+ SWITCH_TO_WINDOW: 'switchToWindow',
219
+ SWITCH_TO_FRAME: 'switchToFrame',
220
+ SWITCH_TO_DEFAULT_CONTENT: 'switchToDefaultContent',
221
+ GET: 'get',
222
+ FORWARD: 'goForward',
223
+ BACK: 'goBack',
224
+ REFRESH: 'refresh',
225
+ GET_TITLE: 'title',
226
+ GET_PAGE_SOURCE: 'getPageSource',
227
+ EXECUTE_SCRIPT: 'executeScript',
228
+ GET_MOUSE_SPEED: 'getMouseSpeed',
229
+ SET_MOUSE_SPEED: 'setMouseSpeed',
230
+ FIND_ELEMENT: 'findElement',
231
+ FIND_ELEMENTS: 'findElements',
232
+ FIND_CHILD_ELEMENT: 'findChildElement',
233
+ FIND_CHILD_ELEMENTS: 'findChildElements',
234
+ GET_ACTIVE_ELEMENT: 'getActiveElement',
235
+ SET_VISIBLE: 'setVisible',
236
+ GET_VISIBLE: 'getVisible',
237
+ CLICK: 'click',
238
+ CLEAR: 'clear',
239
+ SUBMIT: 'submit',
240
+ GET_TEXT: 'getText',
241
+ SEND_KEYS: 'sendKeys',
242
+ GET_VALUE: 'getValue',
243
+ GET_TAG_NAME: 'getTagName',
244
+ IS_SELECTED: 'isSelected',
245
+ SET_SELECTED: 'setSelected',
246
+ TOGGLE: 'toggle',
247
+ IS_ENABLED: 'isEnabled',
248
+ IS_DISPLAYED: 'isDisplayed',
249
+ GET_LOCATION: 'getLocation',
250
+ GET_SIZE: 'getSize',
251
+ GET_ATTRIBUTE: 'getAttribute',
252
+ DRAG_ELEMENT: 'dragElement',
253
+ GET_VALUE_OF_CSS_PROPERTY: 'getValueOfCssProperty'
254
+ };
255
+
256
+
257
+ /**
258
+ * Encapsulates a response to a {@code webdriver.Command}.
259
+ * @param {boolean} isFailure Whether the command resulted in an error. If
260
+ * {@code true}, then {@code value} contains the error message.
261
+ * @param {webdriver.Context} context The (potentially new) context resulting
262
+ * from the command.
263
+ * @param {*} value The value of the response, the meaning of which depends
264
+ * on the command.
265
+ * @parma {Error} opt_error An error that caused this command to fail
266
+ * prematurely.
267
+ * @constructor
268
+ */
269
+ webdriver.Response = function(isFailure, context, value, opt_error) {
270
+ this.isFailure = isFailure;
271
+ this.context = context;
272
+ this.value = value;
273
+ this.errors = goog.array.slice(arguments, 3);
274
+ };
275
+
276
+
277
+ /**
278
+ * @return {?string} A formatted error message, or {@code null} if this is not a
279
+ * failure response.
280
+ */
281
+ webdriver.Response.prototype.getErrorMessage = function() {
282
+ if (!this.isFailure) {
283
+ return null;
284
+ }
285
+ var message = [];
286
+ if (goog.isString(this.value)) {
287
+ message.push(this.value);
288
+ } else if (null != this.value && goog.isDef(this.value.message)) {
289
+ message.push(this.value.message);
290
+ if (goog.isDef(this.value.fileName)) {
291
+ message.push(this.value.fileName + '@' + this.value.lineNumber);
292
+ }
293
+ }
294
+ goog.array.extend(message, goog.array.map(this.errors, function(error) {
295
+ if (goog.isString(error)) {
296
+ return error;
297
+ }
298
+ var errMsg = error.message || error.description || error.toString();
299
+ var stack = error.stack ?
300
+ goog.testing.stacktrace.canonicalize(error.stack) : error['stackTrace'];
301
+ return errMsg + '\n' + stack;
302
+ }));
303
+ return message.join('\n');
304
+ };