selenium-webdriver 0.0.8 → 0.0.9

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.
@@ -25,7 +25,6 @@ goog.provide('webdriver.WebElement');
25
25
  goog.require('goog.array');
26
26
  goog.require('webdriver.By.Locator');
27
27
  goog.require('webdriver.By.Strategy');
28
- goog.require('webdriver.Command');
29
28
  goog.require('webdriver.CommandName');
30
29
  goog.require('webdriver.Future');
31
30
 
@@ -64,92 +63,6 @@ webdriver.WebElement = function(driver) {
64
63
  };
65
64
 
66
65
 
67
- /**
68
- * Regular expression for a UUID.
69
- * @type {RegExp}
70
- * @static
71
- */
72
- webdriver.WebElement.UUID_REGEX =
73
- /^{[\da-z]{8}-[\da-z]{4}-[\da-z]{4}-[\da-z]{4}-[\da-z]{12}}$/i;
74
-
75
-
76
- /**
77
- * Adds a command to the given {@code webdriver.WebDriver} instance to find an
78
- * element on the page.
79
- * @param {webdriver.WebDriver} driver The driver to perform the search with.
80
- * @param {webdriver.By.Locator|{*: string}} locator The locator to use for
81
- * finding the element, or a short-hand object that can be converted into a
82
- * locator.
83
- * @return {webdriver.WebElement} A WebElement that can be used to issue
84
- * commands on the found element. The element's ID will be set
85
- * asynchronously once the driver successfully finds the element.
86
- * @see webdriver.By.Locator.createFromObj
87
- */
88
- webdriver.WebElement.findElement = function(driver, locator) {
89
- var webElement = new webdriver.WebElement(driver);
90
- locator = webdriver.By.Locator.checkLocator(locator);
91
- var command = driver.addCommand(webdriver.CommandName.FIND_ELEMENT).
92
- setParameters(locator.type, locator.target);
93
- webElement.getId().setValue(command.getFutureResult());
94
- return webElement;
95
- };
96
-
97
-
98
- /**
99
- * Adds a command to the given {@code webdriver.WebDriver} instance to test if
100
- * an element is present on the page.
101
- * @param {webdriver.WebDriver} driver The driver to perform the search with.
102
- * @param {webdriver.By.Locator|{*: string}} locator The locator to use for
103
- * finding the element, or a short-hand object that can be converted into a
104
- * locator.
105
- * @return {webdriver.Future} A future whose value will be set when the driver
106
- * completes the search; value will be {@code true} if the element was
107
- * found, false otherwise.
108
- * @see webdriver.By.Locator.createFromObj
109
- */
110
- webdriver.WebElement.isElementPresent = function(driver, locator) {
111
- var callback = function(response) {
112
- // If returns without an error, element is present.
113
- response.value = !response.isFailure;
114
- // Go ahead and clear the error.
115
- response.isFailure = false;
116
- };
117
- locator = webdriver.By.Locator.checkLocator(locator);
118
- return driver.addCommand(webdriver.CommandName.FIND_ELEMENT).
119
- setParameters(locator.type, locator.target).
120
- setSuccessCallback(callback).
121
- setFailureCallback(callback).
122
- getFutureResult();
123
- };
124
-
125
-
126
- /**
127
- * Adds a command to the given {@code webdriver.WebDriver} instance to find
128
- * multiple elements on the page.
129
- * @param {webdriver.WebDriver} driver The driver to perform the search with.
130
- * @param {webdriver.By.Locator|{*: string}} locator The locator to use for
131
- * finding the element, or a short-hand object that can be converted into a
132
- * locator.
133
- * @see webdriver.By.Locator.createFromObj
134
- */
135
- webdriver.WebElement.findElements = function(driver, locator) {
136
- locator = webdriver.By.Locator.checkLocator(locator);
137
- driver.addCommand(webdriver.CommandName.FIND_ELEMENTS).
138
- setParameters(locator.type, locator.target).
139
- setSuccessCallback(function(response) {
140
- var elements = [];
141
- for (var i = 0, id; id = response.value[i]; i++) {
142
- if (id) {
143
- var element = new webdriver.WebElement(driver);
144
- element.getId().setValue(id);
145
- elements.push(element);
146
- }
147
- }
148
- response.value = elements;
149
- });
150
- };
151
-
152
-
153
66
  /**
154
67
  * Adds a command to determine if an element is present under this element in
155
68
  * the DOM tree.
@@ -162,22 +75,29 @@ webdriver.WebElement.findElements = function(driver, locator) {
162
75
  * @see webdriver.By.Locator.createFromObj
163
76
  */
164
77
  webdriver.WebElement.prototype.isElementPresent = function(locator) {
165
- var callback = function(response) {
166
- // If returns without an error, element is present.
167
- response.value = !response.isFailure;
168
- // Go ahead and clear the error (if any).
169
- response.isFailure = false;
170
- };
171
78
  locator = webdriver.By.Locator.checkLocator(locator);
172
- return this.driver_.addCommand(webdriver.CommandName.FIND_CHILD_ELEMENT).
173
- setParameters({
174
- 'id': this.getId(),
175
- 'using': locator.type,
176
- 'value': locator.target
177
- }).
178
- setSuccessCallback(callback).
179
- setFailureCallback(callback).
180
- getFutureResult();
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);
181
101
  };
182
102
 
183
103
 
@@ -217,23 +137,25 @@ webdriver.WebElement.prototype.findElement = function(locator) {
217
137
  */
218
138
  webdriver.WebElement.prototype.findElements = function(locator) {
219
139
  locator = webdriver.By.Locator.checkLocator(locator);
220
- this.driver_.addCommand(webdriver.CommandName.FIND_CHILD_ELEMENTS).
221
- setParameters({
222
- 'id': this.getId(),
223
- 'using': locator.type,
224
- 'value': locator.target
225
- }).
226
- setSuccessCallback(function(response) {
227
- var elements = [];
228
- for (var i = 0, id; id = response.value[i]; i++) {
229
- if (id) {
230
- var element = new webdriver.WebElement(this.driver_);
231
- element.getId().setValue(id);
232
- elements.push(element);
233
- }
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);
234
154
  }
235
- response.value = elements;
236
- }, this);
155
+ }
156
+ return elements;
157
+ }, this);
158
+ }, this);
237
159
  };
238
160
 
239
161
 
@@ -454,12 +376,12 @@ webdriver.WebElement.prototype.dragAndDropTo = function(webElement) {
454
376
  * enabled, as dictated by the {@code disabled} attribute.
455
377
  */
456
378
  webdriver.WebElement.prototype.isEnabled = function() {
457
- return this.createCommand_(webdriver.CommandName.GET_ATTRIBUTE).
458
- setParameters('disabled').
459
- setSuccessCallback(function(response) {
460
- response.value = !!!response.value;
461
- }).
462
- getFutureResult();
379
+ return this.driver_.callFunction(function() {
380
+ this.getAttribute('disabled');
381
+ return this.driver_.callFunction(function(value) {
382
+ return !!!value;
383
+ });
384
+ }, this);
463
385
  };
464
386
 
465
387
 
@@ -473,8 +395,8 @@ webdriver.WebElement.prototype.isEnabled = function() {
473
395
  webdriver.WebElement.prototype.isCheckedOrSelected_ = function() {
474
396
  return this.driver_.callFunction(function() {
475
397
  this.createCommand_(webdriver.CommandName.GET_TAG_NAME);
476
- return this.driver_.callFunction(function(response) {
477
- var attribute = response.value == 'input' ? 'checked' : 'selected';
398
+ return this.driver_.callFunction(function(prevResult) {
399
+ var attribute = prevResult == 'input' ? 'checked' : 'selected';
478
400
  return this.getAttribute(attribute);
479
401
  }, this);
480
402
  }, this);
@@ -506,7 +428,7 @@ webdriver.WebElement.prototype.isChecked = function() {
506
428
  webdriver.WebElement.prototype.toggle = function() {
507
429
  return this.driver_.callFunction(function() {
508
430
  this.createCommand_(webdriver.CommandName.TOGGLE);
509
- return this.driver_.callFunction(this.isCheckedOrSelected_, this);
431
+ return this.isCheckedOrSelected_();
510
432
  }, this);
511
433
  };
512
434
 
@@ -47,23 +47,29 @@ module Selenium
47
47
  end
48
48
 
49
49
  def kill
50
- Process.kill("TERM", @pid) if @pid
50
+ Process.kill('TERM', @pid) if @pid
51
51
  end
52
52
 
53
53
  def kill!
54
- Process.kill("KILL", @pid) if @pid
54
+ Process.kill('KILL', @pid) if @pid
55
55
  end
56
56
 
57
57
  module WindowsProcess
58
58
  def start
59
59
  require "win32/process" # adds a dependency on windows
60
- @pid = Process.create(:app_name => @args.join(" "),
61
- :process_inherit => true,
62
- :thread_inherit => true,
63
- :inherit => true).process_id
60
+ @pid = Process.create(
61
+ :app_name => @args.join(" "),
62
+ :process_inherit => true,
63
+ :thread_inherit => true,
64
+ :inherit => true
65
+ ).process_id
64
66
 
65
67
  self
66
68
  end
69
+
70
+ def kill
71
+ kill!
72
+ end
67
73
  end
68
74
 
69
75
  module JRubyProcess
@@ -82,7 +82,7 @@ WdCertOverrideService.prototype.hasMatchingOverride = function(
82
82
  this.ERROR_TIME;
83
83
  localdump("Bits: " + aOverrideBits.value);
84
84
  } else {
85
- retval = this.origListener.hasMatchingOverride(aHostName, aPort,
85
+ retval = this.origListener_.hasMatchingOverride(aHostName, aPort,
86
86
  aCert, aOverrideBits, aIsTemporary);
87
87
  }
88
88
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-29 00:00:00 +01:00
12
+ date: 2009-12-09 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -86,10 +86,10 @@ files:
86
86
  - common/src/js/extension/README
87
87
  - common/src/js/factory.js
88
88
  - common/src/js/future.js
89
+ - common/src/js/jsunit.js
89
90
  - common/src/js/key.js
90
91
  - common/src/js/localcommandprocessor.js
91
- - common/src/js/logging.js
92
- - common/src/js/testrunner.js
92
+ - common/src/js/testcase.js
93
93
  - common/src/js/timing.js
94
94
  - common/src/js/webdriver.js
95
95
  - common/src/js/webelement.js
@@ -143,7 +143,11 @@ files:
143
143
  - jobbie/src/rb/lib/selenium/webdriver/ie/util.rb
144
144
  - jobbie/src/rb/lib/selenium/webdriver/ie.rb
145
145
  - jobbie/prebuilt/Win32/Release/InternetExplorerDriver.dll
146
+ - jobbie/prebuilt/Win32/Release/webdriver-ie-test.dll
147
+ - jobbie/prebuilt/Win32/Release/webdriver-ie.dll
146
148
  - jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll
149
+ - jobbie/prebuilt/x64/Release/webdriver-ie-test.dll
150
+ - jobbie/prebuilt/x64/Release/webdriver-ie.dll
147
151
  - remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb
148
152
  - remote/client/src/rb/lib/selenium/webdriver/remote/capabilities.rb
149
153
  - remote/client/src/rb/lib/selenium/webdriver/remote/commands.rb
@@ -1,249 +0,0 @@
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 logging API that logs to a DOM on the current page as
20
- * well as the Firebug console.
21
- * @author jmelyba@gmail.com (Jason Leyba)
22
- */
23
-
24
- goog.provide('webdriver.logging');
25
- goog.provide('webdriver.logging.Level');
26
-
27
- goog.require('goog.dom');
28
- goog.require('goog.string');
29
-
30
-
31
- /**
32
- * Represents a level that can be used to filter log messages.
33
- * @param {number} code Numeric value for this level.
34
- * @param {string} firebugLogFnName The name of the firebug function to use for
35
- * logging messages at this level to the console.
36
- * @param {string} domColor The color string to use for logging messages to the
37
- * DOM at this level.
38
- * @constructor
39
- */
40
- webdriver.logging.Level = function(code, firebugLogFnName, domColor) {
41
- this.code = code;
42
- this.firebugLogFnName = firebugLogFnName;
43
- this.domColor = domColor;
44
- };
45
-
46
-
47
- webdriver.logging.Level.ERROR = new webdriver.logging.Level(0, 'error', 'red');
48
- webdriver.logging.Level.WARN = new webdriver.logging.Level(1, 'warn', 'orange');
49
- webdriver.logging.Level.INFO = new webdriver.logging.Level(2, 'info', 'black');
50
- webdriver.logging.Level.DEBUG = new webdriver.logging.Level(3, 'debug', 'gray');
51
-
52
-
53
- /**
54
- * A reference to the Firebug console. Will be undefined if the current browser
55
- * does not have Firebug installed (or if the current browser is not Firefox).
56
- * @type {?Object}
57
- * @private
58
- */
59
- webdriver.logging.console_ = window['console'];
60
-
61
-
62
- /**
63
- * Whether to log to the Firebug console if it is available.
64
- * @type {boolean}
65
- * @private
66
- */
67
- webdriver.logging.firebugLogging_ = false;
68
-
69
-
70
- /**
71
- * Whether to log messages to the DOM.
72
- * @type {boolean}
73
- * @private
74
- */
75
- webdriver.logging.domLogging_ = true;
76
-
77
-
78
- /**
79
- * The current logging level. Messages below this level will not be logged.
80
- * @type {webdriver.logging.Level}
81
- * @private
82
- */
83
- webdriver.logging.currentLevel_ = webdriver.logging.Level.INFO;
84
-
85
-
86
- /**
87
- * @param {boolean} enable Whether to enable logging to the Firebug console.
88
- */
89
- webdriver.logging.enableFirebugLogging = function(enable) {
90
- webdriver.logging.firebugLogging_ = enable;
91
- };
92
-
93
-
94
- /**
95
- * @param {boolean} enable Whether to enable logging to the DOM.
96
- */
97
- webdriver.logging.enableDomLogging = function(enable) {
98
- webdriver.logging.domLogging_ = enable;
99
- };
100
-
101
-
102
- /**
103
- * @param {webdriver.logging.Level} newLevel The new level to filter messages
104
- * by.
105
- */
106
- webdriver.logging.setLevel = function (newLevel) {
107
- webdriver.logging.currentLevel_ = newLevel;
108
- };
109
-
110
-
111
- /**
112
- * Clears all log messages.
113
- */
114
- webdriver.logging.clear = function() {
115
- if (webdriver.logging.div_) {
116
- goog.dom.setTextContent(webdriver.logging.div_, '');
117
- }
118
-
119
- if (webdriver.logging.firebugLogging_ &&
120
- webdriver.logging.console_ &&
121
- goog.isFunction(webdriver.logging.console_['clear'])) {
122
- webdriver.logging.console_['clear']();
123
- }
124
- };
125
-
126
-
127
- /**
128
- * Utility function for logging status messages.
129
- * @param {string} msg The message to log.
130
- * @param {?webdriver.logging.Level} opt_logLevel The level to log the message
131
- * at. Defaults to {@code webdriver.LogLevel.INFO}.
132
- */
133
- webdriver.logging.log = function(msg, opt_logLevel) {
134
- var logLevel = opt_logLevel || webdriver.logging.Level.INFO;
135
- if (logLevel.code > webdriver.logging.currentLevel_.code) {
136
- return;
137
- }
138
-
139
- msg = '[' + goog.now() + ']: ' + msg;
140
-
141
- if (webdriver.logging.firebugLogging_) {
142
- var consoleLoggerFn = webdriver.logging.console_ ?
143
- (webdriver.logging.console_[logLevel.firebugLogFnName] ||
144
- webdriver.logging.console_['log']) : null;
145
- if (goog.isFunction(consoleLoggerFn)) {
146
- consoleLoggerFn(msg);
147
- }
148
- }
149
-
150
- if (!webdriver.logging.domLogging_) {
151
- return;
152
- }
153
-
154
- if (!webdriver.logging.div_) {
155
- webdriver.logging.div_ = goog.dom.createDom('DIV', {
156
- style: 'border: 1px solid black; margin: 3px; padding: 3px'
157
- });
158
- goog.dom.appendChild(goog.dom.getDocument().body, webdriver.logging.div_);
159
- }
160
-
161
- var logRecord = goog.dom.createDom('DIV', {
162
- style: ('font-family: Courier; font-size: 9pt; ' +
163
- 'color: ' + logLevel.domColor + ';' +
164
- 'border-top: 1px solid silver;')
165
- });
166
- logRecord.innerHTML = webdriver.logging.jsStringToHtml(msg);
167
- goog.dom.appendChild(webdriver.logging.div_, logRecord);
168
- };
169
-
170
-
171
- /**
172
- * Escapes a JavaScript string so it can be inserted as HTML.
173
- * - Converts newlines to BR tags
174
- * - Replaces all whitespace with {@code nbsp;}
175
- * - Escapes all appropriate characters with HTML entities (&lt;, &gt;, etc.)
176
- * @param {string} str The string to convert to HTML.
177
- * @return {string} The converted string.
178
- */
179
- webdriver.logging.jsStringToHtml = function(str) {
180
- str = goog.string.canonicalizeNewlines(str);
181
- str = goog.string.htmlEscape(str);
182
- return str.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;');
183
- };
184
-
185
-
186
- /**
187
- * An alias for {@code webdriver.logging.log} used to log messages at the
188
- * {@code DEBUG} level.
189
- * @param {string} message The message to log.
190
- */
191
- webdriver.logging.debug = function(message) {
192
- webdriver.logging.log(message, webdriver.logging.Level.DEBUG);
193
- };
194
-
195
-
196
- /**
197
- * An alias for {@code webdriver.logging.log} used to log messages at the
198
- * {@code INFO} level.
199
- * @param {string} message The message to log.
200
- */
201
- webdriver.logging.info = function(message) {
202
- webdriver.logging.log(message, webdriver.logging.Level.INFO);
203
- };
204
-
205
-
206
- /**
207
- * An alias for {@code webdriver.logging.log} used to log messages at the
208
- * {@code WARN} level.
209
- * @param {string} message The message to log.
210
- */
211
- webdriver.logging.warn = function(message) {
212
- webdriver.logging.log(message, webdriver.logging.Level.WARN);
213
- };
214
-
215
-
216
- /**
217
- * An alias for {@code webdriver.logging.log} used to log messages at the
218
- * {@code ERROR} level.
219
- * @param {string} message The message to log.
220
- */
221
- webdriver.logging.error = function(message) {
222
- webdriver.logging.log(message, webdriver.logging.Level.ERROR);
223
- };
224
-
225
-
226
- /**
227
- * Utility function for recursively describing all of the properties in an
228
- * object using a DFS traversal.
229
- * @param {*} obj The object to describe.
230
- * @param {string} opt_indent Indentation for the current DFS level.
231
- * @return {string} The object description.
232
- */
233
- webdriver.logging.describe = function(obj, opt_indent) {
234
- var indent = opt_indent || '';
235
- var msgLines = [];
236
- if (goog.isString(obj)) {
237
- msgLines.push(indent + ' (' + goog.typeOf(obj) + ') ' + obj);
238
- } else {
239
- for (var prop in obj) {
240
- msgLines.push(
241
- indent + prop + ': (' + goog.typeOf(obj[prop]) + ') ' + obj[prop]);
242
- if (goog.isObject(obj[prop]) && !goog.isFunction(obj[prop]) &&
243
- goog.isArray(obj[prop])) {
244
- msgLines.push(webdriver.logging.describe(obj[prop], indent + ' '));
245
- }
246
- };
247
- }
248
- return msgLines.join('\n');
249
- };