selenium-webdriver 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
  2. data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
  3. data/chrome/src/extension/background.html +9 -0
  4. data/chrome/src/extension/background.js +933 -0
  5. data/chrome/src/extension/content_script.js +1286 -0
  6. data/chrome/src/extension/manifest-nonwin.json +15 -0
  7. data/chrome/src/extension/manifest-win.json +16 -0
  8. data/chrome/src/extension/toolstrip.html +28 -0
  9. data/chrome/src/extension/utils.js +196 -0
  10. data/chrome/src/rb/lib/selenium/webdriver/chrome.rb +8 -0
  11. data/chrome/src/rb/lib/selenium/webdriver/chrome/bridge.rb +324 -0
  12. data/chrome/src/rb/lib/selenium/webdriver/chrome/command_executor.rb +70 -0
  13. data/chrome/src/rb/lib/selenium/webdriver/chrome/launcher.rb +119 -0
  14. data/common/src/js/abstractcommandprocessor.js +161 -0
  15. data/common/src/js/asserts.js +296 -0
  16. data/common/src/js/by.js +147 -0
  17. data/common/src/js/command.js +274 -0
  18. data/common/src/js/context.js +58 -0
  19. data/common/src/js/extension/README +2 -0
  20. data/common/src/js/extension/dommessenger.js +152 -0
  21. data/common/src/js/factory.js +55 -0
  22. data/common/src/js/future.js +118 -0
  23. data/common/src/js/key.js +117 -0
  24. data/common/src/js/localcommandprocessor.js +181 -0
  25. data/common/src/js/logging.js +249 -0
  26. data/common/src/js/testrunner.js +605 -0
  27. data/common/src/js/timing.js +89 -0
  28. data/common/src/js/wait.js +199 -0
  29. data/common/src/js/webdriver.js +853 -0
  30. data/common/src/js/webelement.js +683 -0
  31. data/common/src/rb/lib/selenium-webdriver.rb +1 -0
  32. data/common/src/rb/lib/selenium/webdriver.rb +52 -0
  33. data/common/src/rb/lib/selenium/webdriver/bridge_helper.rb +88 -0
  34. data/common/src/rb/lib/selenium/webdriver/child_process.rb +85 -0
  35. data/common/src/rb/lib/selenium/webdriver/core_ext/dir.rb +41 -0
  36. data/common/src/rb/lib/selenium/webdriver/driver.rb +128 -0
  37. data/common/src/rb/lib/selenium/webdriver/element.rb +126 -0
  38. data/common/src/rb/lib/selenium/webdriver/error.rb +68 -0
  39. data/common/src/rb/lib/selenium/webdriver/find.rb +69 -0
  40. data/common/src/rb/lib/selenium/webdriver/navigation.rb +23 -0
  41. data/common/src/rb/lib/selenium/webdriver/options.rb +50 -0
  42. data/common/src/rb/lib/selenium/webdriver/platform.rb +82 -0
  43. data/common/src/rb/lib/selenium/webdriver/target_locator.rb +23 -0
  44. data/firefox/prebuilt/nsICommandProcessor.xpt +0 -0
  45. data/firefox/prebuilt/nsINativeEvents.xpt +0 -0
  46. data/firefox/prebuilt/nsIResponseHandler.xpt +0 -0
  47. data/firefox/src/extension/chrome.manifest +3 -0
  48. data/firefox/src/extension/components/context.js +37 -0
  49. data/firefox/src/extension/components/driver-component.js +127 -0
  50. data/firefox/src/extension/components/firefoxDriver.js +706 -0
  51. data/firefox/src/extension/components/json2.js +273 -0
  52. data/firefox/src/extension/components/keytest.html +554 -0
  53. data/firefox/src/extension/components/nsCommandProcessor.js +586 -0
  54. data/firefox/src/extension/components/screenshooter.js +70 -0
  55. data/firefox/src/extension/components/socketListener.js +185 -0
  56. data/firefox/src/extension/components/utils.js +1200 -0
  57. data/firefox/src/extension/components/webLoadingListener.js +57 -0
  58. data/firefox/src/extension/components/webdriverserver.js +101 -0
  59. data/firefox/src/extension/components/wrappedElement.js +609 -0
  60. data/firefox/src/extension/content/fxdriver.xul +30 -0
  61. data/firefox/src/extension/content/server.js +95 -0
  62. data/firefox/src/extension/idl/nsICommandProcessor.idl +38 -0
  63. data/firefox/src/extension/idl/nsIResponseHandler.idl +34 -0
  64. data/firefox/src/extension/install.rdf +29 -0
  65. data/firefox/src/rb/lib/selenium/webdriver/firefox.rb +21 -0
  66. data/firefox/src/rb/lib/selenium/webdriver/firefox/binary.rb +86 -0
  67. data/firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb +426 -0
  68. data/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb +82 -0
  69. data/firefox/src/rb/lib/selenium/webdriver/firefox/launcher.rb +132 -0
  70. data/firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb +174 -0
  71. data/firefox/src/rb/lib/selenium/webdriver/firefox/profiles_ini.rb +60 -0
  72. data/firefox/src/rb/lib/selenium/webdriver/firefox/util.rb +23 -0
  73. data/jobbie/prebuilt/Win32/Release/InternetExplorerDriver.dll +0 -0
  74. data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
  75. data/jobbie/src/rb/lib/selenium/webdriver/ie.rb +14 -0
  76. data/jobbie/src/rb/lib/selenium/webdriver/ie/bridge.rb +552 -0
  77. data/jobbie/src/rb/lib/selenium/webdriver/ie/lib.rb +94 -0
  78. data/jobbie/src/rb/lib/selenium/webdriver/ie/util.rb +147 -0
  79. data/remote/client/src/rb/lib/selenium/webdriver/remote.rb +16 -0
  80. data/remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb +374 -0
  81. data/remote/client/src/rb/lib/selenium/webdriver/remote/capabilities.rb +105 -0
  82. data/remote/client/src/rb/lib/selenium/webdriver/remote/commands.rb +53 -0
  83. data/remote/client/src/rb/lib/selenium/webdriver/remote/default_http_client.rb +71 -0
  84. data/remote/client/src/rb/lib/selenium/webdriver/remote/response.rb +43 -0
  85. data/remote/client/src/rb/lib/selenium/webdriver/remote/server_error.rb +32 -0
  86. metadata +182 -0
@@ -0,0 +1,147 @@
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
+
29
+
30
+ /**
31
+ * An element locator.
32
+ * @param {webdriver.By.Strategy} type The type of strategy to use for this
33
+ * locator.
34
+ * @param {string} target The target of this locator.
35
+ * @constructor
36
+ */
37
+ webdriver.By.Locator = function(type, target) {
38
+ this.type = type;
39
+ this.target = target;
40
+ };
41
+
42
+
43
+ /**
44
+ * Creates a new Locator from an object whose only property is also a key in
45
+ * the {@code webdriver.By.Strategy} enumeration. This property will be the
46
+ * locator type; its value will be the locator target.
47
+ * @param {{*: string}} obj The object to convert into a Locator.
48
+ * @return {webdriver.By.Locator} The new locator object.
49
+ * @throws If {@code obj} could not be converted.
50
+ */
51
+ webdriver.By.Locator.createFromObj = function(obj) {
52
+ var key = goog.object.getAnyKey(obj);
53
+ if (key && key in webdriver.By.Strategy) {
54
+ return new webdriver.By.Locator(webdriver.By.Strategy[key], obj[key]);
55
+ }
56
+ throw new Error('Unsupported locator strategy: ' + key);
57
+ };
58
+
59
+
60
+ /**
61
+ * Verifies that a {@code locator} is a valid locator to use for searching for
62
+ * elements on the page.
63
+ * @param {webdriver.By.Locator|{*: string}} locator The locator to verify, or
64
+ * a short-hand object that can be converted into a locator to verify.
65
+ * @return {webdriver.By.Locator} The validated locator.
66
+ * @throws If the {@code locator} is not valid.
67
+ */
68
+ webdriver.By.Locator.checkLocator = function(locator) {
69
+ if (!locator.type || !locator.target) {
70
+ locator = webdriver.By.Locator.createFromObj(locator);
71
+ }
72
+
73
+ if (locator.type == webdriver.By.Strategy.className) {
74
+ var normalized = goog.string.normalizeWhitespace(locator.target);
75
+ locator.target = goog.string.trim(normalized);
76
+ if (locator.target.search(/\s/) >= 0) {
77
+ throw new Error('Compound class names are not allowed for searches: ' +
78
+ goog.string.quote(locator.target));
79
+ }
80
+ }
81
+
82
+ return locator;
83
+ };
84
+
85
+
86
+ /**
87
+ * Enumeration of the supported strategies for finding {@code Element}s on the
88
+ * page. For all strategies, if there is more than one possible match, the
89
+ * first element encountered will be returned.
90
+ * @enum {string}
91
+ */
92
+ webdriver.By.Strategy = {
93
+
94
+ /**
95
+ * Find an element by its ID.
96
+ */
97
+ id: 'id',
98
+
99
+ /**
100
+ * Find an element by the value of its name attribute.
101
+ */
102
+ name: 'name',
103
+
104
+ /**
105
+ * Find an element by one of its class names. Only one class name may be
106
+ * specified per search.
107
+ */
108
+ className: 'class name',
109
+
110
+ /**
111
+ * Find an A tag by its text context.
112
+ */
113
+ linkText: 'link text',
114
+
115
+ /**
116
+ * Find an A tag by partially matching its text context.
117
+ */
118
+ partialLinkText: 'partial link text',
119
+
120
+ /**
121
+ * Find an element by its tagName property.
122
+ */
123
+ tagName: 'tag name',
124
+
125
+ /**
126
+ * Find an element by evaluating an XPath expression.
127
+ */
128
+ xpath: 'xpath',
129
+
130
+ /**
131
+ * Find an element by evaluating a javascript expression.
132
+ */
133
+ js: 'js'
134
+ };
135
+
136
+
137
+ /**
138
+ * Map each of the supported strategies to a factory function in the
139
+ * {@code webdriver.By} namespace.
140
+ */
141
+ goog.object.forEach(webdriver.By.Strategy, function(name, key) {
142
+ webdriver.By[key] = function(target) {
143
+ return new webdriver.By.Locator(name, target);
144
+ };
145
+ });
146
+
147
+ goog.exportSymbol('By', webdriver.By);
@@ -0,0 +1,274 @@
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
+
29
+
30
+ /**
31
+ * Describes a command to be executed by a
32
+ * {@code webdriver.AbstractCommandProcessor}.
33
+ * @param {string} name The name of this command.
34
+ * @param {webdriver.WebElement} opt_element The element to perform this command
35
+ * on. If not defined, the command will be performed relative to the
36
+ * document root.
37
+ * @constructor
38
+ */
39
+ webdriver.Command = function(name, opt_element) {
40
+
41
+ /**
42
+ * The name of this command.
43
+ * @type {string}
44
+ */
45
+ this.name = name;
46
+
47
+ /**
48
+ * The element to perform this command on. If not defined, the command will be
49
+ * performed relative to the document root.
50
+ * @type {webdriver.WebElement}
51
+ */
52
+ this.element = opt_element;
53
+
54
+ /**
55
+ * The parameters to this command.
56
+ * @type {Array.<*>}
57
+ */
58
+ this.parameters = [];
59
+
60
+ /**
61
+ * Callback for when the command processor successfully finishes this command.
62
+ * The result of this function is included in the final result of the command.
63
+ * @type {?function}
64
+ */
65
+ this.onSuccessCallbackFn = null;
66
+
67
+ /**
68
+ * Callback for when the command processor fails to successfully finish a
69
+ * command. The function should take a single argument, the
70
+ * {@code webdriver.Response} from the command processor. The response may be
71
+ * modified (for example, to turn an expect failure into a success). If the
72
+ * error state is cleared, the {@code onSucessCallbackFn} will still not be
73
+ * called.
74
+ * @type {?function}
75
+ */
76
+ this.onFailureCallbackFn = null;
77
+
78
+ /**
79
+ * Callback for when this command is completely finished, which is after the
80
+ * response is set and success/failure callbacks have been run. The function
81
+ * should take a single argument, a reference to this command.
82
+ * @type {?function}
83
+ * @private
84
+ */
85
+ this.onCompleteCallbackFn_ = null;
86
+
87
+ /**
88
+ * The response to this command.
89
+ * @type {webdriver.Response}
90
+ */
91
+ this.response = null;
92
+
93
+ /**
94
+ * Whether this command was aborted.
95
+ * @type {boolean}
96
+ */
97
+ this.abort = false;
98
+ };
99
+
100
+
101
+ /**
102
+ * Set the parameters to send with this command.
103
+ * @param {*} var_args The arguments to send to this command.
104
+ * @return {webdriver.Command} A self reference.
105
+ */
106
+ webdriver.Command.prototype.setParameters = function(var_args) {
107
+ this.parameters = goog.array.slice(arguments, 0);
108
+ return this;
109
+ };
110
+
111
+
112
+ /**
113
+ * Set the function to call with the {@code webdriver.Response} when the
114
+ * command processor successfully runs this command. This function is considered
115
+ * part of the command and any errors will cause the command as a whole to fail.
116
+ * @param {function} callbackFn The function to call on success.
117
+ * @param {Object} opt_selfObj The object in whose context to execute the
118
+ * function.
119
+ */
120
+ webdriver.Command.prototype.setSuccessCallback = function(callbackFn,
121
+ opt_selfObj) {
122
+ if (callbackFn) {
123
+ this.onSuccessCallbackFn = goog.bind(callbackFn, opt_selfObj);
124
+ }
125
+ return this;
126
+ };
127
+
128
+
129
+ /**
130
+ * Set the function to call with the {@code webdriver.Response} when the
131
+ * command processor encounters an error while executing this command.
132
+ * @param {function} callbackFn The function to call on failure.
133
+ * @param {Object} opt_selfObj The object in whose context to execute the
134
+ * function.
135
+ */
136
+ webdriver.Command.prototype.setFailureCallback = function(callbackFn,
137
+ opt_selfObj) {
138
+ if (callbackFn) {
139
+ this.onFailureCallbackFn = goog.bind(callbackFn, opt_selfObj);
140
+ }
141
+ return this;
142
+ };
143
+
144
+
145
+ /**
146
+ * Set the function to call with this command when it is completed.
147
+ * @param {function} callbackFn The function to call on command completion.
148
+ * @param {Object} opt_selfObj The object in whose context to execute the
149
+ * function.
150
+ */
151
+ webdriver.Command.prototype.setCompleteCallback = function(callbackFn,
152
+ opt_selfObj) {
153
+ if (callbackFn) {
154
+ this.onCompleteCallbackFn_ = goog.bind(callbackFn, opt_selfObj);
155
+ }
156
+ return this;
157
+ };
158
+
159
+
160
+ /**
161
+ * Set the response for this command. The response may only be set once; any
162
+ * repeat calls will be ignored.
163
+ * @param {webdriver.Response} response The response.
164
+ * @throws If the response was already set.
165
+ */
166
+ webdriver.Command.prototype.setResponse = function(response) {
167
+ if (this.response) {
168
+ return;
169
+ }
170
+ this.response = response;
171
+
172
+ var sandbox = goog.bind(function(fn) {
173
+ try {
174
+ fn.call(this, this.response);
175
+ } catch (ex) {
176
+ this.response.isFailure = true;
177
+ this.response.errors.push(ex);
178
+ }
179
+ }, this);
180
+
181
+ if (!this.response.errors.length) {
182
+ if (this.response.isFailure &&
183
+ goog.isFunction(this.onFailureCallbackFn)) {
184
+ sandbox(this.onFailureCallbackFn);
185
+ } else if (!this.response.isFailure &&
186
+ goog.isFunction(this.onSuccessCallbackFn)) {
187
+ sandbox(this.onSuccessCallbackFn);
188
+ }
189
+ }
190
+
191
+ if (this.onCompleteCallbackFn_) {
192
+ this.onCompleteCallbackFn_(this);
193
+ }
194
+ };
195
+
196
+
197
+ /**
198
+ * Enumeration of predefined names command names that all command processors
199
+ * will support.
200
+ * @enum {string}
201
+ */
202
+ webdriver.CommandName = {
203
+ // Commands executed directly by the JS API. --------------------------------
204
+ FUNCTION: 'function',
205
+ SLEEP: 'sleep',
206
+ WAIT: 'wait',
207
+ PAUSE: 'pause',
208
+
209
+ // Commands dispatched to the browser driver. -------------------------------
210
+ NEW_SESSION: 'newSession',
211
+ DELETE_SESSION: 'deleteSession',
212
+ QUIT: 'quit',
213
+ GET_CURRENT_WINDOW_HANDLE: 'getCurrentWindowHandle',
214
+ GET_WINDOW_HANDLES: 'getWindowHandles',
215
+ GET_CURRENT_URL: 'getCurrentUrl',
216
+ CLOSE: 'close',
217
+ SWITCH_TO_WINDOW: 'switchToWindow',
218
+ SWITCH_TO_FRAME: 'switchToFrame',
219
+ SWITCH_TO_DEFAULT_CONTENT: 'switchToDefaultContent',
220
+ GET: 'get',
221
+ FORWARD: 'goForward',
222
+ BACK: 'goBack',
223
+ REFRESH: 'refresh',
224
+ GET_TITLE: 'title',
225
+ GET_PAGE_SOURCE: 'getPageSource',
226
+ EXECUTE_SCRIPT: 'executeScript',
227
+ GET_MOUSE_SPEED: 'getMouseSpeed',
228
+ SET_MOUSE_SPEED: 'setMouseSpeed',
229
+ FIND_ELEMENT: 'findElement',
230
+ FIND_ELEMENTS: 'findElements',
231
+ FIND_CHILD_ELEMENT: 'findChildElement',
232
+ FIND_CHILD_ELEMENTS: 'findChildElements',
233
+ GET_ACTIVE_ELEMENT: 'getActiveElement',
234
+ SET_VISIBLE: 'setVisible',
235
+ GET_VISIBLE: 'getVisible',
236
+ CLICK: 'click',
237
+ CLEAR: 'clear',
238
+ SUBMIT: 'submit',
239
+ GET_TEXT: 'getText',
240
+ SEND_KEYS: 'sendKeys',
241
+ GET_VALUE: 'getValue',
242
+ GET_TAG_NAME: 'getTagName',
243
+ IS_SELECTED: 'isSelected',
244
+ SET_SELECTED: 'setSelected',
245
+ TOGGLE: 'toggle',
246
+ IS_ENABLED: 'isEnabled',
247
+ IS_DISPLAYED: 'isDisplayed',
248
+ GET_LOCATION: 'getLocation',
249
+ GET_SIZE: 'getSize',
250
+ GET_ATTRIBUTE: 'getAttribute',
251
+ DRAG_ELEMENT: 'dragElement',
252
+ GET_VALUE_OF_CSS_PROPERTY: 'getValueOfCssProperty'
253
+ };
254
+
255
+
256
+ /**
257
+ * Encapsulates a response to a {@code webdriver.Command}.
258
+ * @param {boolean} isFailure Whether the command resulted in an error. If
259
+ * {@code true}, then {@code value} contains the error message.
260
+ * @param {webdriver.Context} context The (potentially new) context resulting
261
+ * from the command.
262
+ * @param {string} value The value of the response, the meaning of which depends
263
+ * on the command.
264
+ * @parma {Error} opt_error An error that caused this command to fail
265
+ * prematurely.
266
+ * @constructor
267
+ */
268
+ webdriver.Response = function(isFailure, context, value, opt_error) {
269
+ this.isFailure = isFailure;
270
+ this.context = context;
271
+ this.value = value;
272
+ this.errors = goog.array.slice(arguments, 3);
273
+ this.extraData = {};
274
+ };
@@ -0,0 +1,58 @@
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 Defines a simple class for tracking the context of a WebDriver
20
+ * instance currently being controlled.
21
+ * @author jmleyba@gmail.com (Jason Leyba)
22
+ */
23
+
24
+ goog.provide('webdriver.Context');
25
+
26
+
27
+ /**
28
+ * Keeps track of a WebDriver context (window and frame).
29
+ * @param {string} opt_windowId The current window ID.
30
+ * @param {string} opt_frameId The current frame ID.
31
+ * @constructor
32
+ */
33
+ webdriver.Context = function(opt_windowId, opt_frameId) {
34
+ this.windowId = opt_windowId || '';
35
+ this.frameId = opt_frameId || '';
36
+ };
37
+
38
+
39
+ /**
40
+ * @return {string} The string representation of this context, in the form of
41
+ * "${windowId} ${frameId}".
42
+ * @override
43
+ */
44
+ webdriver.Context.prototype.toString = function() {
45
+ return this.windowId + ' ' + this.frameId;
46
+ };
47
+
48
+
49
+
50
+ /**
51
+ * Creates a new context from the given string.
52
+ * @param {string} str A string of the form "${windowId} ${frameId}".
53
+ * @static
54
+ */
55
+ webdriver.Context.fromString = function(str) {
56
+ var parts = str.split(' ');
57
+ return new webdriver.Context(parts[0], parts[1]);
58
+ };