selenium-webdriver 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
- data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
- data/chrome/src/extension/background.js +64 -48
- data/chrome/src/extension/content_script.js +253 -132
- data/chrome/src/extension/manifest-nonwin.json +1 -1
- data/chrome/src/extension/manifest-win.json +1 -1
- data/chrome/src/extension/utils.js +8 -8
- data/chrome/src/rb/lib/selenium/webdriver/chrome.rb +9 -0
- data/chrome/src/rb/lib/selenium/webdriver/chrome/bridge.rb +38 -280
- data/chrome/src/rb/lib/selenium/webdriver/chrome/command_executor.rb +119 -117
- data/chrome/src/rb/lib/selenium/webdriver/chrome/launcher.rb +36 -26
- data/common/src/js/abstractcommandprocessor.js +9 -11
- data/common/src/js/command.js +159 -83
- data/common/src/js/core/RemoteRunner.html +2 -2
- data/common/src/js/core/TestRunner-splash.html +3 -3
- data/common/src/js/core/TestRunner.html +5 -17
- data/common/src/js/core/scripts/htmlutils.js +4208 -2506
- data/common/src/js/core/scripts/selenium-api.js +2 -2
- data/common/src/js/core/scripts/selenium-browserbot.js +66 -58
- data/common/src/js/core/scripts/selenium-version.js +1 -1
- data/common/src/js/localcommandprocessor.js +5 -19
- data/common/src/js/testcase.js +2 -0
- data/common/src/js/webdriver.js +63 -93
- data/common/src/js/webelement.js +40 -42
- data/common/src/rb/lib/selenium/webdriver.rb +23 -14
- data/common/src/rb/lib/selenium/webdriver/bridge_helper.rb +8 -35
- data/common/src/rb/lib/selenium/webdriver/child_process.rb +2 -0
- data/common/src/rb/lib/selenium/webdriver/core_ext/dir.rb +1 -0
- data/common/src/rb/lib/selenium/webdriver/core_ext/string.rb +5 -0
- data/common/src/rb/lib/selenium/webdriver/driver.rb +20 -15
- data/common/src/rb/lib/selenium/webdriver/driver_extensions/takes_screenshot.rb +7 -2
- data/common/src/rb/lib/selenium/webdriver/element.rb +11 -2
- data/common/src/rb/lib/selenium/webdriver/error.rb +9 -5
- data/common/src/rb/lib/selenium/webdriver/keys.rb +1 -2
- data/common/src/rb/lib/selenium/webdriver/navigation.rb +16 -0
- data/common/src/rb/lib/selenium/webdriver/options.rb +32 -0
- data/common/src/rb/lib/selenium/webdriver/platform.rb +17 -1
- data/firefox/prebuilt/Win32/Release/webdriver-firefox.dll +0 -0
- data/firefox/src/extension/components/dispatcher.js +492 -0
- data/firefox/src/extension/components/driver-component.js +4 -1
- data/firefox/src/extension/components/errorcode.js +70 -0
- data/firefox/src/extension/components/firefoxDriver.js +173 -154
- data/firefox/src/extension/components/nsCommandProcessor.js +171 -132
- data/firefox/src/extension/components/promptService.js +5 -5
- data/firefox/src/extension/components/request.js +219 -0
- data/firefox/src/extension/components/response.js +276 -0
- data/firefox/src/extension/components/session.js +281 -0
- data/firefox/src/extension/components/sessionstore.js +226 -0
- data/firefox/src/extension/components/socketListener.js +350 -100
- data/firefox/src/extension/components/utils.js +166 -98
- data/firefox/src/extension/components/webdriverserver.js +9 -5
- data/firefox/src/extension/components/wrappedElement.js +189 -166
- data/firefox/src/extension/install.rdf +1 -1
- data/firefox/src/rb/lib/selenium/webdriver/firefox.rb +2 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/binary.rb +39 -33
- data/firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb +7 -421
- data/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb +7 -64
- data/firefox/src/rb/lib/selenium/webdriver/firefox/launcher.rb +2 -3
- data/firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb +54 -10
- data/firefox/src/rb/lib/selenium/webdriver/firefox/profiles_ini.rb +2 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/util.rb +6 -0
- data/jobbie/prebuilt/Win32/Release/InternetExplorerDriver.dll +0 -0
- data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
- data/jobbie/src/rb/lib/selenium/webdriver/ie.rb +2 -0
- data/jobbie/src/rb/lib/selenium/webdriver/ie/bridge.rb +38 -13
- data/jobbie/src/rb/lib/selenium/webdriver/ie/lib.rb +9 -2
- data/jobbie/src/rb/lib/selenium/webdriver/ie/util.rb +5 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote.rb +2 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb +42 -38
- data/remote/client/src/rb/lib/selenium/webdriver/remote/commands.rb +56 -47
- data/remote/client/src/rb/lib/selenium/webdriver/remote/default_http_client.rb +26 -26
- data/remote/client/src/rb/lib/selenium/webdriver/remote/patron_http_client.rb +58 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/response.rb +10 -12
- data/remote/client/src/rb/lib/selenium/webdriver/remote/server_error.rb +2 -17
- metadata +44 -23
- data/common/src/js/context.js +0 -58
- data/firefox/src/extension/components/context.js +0 -37
@@ -31,7 +31,6 @@ goog.require('goog.json');
|
|
31
31
|
goog.require('goog.object');
|
32
32
|
goog.require('webdriver.AbstractCommandProcessor');
|
33
33
|
goog.require('webdriver.CommandName');
|
34
|
-
goog.require('webdriver.Context');
|
35
34
|
goog.require('webdriver.Response');
|
36
35
|
|
37
36
|
|
@@ -128,9 +127,7 @@ webdriver.LocalCommandProcessor.onResponse_ = function(command, e) {
|
|
128
127
|
'receiving:\n' + jsonResponse);
|
129
128
|
|
130
129
|
var response = new webdriver.Response(
|
131
|
-
rawResponse['
|
132
|
-
webdriver.Context.fromString(rawResponse['context']),
|
133
|
-
rawResponse['response']);
|
130
|
+
rawResponse['status'], rawResponse['value']);
|
134
131
|
|
135
132
|
// Only code in this file should be dispatching command events and listening
|
136
133
|
// for response events, so this is safe. If someone else decided to attach a
|
@@ -146,25 +143,14 @@ webdriver.LocalCommandProcessor.onResponse_ = function(command, e) {
|
|
146
143
|
*/
|
147
144
|
webdriver.LocalCommandProcessor.prototype.dispatchDriverCommand = function(
|
148
145
|
command) {
|
149
|
-
if (command.getName() == webdriver.CommandName.SEND_KEYS) {
|
150
|
-
command.setParameters(command.getParameters().join(''));
|
151
|
-
}
|
152
|
-
|
153
146
|
var jsonCommand = {
|
154
|
-
'
|
155
|
-
'
|
147
|
+
'name': command.getName(),
|
148
|
+
'sessionId': {
|
149
|
+
'value': command.getDriver().getSessionId()
|
150
|
+
},
|
156
151
|
'parameters': command.getParameters()
|
157
152
|
};
|
158
153
|
|
159
|
-
if (command.element) {
|
160
|
-
try {
|
161
|
-
jsonCommand['elementId'] = command.element.getId().getValue();
|
162
|
-
} catch (ex) {
|
163
|
-
window.console.dir(command);
|
164
|
-
throw ex;
|
165
|
-
}
|
166
|
-
}
|
167
|
-
|
168
154
|
jsonCommand = goog.json.serialize(jsonCommand);
|
169
155
|
goog.debug.Logger.getLogger('webdriver.LocalCommandProcessor').fine(
|
170
156
|
'sending:\n' + jsonCommand);
|
data/common/src/js/testcase.js
CHANGED
@@ -124,7 +124,9 @@ webdriver.TestCase.prototype.startTest_ = function() {
|
|
124
124
|
// all of its subcommands so we can continue the test.
|
125
125
|
goog.events.listen(driver, webdriver.Command.ERROR_EVENT,
|
126
126
|
function(e) {
|
127
|
+
// console.error('error event!');
|
127
128
|
var failingCommand = (/** @type {webdriver.Command} */e.target);
|
129
|
+
// console.dir(failingCommand);
|
128
130
|
if (!failingCommand.getResponse()) {
|
129
131
|
// This should never happen, but just in case.
|
130
132
|
test.errors.push('Unknown error');
|
data/common/src/js/webdriver.js
CHANGED
@@ -30,7 +30,6 @@ goog.require('goog.events.EventTarget');
|
|
30
30
|
goog.require('webdriver.By.Locator');
|
31
31
|
goog.require('webdriver.Command');
|
32
32
|
goog.require('webdriver.CommandName');
|
33
|
-
goog.require('webdriver.Context');
|
34
33
|
goog.require('webdriver.Response');
|
35
34
|
goog.require('webdriver.WebElement');
|
36
35
|
goog.require('webdriver.timing');
|
@@ -110,13 +109,6 @@ webdriver.WebDriver = function(commandProcessor) {
|
|
110
109
|
*/
|
111
110
|
this.isPaused_ = false;
|
112
111
|
|
113
|
-
/**
|
114
|
-
* This instances current context (window and frame ID).
|
115
|
-
* @type {webdriver.Context}
|
116
|
-
* @private
|
117
|
-
*/
|
118
|
-
this.context_ = new webdriver.Context();
|
119
|
-
|
120
112
|
/**
|
121
113
|
* This instance's current session ID. Set with the
|
122
114
|
* {@code webdriver.WebDriver.prototype.newSession} command.
|
@@ -159,15 +151,15 @@ webdriver.WebDriver.EventType = {
|
|
159
151
|
|
160
152
|
|
161
153
|
/**
|
162
|
-
* Enumeration of the supported
|
154
|
+
* Enumeration of the supported input speeds.
|
163
155
|
* @enum {number}
|
164
|
-
* @see webdriver.WebDriver.prototype.
|
165
|
-
* @see webdriver.WebDriver.prototype.
|
156
|
+
* @see webdriver.WebDriver.prototype.setSpeed
|
157
|
+
* @see webdriver.WebDriver.prototype.getSpeed
|
166
158
|
*/
|
167
159
|
webdriver.WebDriver.Speed = {
|
168
|
-
SLOW:
|
169
|
-
MEDIUM:
|
170
|
-
FAST:
|
160
|
+
SLOW: 'SLOW',
|
161
|
+
MEDIUM: 'MEDIUM',
|
162
|
+
FAST: 'FAST'
|
171
163
|
};
|
172
164
|
|
173
165
|
|
@@ -191,7 +183,6 @@ webdriver.WebDriver.prototype.disposeInternal = function() {
|
|
191
183
|
delete this.pendingCommands_;
|
192
184
|
delete this.queuedCommands_;
|
193
185
|
delete this.isPaused_;
|
194
|
-
delete this.context_;
|
195
186
|
delete this.sessionLocked_;
|
196
187
|
delete this.sessionId_;
|
197
188
|
delete this.commandInterval_;
|
@@ -203,13 +194,11 @@ webdriver.WebDriver.prototype.disposeInternal = function() {
|
|
203
194
|
/**
|
204
195
|
* Queues a command to execute.
|
205
196
|
* @param {webdriver.CommandName} name The name of the command to execute.
|
206
|
-
* @param {webdriver.WebElement} opt_element The element that is the target
|
207
|
-
* of the new command.
|
208
197
|
* @return {webdriver.Command} The new command.
|
209
198
|
* @protected
|
210
199
|
*/
|
211
|
-
webdriver.WebDriver.prototype.addCommand = function(name
|
212
|
-
var command = new webdriver.Command(this, name
|
200
|
+
webdriver.WebDriver.prototype.addCommand = function(name) {
|
201
|
+
var command = new webdriver.Command(this, name);
|
213
202
|
goog.array.peek(this.queuedCommands_).push(command);
|
214
203
|
return command;
|
215
204
|
};
|
@@ -229,7 +218,7 @@ webdriver.WebDriver.prototype.isIdle = function() {
|
|
229
218
|
// not process any more commands, so we consider this idle.
|
230
219
|
var pendingCommand = goog.array.peek(this.pendingCommands_);
|
231
220
|
if (pendingCommand && pendingCommand.isFinished() &&
|
232
|
-
pendingCommand.getResponse().
|
221
|
+
!pendingCommand.getResponse().isSuccess()) {
|
233
222
|
return true;
|
234
223
|
}
|
235
224
|
return !pendingCommand && this.queuedCommands_.length == 1 &&
|
@@ -297,7 +286,7 @@ webdriver.WebDriver.prototype.processCommands_ = function() {
|
|
297
286
|
return;
|
298
287
|
}
|
299
288
|
|
300
|
-
if (pendingCommand && pendingCommand.getResponse().
|
289
|
+
if (pendingCommand && !pendingCommand.getResponse().isSuccess()) {
|
301
290
|
// Or should we be throwing this to be caught by window.onerror?
|
302
291
|
this.logger_.severe(
|
303
292
|
'Unhandled command failure; halting command processing:\n' +
|
@@ -333,23 +322,6 @@ webdriver.WebDriver.prototype.getSessionId = function() {
|
|
333
322
|
};
|
334
323
|
|
335
324
|
|
336
|
-
/**
|
337
|
-
* @return {webdriver.Context} This instance's current context.
|
338
|
-
*/
|
339
|
-
webdriver.WebDriver.prototype.getContext = function() {
|
340
|
-
return this.context_;
|
341
|
-
};
|
342
|
-
|
343
|
-
|
344
|
-
/**
|
345
|
-
* Sets this driver's context.
|
346
|
-
* @param {webdriver.Context} context The new context.
|
347
|
-
*/
|
348
|
-
webdriver.WebDriver.prototype.setContext = function(context) {
|
349
|
-
return this.context_ = context;
|
350
|
-
};
|
351
|
-
|
352
|
-
|
353
325
|
// ----------------------------------------------------------------------------
|
354
326
|
// Client command functions:
|
355
327
|
// ----------------------------------------------------------------------------
|
@@ -445,7 +417,7 @@ webdriver.WebDriver.prototype.pause = function() {
|
|
445
417
|
* sleep.
|
446
418
|
*/
|
447
419
|
webdriver.WebDriver.prototype.sleep = function(ms) {
|
448
|
-
this.addCommand(webdriver.CommandName.SLEEP).
|
420
|
+
this.addCommand(webdriver.CommandName.SLEEP).setParameter('ms', ms);
|
449
421
|
};
|
450
422
|
|
451
423
|
|
@@ -465,7 +437,8 @@ webdriver.WebDriver.prototype.callFunction = function(fn, opt_selfObj,
|
|
465
437
|
var previousCommand = goog.array.peek(frame);
|
466
438
|
args.push(previousCommand ? previousCommand.getFutureResult() : null);
|
467
439
|
return this.addCommand(webdriver.CommandName.FUNCTION).
|
468
|
-
|
440
|
+
setParameter('function', goog.bind(fn, opt_selfObj)).
|
441
|
+
setParameter('args', args).
|
469
442
|
getFutureResult();
|
470
443
|
};
|
471
444
|
|
@@ -528,7 +501,8 @@ webdriver.WebDriver.prototype.wait = function(conditionFn, timeout, opt_self,
|
|
528
501
|
}
|
529
502
|
|
530
503
|
this.addCommand(webdriver.CommandName.WAIT).
|
531
|
-
|
504
|
+
setParameter('function', pollFunction).
|
505
|
+
setParameter('args', [0, null]);
|
532
506
|
};
|
533
507
|
|
534
508
|
|
@@ -575,8 +549,7 @@ webdriver.WebDriver.prototype.newSession = function() {
|
|
575
549
|
webdriver.WebDriver.prototype.switchToWindow = function(name) {
|
576
550
|
this.callFunction(function() {
|
577
551
|
this.addCommand(webdriver.CommandName.SWITCH_TO_WINDOW).
|
578
|
-
|
579
|
-
this.callFunction(this.setContext, this);
|
552
|
+
setParameter('name', name);
|
580
553
|
}, this);
|
581
554
|
};
|
582
555
|
|
@@ -593,13 +566,8 @@ webdriver.WebDriver.prototype.switchToWindow = function(name) {
|
|
593
566
|
*/
|
594
567
|
webdriver.WebDriver.prototype.switchToFrame = function(frame) {
|
595
568
|
this.callFunction(function() {
|
596
|
-
|
597
|
-
|
598
|
-
if (goog.isString(frame) || goog.isNumber(frame)) {
|
599
|
-
command = this.addCommand(commandName).setParameters(frame);
|
600
|
-
} else {
|
601
|
-
command = this.addCommand(commandName, frame);
|
602
|
-
}
|
569
|
+
this.addCommand(webdriver.CommandName.SWITCH_TO_FRAME).
|
570
|
+
setParameter('id', frame);
|
603
571
|
}, this);
|
604
572
|
};
|
605
573
|
|
@@ -609,10 +577,7 @@ webdriver.WebDriver.prototype.switchToFrame = function(frame) {
|
|
609
577
|
* contains iframes.
|
610
578
|
*/
|
611
579
|
webdriver.WebDriver.prototype.switchToDefaultContent = function() {
|
612
|
-
this.
|
613
|
-
this.addCommand(webdriver.CommandName.SWITCH_TO_DEFAULT_CONTENT).
|
614
|
-
setParameters(null);
|
615
|
-
}, this);
|
580
|
+
return this.switchToFrame(null);
|
616
581
|
};
|
617
582
|
|
618
583
|
|
@@ -659,27 +624,26 @@ webdriver.WebDriver.prototype.close = function() {
|
|
659
624
|
* Helper function for converting an argument to a script into a parameter
|
660
625
|
* object to send with the {@code webdriver.Command}.
|
661
626
|
* @param {*} arg The value to convert.
|
662
|
-
* @return {
|
627
|
+
* @return {*} The converted value.
|
663
628
|
* @see {webdriver.WebDriver.prototype.executeScript}
|
664
629
|
* @private
|
665
630
|
*/
|
666
631
|
webdriver.WebDriver.wrapScriptArgument_ = function(arg) {
|
667
|
-
var type, value;
|
668
632
|
if (arg instanceof webdriver.WebElement) {
|
669
|
-
|
670
|
-
|
633
|
+
return {'ELEMENT': arg.getId()};
|
634
|
+
} else if (arg == null || !goog.isDef(arg)) {
|
635
|
+
return null;
|
671
636
|
} else if (goog.isBoolean(arg) ||
|
672
637
|
goog.isNumber(arg) ||
|
673
638
|
goog.isString(arg)) {
|
674
|
-
|
675
|
-
value = arg;
|
639
|
+
return arg;
|
676
640
|
} else if (goog.isArray(arg)) {
|
677
|
-
|
678
|
-
|
679
|
-
} else {
|
641
|
+
return goog.array.map(arg, webdriver.WebDriver.wrapScriptArgument_);
|
642
|
+
} else if (goog.isFunction(arg)) {
|
680
643
|
throw new Error('Invalid script argument type: ' + goog.typeOf(arg));
|
644
|
+
} else {
|
645
|
+
return goog.object.map(arg, webdriver.WebDriver.wrapScriptArgument_);
|
681
646
|
}
|
682
|
-
return {'type': type, 'value': value};
|
683
647
|
};
|
684
648
|
|
685
649
|
|
@@ -691,19 +655,17 @@ webdriver.WebDriver.wrapScriptArgument_ = function(arg) {
|
|
691
655
|
* @private
|
692
656
|
*/
|
693
657
|
webdriver.WebDriver.prototype.unwrapScriptResult_ = function(result) {
|
694
|
-
|
695
|
-
|
696
|
-
var element = new webdriver.WebElement(this);
|
697
|
-
element.getId().setValue(result.value);
|
698
|
-
return element;
|
699
|
-
|
700
|
-
case 'ARRAY':
|
701
|
-
return goog.array.map(result.value, goog.bind(
|
702
|
-
this.unwrapScriptResult_, this));
|
703
|
-
|
704
|
-
default:
|
705
|
-
return result.value;
|
658
|
+
if (goog.isArray(result)) {
|
659
|
+
return goog.array.map(result, goog.bind(this.unwrapScriptResult_, this));
|
706
660
|
}
|
661
|
+
|
662
|
+
if (result != null && goog.isObject(result) && 'ELEMENT' in result) {
|
663
|
+
var element = new webdriver.WebElement(this);
|
664
|
+
element.getId().setValue(result['ELEMENT']);
|
665
|
+
return element;
|
666
|
+
}
|
667
|
+
|
668
|
+
return result;
|
707
669
|
};
|
708
670
|
|
709
671
|
|
@@ -721,7 +683,8 @@ webdriver.WebDriver.prototype.executeScript = function(script, var_args) {
|
|
721
683
|
webdriver.WebDriver.wrapScriptArgument_);
|
722
684
|
return this.callFunction(function() {
|
723
685
|
this.addCommand(webdriver.CommandName.EXECUTE_SCRIPT).
|
724
|
-
|
686
|
+
setParameter("script", script).
|
687
|
+
setParameter("args", args);
|
725
688
|
return this.callFunction(function(prevResult) {
|
726
689
|
return this.unwrapScriptResult_(prevResult);
|
727
690
|
}, this);
|
@@ -736,7 +699,7 @@ webdriver.WebDriver.prototype.executeScript = function(script, var_args) {
|
|
736
699
|
webdriver.WebDriver.prototype.get = function(url) {
|
737
700
|
this.callFunction(function() {
|
738
701
|
this.addCommand(webdriver.CommandName.GET).
|
739
|
-
|
702
|
+
setParameter('url', url.toString());
|
740
703
|
}, this);
|
741
704
|
};
|
742
705
|
|
@@ -745,7 +708,7 @@ webdriver.WebDriver.prototype.get = function(url) {
|
|
745
708
|
* Navigate backwards in the current browser window's history.
|
746
709
|
*/
|
747
710
|
webdriver.WebDriver.prototype.back = function() {
|
748
|
-
this.addCommand(webdriver.CommandName.
|
711
|
+
this.addCommand(webdriver.CommandName.GO_BACK);
|
749
712
|
};
|
750
713
|
|
751
714
|
|
@@ -753,7 +716,7 @@ webdriver.WebDriver.prototype.back = function() {
|
|
753
716
|
* Navigate forwards in the current browser window's history.
|
754
717
|
*/
|
755
718
|
webdriver.WebDriver.prototype.forward = function() {
|
756
|
-
this.addCommand(webdriver.CommandName.
|
719
|
+
this.addCommand(webdriver.CommandName.GO_FORWARD);
|
757
720
|
};
|
758
721
|
|
759
722
|
|
@@ -796,9 +759,14 @@ webdriver.WebDriver.prototype.getTitle = function() {
|
|
796
759
|
webdriver.WebDriver.prototype.findElement = function(by) {
|
797
760
|
var webElement = new webdriver.WebElement(this);
|
798
761
|
var locator = webdriver.By.Locator.checkLocator(by);
|
799
|
-
|
800
|
-
|
801
|
-
|
762
|
+
this.callFunction(function() {
|
763
|
+
var command = this.addCommand(webdriver.CommandName.FIND_ELEMENT).
|
764
|
+
setParameter("using", locator.type).
|
765
|
+
setParameter("value", locator.target);
|
766
|
+
this.callFunction(function(id) {
|
767
|
+
webElement.getId().setValue(id['ELEMENT']);
|
768
|
+
});
|
769
|
+
}, this);
|
802
770
|
return webElement;
|
803
771
|
};
|
804
772
|
|
@@ -816,7 +784,8 @@ webdriver.WebDriver.prototype.isElementPresent = function(by) {
|
|
816
784
|
var locator = webdriver.By.Locator.checkLocator(by);
|
817
785
|
return this.callFunction(function() {
|
818
786
|
var findCommand = this.addCommand(webdriver.CommandName.FIND_ELEMENT).
|
819
|
-
|
787
|
+
setParameter("using", locator.type).
|
788
|
+
setParameter("value", locator.target);
|
820
789
|
var commandFailed = false;
|
821
790
|
var key = goog.events.listenOnce(findCommand,
|
822
791
|
webdriver.Command.ERROR_EVENT, function(e) {
|
@@ -853,13 +822,14 @@ webdriver.WebDriver.prototype.findElements = function(by) {
|
|
853
822
|
var locator = webdriver.By.Locator.checkLocator(by);
|
854
823
|
return this.callFunction(function() {
|
855
824
|
this.addCommand(webdriver.CommandName.FIND_ELEMENTS).
|
856
|
-
|
825
|
+
setParameter("using", locator.type).
|
826
|
+
setParameter("value", locator.target);
|
857
827
|
return this.callFunction(function(ids) {
|
858
828
|
var elements = [];
|
859
829
|
for (var i = 0; i < ids.length; i++) {
|
860
830
|
if (ids[i]) {
|
861
831
|
var element = new webdriver.WebElement(this);
|
862
|
-
element.getId().setValue(ids[i]);
|
832
|
+
element.getId().setValue(ids[i]['ELEMENT']);
|
863
833
|
elements.push(element);
|
864
834
|
}
|
865
835
|
}
|
@@ -870,21 +840,21 @@ webdriver.WebDriver.prototype.findElements = function(by) {
|
|
870
840
|
|
871
841
|
|
872
842
|
/**
|
873
|
-
* Adjust the speed of
|
843
|
+
* Adjust the speed of user input.
|
874
844
|
* @param {webdriver.WebDriver.Speed} speed The new speed setting.
|
875
845
|
*/
|
876
|
-
webdriver.WebDriver.prototype.
|
877
|
-
this.addCommand(webdriver.CommandName.
|
878
|
-
|
846
|
+
webdriver.WebDriver.prototype.setSpeed = function(speed) {
|
847
|
+
this.addCommand(webdriver.CommandName.SET_SPEED).
|
848
|
+
setParameter("speed", speed);
|
879
849
|
};
|
880
850
|
|
881
851
|
|
882
852
|
/**
|
883
|
-
* Fetch the current
|
853
|
+
* Fetch the current user input speed.
|
884
854
|
* @return {webdriver.Future} A Future whose value will be set by this driver
|
885
855
|
* when the query command completes.
|
886
856
|
*/
|
887
|
-
webdriver.WebDriver.prototype.
|
888
|
-
return this.addCommand(webdriver.CommandName.
|
857
|
+
webdriver.WebDriver.prototype.getSpeed = function() {
|
858
|
+
return this.addCommand(webdriver.CommandName.GET_SPEED).
|
889
859
|
getFutureResult();
|
890
860
|
};
|
data/common/src/js/webelement.js
CHANGED
@@ -77,13 +77,10 @@ webdriver.WebElement = function(driver) {
|
|
77
77
|
webdriver.WebElement.prototype.isElementPresent = function(locator) {
|
78
78
|
locator = webdriver.By.Locator.checkLocator(locator);
|
79
79
|
return this.driver_.callFunction(function() {
|
80
|
-
var findCommand = this.
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
'using': locator.type,
|
85
|
-
'value': locator.target
|
86
|
-
});
|
80
|
+
var findCommand = this.
|
81
|
+
createCommand_(webdriver.CommandName.FIND_CHILD_ELEMENT).
|
82
|
+
setParameter('using', locator.type).
|
83
|
+
setParameter('value', locator.target);
|
87
84
|
var commandFailed = false;
|
88
85
|
var key = goog.events.listenOnce(findCommand,
|
89
86
|
webdriver.Command.ERROR_EVENT, function(e) {
|
@@ -115,14 +112,15 @@ webdriver.WebElement.prototype.isElementPresent = function(locator) {
|
|
115
112
|
webdriver.WebElement.prototype.findElement = function(locator) {
|
116
113
|
var webElement = new webdriver.WebElement(this.driver_);
|
117
114
|
locator = webdriver.By.Locator.checkLocator(locator);
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
'
|
122
|
-
'
|
123
|
-
|
124
|
-
|
125
|
-
|
115
|
+
this.driver_.callFunction(function() {
|
116
|
+
var command = this.
|
117
|
+
createCommand_(webdriver.CommandName.FIND_CHILD_ELEMENT).
|
118
|
+
setParameter('using', locator.type).
|
119
|
+
setParameter('value', locator.target);
|
120
|
+
this.driver_.callFunction(function(id) {
|
121
|
+
webElement.getId().setValue(id['ELEMENT']);
|
122
|
+
});
|
123
|
+
}, this);
|
126
124
|
return webElement;
|
127
125
|
};
|
128
126
|
|
@@ -138,18 +136,15 @@ webdriver.WebElement.prototype.findElement = function(locator) {
|
|
138
136
|
webdriver.WebElement.prototype.findElements = function(locator) {
|
139
137
|
locator = webdriver.By.Locator.checkLocator(locator);
|
140
138
|
this.driver_.callFunction(function() {
|
141
|
-
this.
|
142
|
-
|
143
|
-
|
144
|
-
'using': locator.type,
|
145
|
-
'value': locator.target
|
146
|
-
});
|
139
|
+
this.createCommand_(webdriver.CommandName.FIND_CHILD_ELEMENTS).
|
140
|
+
setParameter('using', locator.type).
|
141
|
+
setParameter('value', locator.target);
|
147
142
|
return this.driver_.callFunction(function(ids) {
|
148
143
|
var elements = [];
|
149
144
|
for (var i = 0; i < ids.length; i++) {
|
150
145
|
if (ids[i]) {
|
151
146
|
var element = new webdriver.WebElement(this.driver_);
|
152
|
-
element.getId().setValue(ids[i]);
|
147
|
+
element.getId().setValue(ids[i]['ELEMENT']);
|
153
148
|
elements.push(element);
|
154
149
|
}
|
155
150
|
}
|
@@ -184,7 +179,7 @@ webdriver.WebElement.prototype.getId = function() {
|
|
184
179
|
* @private
|
185
180
|
*/
|
186
181
|
webdriver.WebElement.prototype.createCommand_ = function(name) {
|
187
|
-
return this.driver_.addCommand(name, this);
|
182
|
+
return this.driver_.addCommand(name).setParameter('id', this.getId());
|
188
183
|
};
|
189
184
|
|
190
185
|
|
@@ -192,7 +187,7 @@ webdriver.WebElement.prototype.createCommand_ = function(name) {
|
|
192
187
|
* Adds a command to click on this element.
|
193
188
|
*/
|
194
189
|
webdriver.WebElement.prototype.click = function() {
|
195
|
-
this.createCommand_(webdriver.CommandName.
|
190
|
+
this.createCommand_(webdriver.CommandName.CLICK_ELEMENT);
|
196
191
|
};
|
197
192
|
|
198
193
|
|
@@ -246,15 +241,16 @@ webdriver.WebElement.prototype.click = function() {
|
|
246
241
|
* convenience).
|
247
242
|
*/
|
248
243
|
webdriver.WebElement.prototype.sendKeys = function(var_args) {
|
249
|
-
var command = this.createCommand_(
|
250
|
-
|
244
|
+
var command = this.createCommand_(
|
245
|
+
webdriver.CommandName.SEND_KEYS_TO_ELEMENT);
|
246
|
+
command.setParameter('value', goog.array.slice(arguments, 0));
|
251
247
|
};
|
252
248
|
|
253
249
|
/**
|
254
250
|
* Queries for the tag/node name of this element.
|
255
251
|
*/
|
256
252
|
webdriver.WebElement.prototype.getTagName = function() {
|
257
|
-
return this.createCommand_(webdriver.CommandName.
|
253
|
+
return this.createCommand_(webdriver.CommandName.GET_ELEMENT_TAG_NAME).
|
258
254
|
getFutureResult();
|
259
255
|
};
|
260
256
|
|
@@ -272,8 +268,9 @@ webdriver.WebElement.prototype.getTagName = function() {
|
|
272
268
|
* Future.
|
273
269
|
*/
|
274
270
|
webdriver.WebElement.prototype.getComputedStyle = function(cssStyleProperty) {
|
275
|
-
return this.createCommand_(
|
276
|
-
|
271
|
+
return this.createCommand_(
|
272
|
+
webdriver.CommandName.GET_ELEMENT_VALUE_OF_CSS_PROPERTY).
|
273
|
+
setParameter('propertyName', cssStyleProperty).
|
277
274
|
getFutureResult();
|
278
275
|
};
|
279
276
|
|
@@ -283,8 +280,8 @@ webdriver.WebElement.prototype.getComputedStyle = function(cssStyleProperty) {
|
|
283
280
|
* @param {string} attributeName The name of the attribute to query.
|
284
281
|
*/
|
285
282
|
webdriver.WebElement.prototype.getAttribute = function(attributeName) {
|
286
|
-
return this.createCommand_(webdriver.CommandName.
|
287
|
-
|
283
|
+
return this.createCommand_(webdriver.CommandName.GET_ELEMENT_ATTRIBUTE).
|
284
|
+
setParameter('name', attributeName).
|
288
285
|
getFutureResult();
|
289
286
|
};
|
290
287
|
|
@@ -294,7 +291,7 @@ webdriver.WebElement.prototype.getAttribute = function(attributeName) {
|
|
294
291
|
* this instance.
|
295
292
|
*/
|
296
293
|
webdriver.WebElement.prototype.getValue = function() {
|
297
|
-
return this.createCommand_(webdriver.CommandName.
|
294
|
+
return this.createCommand_(webdriver.CommandName.GET_ELEMENT_VALUE).
|
298
295
|
getFutureResult();
|
299
296
|
};
|
300
297
|
|
@@ -304,7 +301,7 @@ webdriver.WebElement.prototype.getValue = function() {
|
|
304
301
|
* or trailing whitespace.
|
305
302
|
*/
|
306
303
|
webdriver.WebElement.prototype.getText = function() {
|
307
|
-
return this.createCommand_(webdriver.CommandName.
|
304
|
+
return this.createCommand_(webdriver.CommandName.GET_ELEMENT_TEXT).
|
308
305
|
getFutureResult();
|
309
306
|
};
|
310
307
|
|
@@ -313,7 +310,7 @@ webdriver.WebElement.prototype.getText = function() {
|
|
313
310
|
* Selects this element.
|
314
311
|
*/
|
315
312
|
webdriver.WebElement.prototype.setSelected = function() {
|
316
|
-
this.createCommand_(webdriver.CommandName.
|
313
|
+
this.createCommand_(webdriver.CommandName.SET_ELEMENT_SELECTED);
|
317
314
|
};
|
318
315
|
|
319
316
|
|
@@ -321,7 +318,7 @@ webdriver.WebElement.prototype.setSelected = function() {
|
|
321
318
|
* @return {webdriver.Future} The size of this element.
|
322
319
|
*/
|
323
320
|
webdriver.WebElement.prototype.getSize = function() {
|
324
|
-
return this.createCommand_(webdriver.CommandName.
|
321
|
+
return this.createCommand_(webdriver.CommandName.GET_ELEMENT_SIZE).
|
325
322
|
getFutureResult();
|
326
323
|
};
|
327
324
|
|
@@ -330,7 +327,7 @@ webdriver.WebElement.prototype.getSize = function() {
|
|
330
327
|
* @return {webdriver.Future} The location of this element.
|
331
328
|
*/
|
332
329
|
webdriver.WebElement.prototype.getLocation = function() {
|
333
|
-
return this.createCommand_(webdriver.CommandName.
|
330
|
+
return this.createCommand_(webdriver.CommandName.GET_ELEMENT_LOCATION).
|
334
331
|
getFutureResult();
|
335
332
|
};
|
336
333
|
|
@@ -343,7 +340,8 @@ webdriver.WebElement.prototype.getLocation = function() {
|
|
343
340
|
*/
|
344
341
|
webdriver.WebElement.prototype.dragAndDropBy = function(x, y) {
|
345
342
|
return this.createCommand_(webdriver.CommandName.DRAG_ELEMENT).
|
346
|
-
|
343
|
+
setParameter('x', x).
|
344
|
+
setParameter('y', y).
|
347
345
|
getFutureResult();
|
348
346
|
};
|
349
347
|
|
@@ -394,7 +392,7 @@ webdriver.WebElement.prototype.isEnabled = function() {
|
|
394
392
|
*/
|
395
393
|
webdriver.WebElement.prototype.isCheckedOrSelected_ = function() {
|
396
394
|
return this.driver_.callFunction(function() {
|
397
|
-
this.createCommand_(webdriver.CommandName.
|
395
|
+
this.createCommand_(webdriver.CommandName.GET_ELEMENT_TAG_NAME);
|
398
396
|
return this.driver_.callFunction(function(prevResult) {
|
399
397
|
var attribute = prevResult == 'input' ? 'checked' : 'selected';
|
400
398
|
return this.getAttribute(attribute);
|
@@ -427,7 +425,7 @@ webdriver.WebElement.prototype.isChecked = function() {
|
|
427
425
|
*/
|
428
426
|
webdriver.WebElement.prototype.toggle = function() {
|
429
427
|
return this.driver_.callFunction(function() {
|
430
|
-
this.createCommand_(webdriver.CommandName.
|
428
|
+
this.createCommand_(webdriver.CommandName.TOGGLE_ELEMENT);
|
431
429
|
return this.isCheckedOrSelected_();
|
432
430
|
}, this);
|
433
431
|
};
|
@@ -438,7 +436,7 @@ webdriver.WebElement.prototype.toggle = function() {
|
|
438
436
|
* will that form.
|
439
437
|
*/
|
440
438
|
webdriver.WebElement.prototype.submit = function() {
|
441
|
-
this.createCommand_(webdriver.CommandName.
|
439
|
+
this.createCommand_(webdriver.CommandName.SUBMIT_ELEMENT);
|
442
440
|
};
|
443
441
|
|
444
442
|
|
@@ -447,7 +445,7 @@ webdriver.WebElement.prototype.submit = function() {
|
|
447
445
|
* will clear its {@code value}.
|
448
446
|
*/
|
449
447
|
webdriver.WebElement.prototype.clear = function() {
|
450
|
-
this.createCommand_(webdriver.CommandName.
|
448
|
+
this.createCommand_(webdriver.CommandName.CLEAR_ELEMENT);
|
451
449
|
};
|
452
450
|
|
453
451
|
|
@@ -455,7 +453,7 @@ webdriver.WebElement.prototype.clear = function() {
|
|
455
453
|
* @return {webdriver.Future} Whether this element is currently displayed.
|
456
454
|
*/
|
457
455
|
webdriver.WebElement.prototype.isDisplayed = function() {
|
458
|
-
return this.createCommand_(webdriver.CommandName.
|
456
|
+
return this.createCommand_(webdriver.CommandName.IS_ELEMENT_DISPLAYED).
|
459
457
|
getFutureResult();
|
460
458
|
};
|
461
459
|
|