selenium-webdriver 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- data/{common/src/rb/CHANGES → CHANGES} +13 -0
- data/{common/src/rb/README → README} +1 -1
- data/{common/src/rb/lib → lib}/selenium-webdriver.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver.rb +2 -1
- data/{common/src/rb/lib → lib}/selenium/webdriver/bridge_helper.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/child_process.rb +0 -0
- data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome.rb +0 -0
- data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/bridge.rb +2 -2
- data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/command_executor.rb +0 -0
- data/lib/selenium/webdriver/chrome/extension.zip +0 -0
- data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/launcher.rb +26 -20
- data/{common/src/rb/lib → lib}/selenium/webdriver/core_ext/dir.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/core_ext/string.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/driver.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/driver_extensions/takes_screenshot.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/element.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/error.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/file_reaper.rb +2 -1
- data/{common/src/rb/lib → lib}/selenium/webdriver/find.rb +0 -0
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox.rb +2 -1
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/binary.rb +32 -6
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/bridge.rb +0 -0
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/launcher.rb +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/profile.rb +37 -72
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/profiles_ini.rb +0 -0
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/util.rb +0 -0
- data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie.rb +2 -2
- data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/bridge.rb +7 -2
- data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/lib.rb +0 -0
- data/{jobbie/prebuilt/Win32/Release → lib/selenium/webdriver/ie/native/win32}/InternetExplorerDriver.dll +0 -0
- data/lib/selenium/webdriver/ie/native/x64/InternetExplorerDriver.dll +0 -0
- data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/util.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/keys.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/navigation.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/options.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/platform.rb +5 -1
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/bridge.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/capabilities.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/commands.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/common.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/curb.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/default.rb +5 -1
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/response.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/server_error.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/target_locator.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/timeouts.rb +0 -0
- data/lib/selenium/webdriver/zip_helper.rb +30 -0
- metadata +73 -214
- data/COPYING +0 -204
- data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
- data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
- data/chrome/src/extension/background.html +0 -9
- data/chrome/src/extension/background.js +0 -1029
- data/chrome/src/extension/content_script.js +0 -1488
- data/chrome/src/extension/icons/busy.png +0 -0
- data/chrome/src/extension/icons/free.png +0 -0
- data/chrome/src/extension/manifest-nonwin.json +0 -19
- data/chrome/src/extension/manifest-win.json +0 -20
- data/chrome/src/extension/utils.js +0 -231
- data/common/src/js/abstractcommandprocessor.js +0 -132
- data/common/src/js/asserts.js +0 -296
- data/common/src/js/by.js +0 -149
- data/common/src/js/command.js +0 -380
- data/common/src/js/core/Blank.html +0 -7
- data/common/src/js/core/InjectedRemoteRunner.html +0 -8
- data/common/src/js/core/RemoteRunner.html +0 -101
- data/common/src/js/core/SeleniumLog.html +0 -109
- data/common/src/js/core/TestPrompt.html +0 -145
- data/common/src/js/core/TestRunner-splash.html +0 -55
- data/common/src/js/core/TestRunner.html +0 -165
- data/common/src/js/core/icons/all.png +0 -0
- data/common/src/js/core/icons/continue.png +0 -0
- data/common/src/js/core/icons/continue_disabled.png +0 -0
- data/common/src/js/core/icons/pause.png +0 -0
- data/common/src/js/core/icons/pause_disabled.png +0 -0
- data/common/src/js/core/icons/selected.png +0 -0
- data/common/src/js/core/icons/step.png +0 -0
- data/common/src/js/core/icons/step_disabled.png +0 -0
- data/common/src/js/core/lib/cssQuery/cssQuery-p.js +0 -6
- data/common/src/js/core/lib/cssQuery/src/cssQuery-level2.js +0 -142
- data/common/src/js/core/lib/cssQuery/src/cssQuery-level3.js +0 -150
- data/common/src/js/core/lib/cssQuery/src/cssQuery-standard.js +0 -53
- data/common/src/js/core/lib/cssQuery/src/cssQuery.js +0 -356
- data/common/src/js/core/lib/prototype.js +0 -2006
- data/common/src/js/core/lib/scriptaculous/builder.js +0 -101
- data/common/src/js/core/lib/scriptaculous/controls.js +0 -815
- data/common/src/js/core/lib/scriptaculous/dragdrop.js +0 -915
- data/common/src/js/core/lib/scriptaculous/effects.js +0 -958
- data/common/src/js/core/lib/scriptaculous/scriptaculous.js +0 -47
- data/common/src/js/core/lib/scriptaculous/slider.js +0 -283
- data/common/src/js/core/lib/scriptaculous/unittest.js +0 -383
- data/common/src/js/core/lib/snapsie.js +0 -91
- data/common/src/js/core/scripts/find_matching_child.js +0 -69
- data/common/src/js/core/scripts/htmlutils.js +0 -8716
- data/common/src/js/core/scripts/injection.html +0 -72
- data/common/src/js/core/scripts/selenium-api.js +0 -3291
- data/common/src/js/core/scripts/selenium-browserbot.js +0 -2457
- data/common/src/js/core/scripts/selenium-browserdetect.js +0 -153
- data/common/src/js/core/scripts/selenium-commandhandlers.js +0 -379
- data/common/src/js/core/scripts/selenium-executionloop.js +0 -175
- data/common/src/js/core/scripts/selenium-logging.js +0 -148
- data/common/src/js/core/scripts/selenium-remoterunner.js +0 -695
- data/common/src/js/core/scripts/selenium-testrunner.js +0 -1362
- data/common/src/js/core/scripts/selenium-version.js +0 -5
- data/common/src/js/core/scripts/ui-doc.html +0 -808
- data/common/src/js/core/scripts/ui-element.js +0 -1644
- data/common/src/js/core/scripts/ui-map-sample.js +0 -979
- data/common/src/js/core/scripts/user-extensions.js +0 -3
- data/common/src/js/core/scripts/user-extensions.js.sample +0 -75
- data/common/src/js/core/scripts/xmlextras.js +0 -153
- data/common/src/js/core/selenium-logo.png +0 -0
- data/common/src/js/core/selenium-test.css +0 -43
- data/common/src/js/core/selenium.css +0 -316
- data/common/src/js/core/xpath/dom.js +0 -566
- data/common/src/js/core/xpath/javascript-xpath-0.1.11.js +0 -2816
- data/common/src/js/core/xpath/util.js +0 -549
- data/common/src/js/core/xpath/xmltoken.js +0 -149
- data/common/src/js/core/xpath/xpath.js +0 -2481
- data/common/src/js/extension/README +0 -2
- data/common/src/js/extension/dommessenger.js +0 -152
- data/common/src/js/factory.js +0 -55
- data/common/src/js/future.js +0 -141
- data/common/src/js/jsunit.js +0 -40
- data/common/src/js/jsunit/app/css/jsUnitStyle.css +0 -50
- data/common/src/js/jsunit/app/css/readme +0 -10
- data/common/src/js/jsunit/app/emptyPage.html +0 -11
- data/common/src/js/jsunit/app/jsUnitCore.js +0 -534
- data/common/src/js/jsunit/app/jsUnitMockTimeout.js +0 -81
- data/common/src/js/jsunit/app/jsUnitTestManager.js +0 -705
- data/common/src/js/jsunit/app/jsUnitTestSuite.js +0 -44
- data/common/src/js/jsunit/app/jsUnitTracer.js +0 -102
- data/common/src/js/jsunit/app/jsUnitVersionCheck.js +0 -59
- data/common/src/js/jsunit/app/main-counts-errors.html +0 -12
- data/common/src/js/jsunit/app/main-counts-failures.html +0 -13
- data/common/src/js/jsunit/app/main-counts-runs.html +0 -13
- data/common/src/js/jsunit/app/main-counts.html +0 -21
- data/common/src/js/jsunit/app/main-data.html +0 -178
- data/common/src/js/jsunit/app/main-errors.html +0 -23
- data/common/src/js/jsunit/app/main-frame.html +0 -19
- data/common/src/js/jsunit/app/main-loader.html +0 -45
- data/common/src/js/jsunit/app/main-progress.html +0 -25
- data/common/src/js/jsunit/app/main-results.html +0 -67
- data/common/src/js/jsunit/app/main-status.html +0 -13
- data/common/src/js/jsunit/app/testContainer.html +0 -16
- data/common/src/js/jsunit/app/testContainerController.html +0 -77
- data/common/src/js/jsunit/app/xbDebug.js +0 -306
- data/common/src/js/jsunit/changelog.txt +0 -60
- data/common/src/js/jsunit/css/jsUnitStyle.css +0 -83
- data/common/src/js/jsunit/images/green.gif +0 -0
- data/common/src/js/jsunit/images/logo_jsunit.gif +0 -0
- data/common/src/js/jsunit/images/powerby-transparent.gif +0 -0
- data/common/src/js/jsunit/images/red.gif +0 -0
- data/common/src/js/jsunit/licenses/JDOM_license.txt +0 -56
- data/common/src/js/jsunit/licenses/Jetty_license.html +0 -213
- data/common/src/js/jsunit/licenses/MPL-1.1.txt +0 -470
- data/common/src/js/jsunit/licenses/gpl-2.txt +0 -340
- data/common/src/js/jsunit/licenses/index.html +0 -141
- data/common/src/js/jsunit/licenses/lgpl-2.1.txt +0 -504
- data/common/src/js/jsunit/licenses/mpl-tri-license-c.txt +0 -35
- data/common/src/js/jsunit/licenses/mpl-tri-license-html.txt +0 -35
- data/common/src/js/jsunit/readme.txt +0 -19
- data/common/src/js/jsunit/testRunner.html +0 -167
- data/common/src/js/jsunit/version.txt +0 -1
- data/common/src/js/key.js +0 -117
- data/common/src/js/localcommandprocessor.js +0 -171
- data/common/src/js/testcase.js +0 -219
- data/common/src/js/timing.js +0 -89
- data/common/src/js/webdriver.js +0 -860
- data/common/src/js/webelement.js +0 -483
- data/firefox/prebuilt/Win32/Release/webdriver-firefox.dll +0 -0
- data/firefox/prebuilt/amd64/libnoblur64.so +0 -0
- data/firefox/prebuilt/i386/libnoblur.so +0 -0
- data/firefox/prebuilt/linux/Release/libwebdriver-firefox.so +0 -0
- data/firefox/prebuilt/linux64/Release/libwebdriver-firefox.so +0 -0
- data/firefox/prebuilt/nsICommandProcessor.xpt +0 -0
- data/firefox/prebuilt/nsINativeEvents.xpt +0 -0
- data/firefox/prebuilt/nsIResponseHandler.xpt +0 -0
- data/firefox/src/extension/chrome.manifest +0 -3
- data/firefox/src/extension/components/badCertListener.js +0 -295
- data/firefox/src/extension/components/dispatcher.js +0 -495
- data/firefox/src/extension/components/driver-component.js +0 -130
- data/firefox/src/extension/components/errorcode.js +0 -70
- data/firefox/src/extension/components/firefoxDriver.js +0 -831
- data/firefox/src/extension/components/json2.js +0 -273
- data/firefox/src/extension/components/keytest.html +0 -554
- data/firefox/src/extension/components/nsCommandProcessor.js +0 -684
- data/firefox/src/extension/components/promptService.js +0 -208
- data/firefox/src/extension/components/request.js +0 -219
- data/firefox/src/extension/components/response.js +0 -276
- data/firefox/src/extension/components/screenshooter.js +0 -81
- data/firefox/src/extension/components/session.js +0 -314
- data/firefox/src/extension/components/sessionstore.js +0 -226
- data/firefox/src/extension/components/socketListener.js +0 -435
- data/firefox/src/extension/components/utils.js +0 -1335
- data/firefox/src/extension/components/webLoadingListener.js +0 -57
- data/firefox/src/extension/components/webdriverserver.js +0 -110
- data/firefox/src/extension/components/wrappedElement.js +0 -706
- data/firefox/src/extension/content/fxdriver.xul +0 -30
- data/firefox/src/extension/content/server.js +0 -95
- data/firefox/src/extension/idl/nsICommandProcessor.idl +0 -38
- data/firefox/src/extension/idl/nsIResponseHandler.idl +0 -34
- data/firefox/src/extension/install.rdf +0 -29
- data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
@@ -1,57 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Copyright 2007-2009 WebDriver committers
|
3
|
-
Copyright 2007-2009 Google Inc.
|
4
|
-
Portions copyright 2007 ThoughtWorks, Inc
|
5
|
-
|
6
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
you may not use this file except in compliance with the License.
|
8
|
-
You may obtain a copy of the License at
|
9
|
-
|
10
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
|
12
|
-
Unless required by applicable law or agreed to in writing, software
|
13
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
See the License for the specific language governing permissions and
|
16
|
-
limitations under the License.
|
17
|
-
*/
|
18
|
-
|
19
|
-
var STATE_START = Components.interfaces.nsIWebProgressListener.STATE_START;
|
20
|
-
var STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP;
|
21
|
-
|
22
|
-
function WebLoadingListener(browser, toCall) {
|
23
|
-
var listener = this;
|
24
|
-
|
25
|
-
this.handler = {
|
26
|
-
QueryInterface: function(iid) {
|
27
|
-
if (iid.equals(Components.interfaces.nsIWebProgressListener) ||
|
28
|
-
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
|
29
|
-
iid.equals(Components.interfaces.nsISupports))
|
30
|
-
return this;
|
31
|
-
throw Components.results.NS_NOINTERFACE;
|
32
|
-
},
|
33
|
-
|
34
|
-
onStateChange: function(webProgress, request, flags, status) {
|
35
|
-
if (flags & STATE_STOP) {
|
36
|
-
if (request.URI) {
|
37
|
-
WebLoadingListener.removeListener(browser, listener);
|
38
|
-
toCall();
|
39
|
-
}
|
40
|
-
}
|
41
|
-
return 0;
|
42
|
-
},
|
43
|
-
|
44
|
-
onLocationChange: function(aProgress, aRequest, aURI) { return 0; },
|
45
|
-
onProgressChange: function() { return 0; },
|
46
|
-
onStatusChange: function() { return 0; },
|
47
|
-
onSecurityChange: function() { return 0; },
|
48
|
-
onLinkIconAvailable: function() { return 0; }
|
49
|
-
};
|
50
|
-
|
51
|
-
browser.addProgressListener(this.handler,
|
52
|
-
Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
|
53
|
-
}
|
54
|
-
|
55
|
-
WebLoadingListener.removeListener = function(browser, listener) {
|
56
|
-
browser.removeProgressListener(listener.handler);
|
57
|
-
};
|
@@ -1,110 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Copyright 2007-2009 WebDriver committers
|
3
|
-
Copyright 2007-2009 Google Inc.
|
4
|
-
Portions copyright 2007 ThoughtWorks, Inc
|
5
|
-
|
6
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
you may not use this file except in compliance with the License.
|
8
|
-
You may obtain a copy of the License at
|
9
|
-
|
10
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
|
12
|
-
Unless required by applicable law or agreed to in writing, software
|
13
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
See the License for the specific language governing permissions and
|
16
|
-
limitations under the License.
|
17
|
-
*/
|
18
|
-
|
19
|
-
|
20
|
-
function WebDriverServer() {
|
21
|
-
this.wrappedJSObject = this;
|
22
|
-
this.serverSocket =
|
23
|
-
Components.classes["@mozilla.org/network/server-socket;1"].
|
24
|
-
createInstance(Components.interfaces.nsIServerSocket);
|
25
|
-
this.generator = Utils.getService("@mozilla.org/uuid-generator;1", "nsIUUIDGenerator");
|
26
|
-
this.enableNativeEvents = null;
|
27
|
-
|
28
|
-
// Force our cert override service to be loaded - otherwise, it will not be
|
29
|
-
// loaded and cause a "too deep recursion" error.
|
30
|
-
var overrideService = Components.classes["@mozilla.org/security/certoverride;1"]
|
31
|
-
.getService(Components.interfaces.nsICertOverrideService);
|
32
|
-
|
33
|
-
/**
|
34
|
-
* This server's request dispatcher.
|
35
|
-
* @type {Dispatcher}
|
36
|
-
* @private
|
37
|
-
*/
|
38
|
-
this.dispatcher_ = new Dispatcher();
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
WebDriverServer.prototype.newDriver = function(window) {
|
43
|
-
if (null == this.useNativeEvents) {
|
44
|
-
var prefs =
|
45
|
-
Utils.getService("@mozilla.org/preferences-service;1", "nsIPrefBranch");
|
46
|
-
if (!prefs.prefHasUserValue("webdriver_enable_native_events")) {
|
47
|
-
Utils.dumpn('webdriver_enable_native_events not set; defaulting to false');
|
48
|
-
}
|
49
|
-
this.enableNativeEvents =
|
50
|
-
prefs.prefHasUserValue("webdriver_enable_native_events") ?
|
51
|
-
prefs.getBoolPref("webdriver_enable_native_events") : false;
|
52
|
-
Utils.dumpn('Enable native events: ' + this.enableNativeEvents);
|
53
|
-
}
|
54
|
-
window.fxdriver = new FirefoxDriver(this, this.enableNativeEvents, window);
|
55
|
-
return window.fxdriver;
|
56
|
-
};
|
57
|
-
|
58
|
-
|
59
|
-
WebDriverServer.prototype.getNextId = function() {
|
60
|
-
return this.generator.generateUUID().toString();
|
61
|
-
};
|
62
|
-
|
63
|
-
|
64
|
-
WebDriverServer.prototype.onSocketAccepted = function(socket, transport) {
|
65
|
-
try {
|
66
|
-
var socketListener = new SocketListener(this.dispatcher_, transport);
|
67
|
-
} catch(e) {
|
68
|
-
dump(e);
|
69
|
-
}
|
70
|
-
};
|
71
|
-
|
72
|
-
|
73
|
-
WebDriverServer.prototype.startListening = function(port) {
|
74
|
-
if (!port) {
|
75
|
-
var prefs =
|
76
|
-
Utils.getService("@mozilla.org/preferences-service;1", "nsIPrefBranch");
|
77
|
-
|
78
|
-
port = prefs.prefHasUserValue("webdriver_firefox_port") ?
|
79
|
-
prefs.getIntPref("webdriver_firefox_port") : 7055;
|
80
|
-
}
|
81
|
-
|
82
|
-
if (!this.isListening) {
|
83
|
-
this.serverSocket.init(port, true, -1);
|
84
|
-
this.serverSocket.asyncListen(this);
|
85
|
-
this.isListening = true;
|
86
|
-
}
|
87
|
-
};
|
88
|
-
|
89
|
-
|
90
|
-
WebDriverServer.prototype.onStopListening = function(socket, status)
|
91
|
-
{
|
92
|
-
};
|
93
|
-
|
94
|
-
|
95
|
-
WebDriverServer.prototype.close = function()
|
96
|
-
{
|
97
|
-
};
|
98
|
-
|
99
|
-
|
100
|
-
WebDriverServer.prototype.QueryInterface = function(aIID) {
|
101
|
-
if (!aIID.equals(nsISupports))
|
102
|
-
throw Components.results.NS_ERROR_NO_INTERFACE;
|
103
|
-
return this;
|
104
|
-
};
|
105
|
-
|
106
|
-
|
107
|
-
WebDriverServer.prototype.createInstance = function(ignore1, ignore2, ignore3) {
|
108
|
-
var port = WebDriverServer.readPort();
|
109
|
-
this.startListening(port);
|
110
|
-
};
|
@@ -1,706 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Copyright 2007-2009 WebDriver committers
|
3
|
-
Copyright 2007-2009 Google Inc.
|
4
|
-
Portions copyright 2007 ThoughtWorks, Inc
|
5
|
-
|
6
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
you may not use this file except in compliance with the License.
|
8
|
-
You may obtain a copy of the License at
|
9
|
-
|
10
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
|
12
|
-
Unless required by applicable law or agreed to in writing, software
|
13
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
See the License for the specific language governing permissions and
|
16
|
-
limitations under the License.
|
17
|
-
*/
|
18
|
-
|
19
|
-
|
20
|
-
FirefoxDriver.prototype.elementEquals = function(respond, parameters) {
|
21
|
-
var elementA = Utils.getElementAt(parameters.id,
|
22
|
-
respond.session.getDocument());
|
23
|
-
var elementB = Utils.getElementAt(parameters.other,
|
24
|
-
respond.session.getDocument());
|
25
|
-
respond.value = elementA == elementB;
|
26
|
-
respond.send();
|
27
|
-
};
|
28
|
-
|
29
|
-
|
30
|
-
FirefoxDriver.prototype.clickElement = function(respond, parameters) {
|
31
|
-
var element = Utils.getElementAt(parameters.id,
|
32
|
-
respond.session.getDocument());
|
33
|
-
|
34
|
-
if (!Utils.isDisplayed(element, true) && !Utils.isInHead(element)) {
|
35
|
-
throw new WebDriverError(ErrorCode.ELEMENT_NOT_VISIBLE,
|
36
|
-
"Element is not currently visible and so may not be clicked");
|
37
|
-
}
|
38
|
-
|
39
|
-
var nativeEvents = Utils.getNativeEvents();
|
40
|
-
var node = Utils.getNodeForNativeEvents(element);
|
41
|
-
var appInfo = Components.classes["@mozilla.org/xre/app-info;1"].
|
42
|
-
getService(Components.interfaces.nsIXULAppInfo);
|
43
|
-
var versionChecker = Components.
|
44
|
-
classes["@mozilla.org/xpcom/version-comparator;1"].
|
45
|
-
getService(Components.interfaces.nsIVersionComparator);
|
46
|
-
|
47
|
-
// I'm having trouble getting clicks to work on Firefox 2 on Windows. Always
|
48
|
-
// fall back for that
|
49
|
-
var useNativeClick =
|
50
|
-
versionChecker.compare(appInfo.platformVersion, "1.9") >= 0;
|
51
|
-
|
52
|
-
if (this.enableNativeEvents && nativeEvents && node && useNativeClick) {
|
53
|
-
Utils.dumpn("Using native events for click");
|
54
|
-
var loc = Utils.getLocationOnceScrolledIntoView(element);
|
55
|
-
var x = loc.x + (loc.width ? loc.width / 2 : 0);
|
56
|
-
var y = loc.y + (loc.height ? loc.height / 2 : 0);
|
57
|
-
|
58
|
-
// In Firefox 3.6 and above, there's a shared window handle. We need to calculate an offset
|
59
|
-
// to add to the x and y locations.
|
60
|
-
|
61
|
-
var appInfo = Components.classes['@mozilla.org/xre/app-info;1'].
|
62
|
-
getService(Components.interfaces.nsIXULAppInfo);
|
63
|
-
var versionChecker = Components.classes['@mozilla.org/xpcom/version-comparator;1'].
|
64
|
-
getService(Components.interfaces.nsIVersionComparator);
|
65
|
-
if (versionChecker.compare(appInfo.version, '3.6') >= 0) {
|
66
|
-
// Get the ultimate parent frame
|
67
|
-
var current = element.ownerDocument.defaultView;
|
68
|
-
var ultimateParent = element.ownerDocument.defaultView.parent;
|
69
|
-
while (ultimateParent != current) {
|
70
|
-
current = ultimateParent;
|
71
|
-
ultimateParent = current.parent;
|
72
|
-
}
|
73
|
-
var offX = element.ownerDocument.defaultView.mozInnerScreenX - ultimateParent.mozInnerScreenX;
|
74
|
-
var offY = element.ownerDocument.defaultView.mozInnerScreenY - ultimateParent.mozInnerScreenY;
|
75
|
-
|
76
|
-
x += offX;
|
77
|
-
y += offY;
|
78
|
-
}
|
79
|
-
|
80
|
-
try {
|
81
|
-
nativeEvents.mouseMove(node, this.currentX, this.currentY, x, y);
|
82
|
-
nativeEvents.click(node, x, y);
|
83
|
-
this.currentX = x;
|
84
|
-
this.currentY = y;
|
85
|
-
respond.send();
|
86
|
-
return;
|
87
|
-
} catch (e) {
|
88
|
-
// Make sure that we only fall through only if
|
89
|
-
// the error returned from the native call indicates it's not
|
90
|
-
// implemented.
|
91
|
-
|
92
|
-
Utils.dumpn("Detected error when clicking: " + e.name);
|
93
|
-
|
94
|
-
if (e.name != "NS_ERROR_NOT_IMPLEMENTED") {
|
95
|
-
throw new WebDriverError(ErrorCode.INVALID_ELEMENT_STATE, e);
|
96
|
-
}
|
97
|
-
|
98
|
-
// Fall through to the synthesized click code.
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
Utils.dumpn("Falling back to synthesized click");
|
103
|
-
var doc = respond.session.getDocument()
|
104
|
-
var currentlyActive = Utils.getActiveElement(doc);
|
105
|
-
|
106
|
-
Utils.fireMouseEventOn(element, "mouseover");
|
107
|
-
Utils.fireMouseEventOn(element, "mousemove");
|
108
|
-
Utils.fireMouseEventOn(element, "mousedown");
|
109
|
-
if (element != currentlyActive) {
|
110
|
-
// Some elements may not have blur, focus functions - for example,
|
111
|
-
// elements under an SVG element. Call those only if they exist.
|
112
|
-
if (typeof currentlyActive.blur == 'function') {
|
113
|
-
currentlyActive.blur();
|
114
|
-
}
|
115
|
-
if (typeof element.focus == 'function') {
|
116
|
-
element.focus();
|
117
|
-
}
|
118
|
-
}
|
119
|
-
|
120
|
-
Utils.fireMouseEventOn(element, "mouseup");
|
121
|
-
Utils.fireMouseEventOn(element, "click");
|
122
|
-
|
123
|
-
var browser = respond.session.getBrowser();
|
124
|
-
var alreadyReplied = false;
|
125
|
-
|
126
|
-
var clickListener = new WebLoadingListener(browser, function(event) {
|
127
|
-
if (!alreadyReplied) {
|
128
|
-
alreadyReplied = true;
|
129
|
-
respond.send();
|
130
|
-
}
|
131
|
-
});
|
132
|
-
|
133
|
-
var contentWindow = browser.contentWindow;
|
134
|
-
|
135
|
-
var checkForLoad = function() {
|
136
|
-
// Returning should be handled by the click listener, unless we're not
|
137
|
-
// actually loading something. Do a check and return if we are. There's a
|
138
|
-
// race condition here, in that the click event and load may have finished
|
139
|
-
// before we get here. For now, let's pretend that doesn't happen. The other
|
140
|
-
// race condition is that we make this check before the load has begun. With
|
141
|
-
// all the javascript out there, this might actually be a bit of a problem.
|
142
|
-
var docLoaderService = browser.webProgress;
|
143
|
-
if (!docLoaderService.isLoadingDocument) {
|
144
|
-
WebLoadingListener.removeListener(browser, clickListener);
|
145
|
-
if (!alreadyReplied) {
|
146
|
-
alreadyReplied = true;
|
147
|
-
respond.send();
|
148
|
-
}
|
149
|
-
}
|
150
|
-
};
|
151
|
-
|
152
|
-
|
153
|
-
if (contentWindow.closed) {
|
154
|
-
// Nulls out the session; client will have to switch to another
|
155
|
-
// window on their own.
|
156
|
-
respond.send();
|
157
|
-
return;
|
158
|
-
}
|
159
|
-
contentWindow.setTimeout(checkForLoad, 50);
|
160
|
-
};
|
161
|
-
|
162
|
-
|
163
|
-
FirefoxDriver.prototype.getElementText = function(respond, parameters) {
|
164
|
-
var element = Utils.getElementAt(parameters.id,
|
165
|
-
respond.session.getDocument());
|
166
|
-
|
167
|
-
if (element.tagName == "TITLE") {
|
168
|
-
respond.value = respond.session.getBrowser().contentTitle;
|
169
|
-
} else {
|
170
|
-
respond.value = Utils.getText(element, true);
|
171
|
-
}
|
172
|
-
|
173
|
-
respond.send();
|
174
|
-
};
|
175
|
-
|
176
|
-
|
177
|
-
FirefoxDriver.prototype.getElementValue = function(respond, parameters) {
|
178
|
-
var element = Utils.getElementAt(parameters.id,
|
179
|
-
respond.session.getDocument());
|
180
|
-
|
181
|
-
if (element["value"] !== undefined) {
|
182
|
-
respond.value = element.value;
|
183
|
-
respond.send();
|
184
|
-
return;
|
185
|
-
}
|
186
|
-
|
187
|
-
if (element.hasAttribute("value")) {
|
188
|
-
respond.value = element.getAttribute("value");
|
189
|
-
respond.send();
|
190
|
-
return;
|
191
|
-
}
|
192
|
-
|
193
|
-
throw new WebDriverError(ErrorCode.INVALID_ELEMENT_STATE,
|
194
|
-
'Element does not have a value attribute');
|
195
|
-
};
|
196
|
-
|
197
|
-
|
198
|
-
FirefoxDriver.prototype.sendKeysToElement = function(respond, parameters) {
|
199
|
-
var element = Utils.getElementAt(parameters.id,
|
200
|
-
respond.session.getDocument());
|
201
|
-
|
202
|
-
if (!Utils.isDisplayed(element, true) && !Utils.isInHead(element)) {
|
203
|
-
throw new WebDriverError(ErrorCode.ELEMENT_NOT_VISIBLE,
|
204
|
-
"Element is not currently visible and so may not be used for typing");
|
205
|
-
}
|
206
|
-
|
207
|
-
var currentlyActive = Utils.getActiveElement(respond.session.getDocument());
|
208
|
-
if (currentlyActive != element) {
|
209
|
-
currentlyActive.blur();
|
210
|
-
element.focus();
|
211
|
-
element.ownerDocument.defaultView.focus();
|
212
|
-
}
|
213
|
-
|
214
|
-
var use = element;
|
215
|
-
var tagName = element.tagName.toLowerCase();
|
216
|
-
if (tagName == "body" && element.ownerDocument.defaultView.frameElement) {
|
217
|
-
element.ownerDocument.defaultView.focus();
|
218
|
-
|
219
|
-
// Turns out, this is what we should be using as the target
|
220
|
-
// to send events to
|
221
|
-
use = element.ownerDocument.getElementsByTagName("html")[0];
|
222
|
-
}
|
223
|
-
|
224
|
-
Utils.type(respond.session.getDocument(), use, parameters.value.join(''), this.enableNativeEvents);
|
225
|
-
|
226
|
-
respond.send();
|
227
|
-
};
|
228
|
-
|
229
|
-
|
230
|
-
FirefoxDriver.prototype.clearElement = function(respond, parameters) {
|
231
|
-
var element = Utils.getElementAt(parameters.id,
|
232
|
-
respond.session.getDocument());
|
233
|
-
|
234
|
-
if (!Utils.isDisplayed(element, true) && !Utils.isInHead(element)) {
|
235
|
-
throw new WebDriverError(ErrorCode.ELEMENT_NOT_VISIBLE,
|
236
|
-
"Element is not currently visible and so may not be cleared");
|
237
|
-
}
|
238
|
-
|
239
|
-
var isTextField = element["value"] !== undefined;
|
240
|
-
|
241
|
-
var currentlyActive = Utils.getActiveElement(respond.session.getDocument());
|
242
|
-
if (currentlyActive != element) {
|
243
|
-
currentlyActive.blur();
|
244
|
-
element.focus();
|
245
|
-
}
|
246
|
-
|
247
|
-
var currentValue = undefined;
|
248
|
-
if (element["value"] !== undefined) {
|
249
|
-
currentValue = element.value;
|
250
|
-
} else if (element.hasAttribute("value")) {
|
251
|
-
currentValue = element.getAttribute("value");
|
252
|
-
}
|
253
|
-
|
254
|
-
if (isTextField) {
|
255
|
-
element.value = "";
|
256
|
-
} else {
|
257
|
-
element.setAttribute("value", "");
|
258
|
-
}
|
259
|
-
|
260
|
-
if (currentValue !== undefined && currentValue != "") {
|
261
|
-
Utils.fireHtmlEvent(element, "change");
|
262
|
-
}
|
263
|
-
|
264
|
-
respond.send();
|
265
|
-
};
|
266
|
-
|
267
|
-
|
268
|
-
FirefoxDriver.prototype.getElementTagName = function(respond, parameters) {
|
269
|
-
var element = Utils.getElementAt(parameters.id,
|
270
|
-
respond.session.getDocument());
|
271
|
-
|
272
|
-
respond.value = element.tagName.toLowerCase();
|
273
|
-
respond.send();
|
274
|
-
};
|
275
|
-
|
276
|
-
|
277
|
-
FirefoxDriver.prototype.getElementAttribute = function(respond, parameters) {
|
278
|
-
var element = Utils.getElementAt(parameters.id,
|
279
|
-
respond.session.getDocument());
|
280
|
-
|
281
|
-
var attributeName = parameters.name;
|
282
|
-
|
283
|
-
if (element.hasAttribute(attributeName)) {
|
284
|
-
respond.value = element.getAttribute(attributeName);
|
285
|
-
// Is this block necessary?
|
286
|
-
if (attributeName.toLowerCase() == "disabled") {
|
287
|
-
respond.value = element.disabled;
|
288
|
-
} else if (attributeName.toLowerCase() == "selected") {
|
289
|
-
respond.value = element.selected;
|
290
|
-
} else if (attributeName.toLowerCase() == "checked") {
|
291
|
-
respond.value = element.checked;
|
292
|
-
} else if (attributeName.toLowerCase() == "readonly") {
|
293
|
-
respond.value = element.readOnly;
|
294
|
-
}
|
295
|
-
|
296
|
-
respond.send();
|
297
|
-
return;
|
298
|
-
}
|
299
|
-
|
300
|
-
attributeName = attributeName.toLowerCase();
|
301
|
-
|
302
|
-
if (attributeName == "disabled") {
|
303
|
-
respond.value = (element.disabled === undefined ? false : element.disabled);
|
304
|
-
respond.send();
|
305
|
-
return;
|
306
|
-
} else if ((attributeName == "checked" || attributeName == "selected") &&
|
307
|
-
element.tagName.toLowerCase() == "input") {
|
308
|
-
respond.value = element.checked;
|
309
|
-
respond.send();
|
310
|
-
return;
|
311
|
-
} else if (attributeName == "selected" && element.tagName.toLowerCase()
|
312
|
-
== "option") {
|
313
|
-
respond.value = element.selected;
|
314
|
-
respond.send();
|
315
|
-
return;
|
316
|
-
} else if (attributeName == "index" && element.tagName.toLowerCase()
|
317
|
-
== "option") {
|
318
|
-
respond.value = element.index;
|
319
|
-
respond.send();
|
320
|
-
return;
|
321
|
-
}
|
322
|
-
respond.value = null;
|
323
|
-
respond.send();
|
324
|
-
};
|
325
|
-
|
326
|
-
|
327
|
-
FirefoxDriver.prototype.isElementEnabled = function(respond, parameters) {
|
328
|
-
var element = Utils.getElementAt(parameters.id,
|
329
|
-
respond.session.getDocument());
|
330
|
-
respond.value = !!!element.disabled;
|
331
|
-
respond.send();
|
332
|
-
};
|
333
|
-
|
334
|
-
|
335
|
-
FirefoxDriver.prototype.hoverOverElement = function(respond, parameters) {
|
336
|
-
var element = Utils.getElementAt(parameters.id,
|
337
|
-
respond.session.getDocument());
|
338
|
-
|
339
|
-
var events = Utils.getNativeEvents();
|
340
|
-
var node = Utils.getNodeForNativeEvents(element);
|
341
|
-
|
342
|
-
if (this.enableNativeEvents && events && node) {
|
343
|
-
var loc = Utils.getLocationOnceScrolledIntoView(element);
|
344
|
-
|
345
|
-
var x = loc.x + (loc.width ? loc.width / 2 : 0);
|
346
|
-
var y = loc.y + (loc.height ? loc.height / 2 : 0);
|
347
|
-
|
348
|
-
events.mouseMove(node, this.currentX, this.currentY, x, y);
|
349
|
-
this.currentX = x;
|
350
|
-
this.currentY = y;
|
351
|
-
} else {
|
352
|
-
// TODO: use the correct error type here.
|
353
|
-
throw new WebDriverError(ErrorCode.INVALID_ELEMENT_STATE,
|
354
|
-
"Unable to hover over element");
|
355
|
-
}
|
356
|
-
|
357
|
-
respond.send();
|
358
|
-
};
|
359
|
-
|
360
|
-
FirefoxDriver.prototype.submitElement = function(respond, parameters) {
|
361
|
-
var element = Utils.getElementAt(parameters.id,
|
362
|
-
respond.session.getDocument());
|
363
|
-
|
364
|
-
if (element) {
|
365
|
-
while (element.parentNode != null && element.tagName.toLowerCase() != "form") {
|
366
|
-
element = element.parentNode;
|
367
|
-
}
|
368
|
-
if (element.tagName && element.tagName.toLowerCase() == "form") {
|
369
|
-
if (Utils.fireHtmlEvent(element, "submit")) {
|
370
|
-
new WebLoadingListener(respond.session.getBrowser(), function() {
|
371
|
-
respond.send();
|
372
|
-
});
|
373
|
-
element.submit();
|
374
|
-
return;
|
375
|
-
} else {
|
376
|
-
//Event was blocked, so don't submit
|
377
|
-
respond.send();
|
378
|
-
return;
|
379
|
-
}
|
380
|
-
} else {
|
381
|
-
throw new WebDriverError(ErrorCode.INVALID_ELEMENT_STATE,
|
382
|
-
"Element was not in a form so couldn't submit");
|
383
|
-
}
|
384
|
-
} else {
|
385
|
-
respond.send();
|
386
|
-
return;
|
387
|
-
}
|
388
|
-
};
|
389
|
-
|
390
|
-
FirefoxDriver.prototype.isElementSelected = function(respond, parameters) {
|
391
|
-
var element = Utils.getElementAt(parameters.id,
|
392
|
-
respond.session.getDocument());
|
393
|
-
|
394
|
-
var selected = false;
|
395
|
-
|
396
|
-
try {
|
397
|
-
var option =
|
398
|
-
element.QueryInterface(Components.interfaces.nsIDOMHTMLOptionElement);
|
399
|
-
selected = option.selected;
|
400
|
-
} catch(e) {
|
401
|
-
}
|
402
|
-
|
403
|
-
try {
|
404
|
-
var inputElement =
|
405
|
-
element.QueryInterface(Components.interfaces.nsIDOMHTMLInputElement);
|
406
|
-
if (inputElement.type == "checkbox" || inputElement.type == "radio") {
|
407
|
-
selected = inputElement.checked;
|
408
|
-
}
|
409
|
-
} catch(e) {
|
410
|
-
}
|
411
|
-
|
412
|
-
respond.value = selected;
|
413
|
-
respond.send();
|
414
|
-
};
|
415
|
-
|
416
|
-
|
417
|
-
FirefoxDriver.prototype.setElementSelected = function(respond, parameters) {
|
418
|
-
var element = Utils.getElementAt(parameters.id,
|
419
|
-
respond.session.getDocument());
|
420
|
-
|
421
|
-
if (!Utils.isDisplayed(element, true) && !Utils.isInHead(element)) {
|
422
|
-
throw new WebDriverError(ErrorCode.ELEMENT_NOT_VISIBLE,
|
423
|
-
"Element is not currently visible and so may not be selected");
|
424
|
-
}
|
425
|
-
|
426
|
-
function safeQueryInterface(element, queryFor) {
|
427
|
-
try {
|
428
|
-
return element.QueryInterface(queryFor);
|
429
|
-
} catch (ignored) {
|
430
|
-
return null;
|
431
|
-
}
|
432
|
-
}
|
433
|
-
|
434
|
-
var option = safeQueryInterface(
|
435
|
-
element, Components.interfaces.nsIDOMHTMLOptionElement);
|
436
|
-
if (option) {
|
437
|
-
var select = element;
|
438
|
-
while (select.parentNode && select.tagName.toLowerCase() != 'select') {
|
439
|
-
select = select.parentNode;
|
440
|
-
}
|
441
|
-
select = safeQueryInterface(
|
442
|
-
select, Components.interfaces.nsIDOMHTMLSelectElement);
|
443
|
-
if (!select) {
|
444
|
-
//If we're not within a select element, fire the event from the option, and hope that it bubbles up
|
445
|
-
Utils.dumpn("Falling back to event firing from option, not select element");
|
446
|
-
select = option;
|
447
|
-
}
|
448
|
-
|
449
|
-
if (!option.selected) {
|
450
|
-
option.selected = true;
|
451
|
-
Utils.fireHtmlEvent(select, 'change');
|
452
|
-
}
|
453
|
-
|
454
|
-
respond.status = ErrorCode.SUCCESS;
|
455
|
-
respond.value = '';
|
456
|
-
respond.send();
|
457
|
-
return;
|
458
|
-
}
|
459
|
-
|
460
|
-
var inputElement = safeQueryInterface(
|
461
|
-
element, Components.interfaces.nsIDOMHTMLInputElement);
|
462
|
-
if (inputElement) {
|
463
|
-
if (inputElement.disabled) {
|
464
|
-
throw new WebDriverError(ErrorCode.INVALID_ELEMENT_STATE,
|
465
|
-
"You may not select a disabled element");
|
466
|
-
}
|
467
|
-
|
468
|
-
if (inputElement.type == 'checkbox' || inputElement.type == 'radio') {
|
469
|
-
if (!inputElement.checked) {
|
470
|
-
inputElement.checked = true;
|
471
|
-
Utils.fireHtmlEvent(inputElement, 'change');
|
472
|
-
}
|
473
|
-
|
474
|
-
respond.status = ErrorCode.SUCCESS;
|
475
|
-
respond.value = '';
|
476
|
-
respond.send();
|
477
|
-
return;
|
478
|
-
}
|
479
|
-
}
|
480
|
-
|
481
|
-
throw new WebDriverError(ErrorCode.INVALID_ELEMENT_STATE,
|
482
|
-
'You may not select an unselectable element');
|
483
|
-
};
|
484
|
-
|
485
|
-
|
486
|
-
FirefoxDriver.prototype.toggleElement = function(respond, parameters) {
|
487
|
-
var element = Utils.getElementAt(parameters.id,
|
488
|
-
respond.session.getDocument());
|
489
|
-
|
490
|
-
if (!Utils.isDisplayed(element) && !Utils.isInHead(element)) {
|
491
|
-
throw new WebDriverError(ErrorCode.ELEMENT_NOT_VISIBLE,
|
492
|
-
"Element is not currently visible and so may not be toggled");
|
493
|
-
}
|
494
|
-
|
495
|
-
try {
|
496
|
-
var checkbox =
|
497
|
-
element.QueryInterface(Components.interfaces.nsIDOMHTMLInputElement);
|
498
|
-
if (checkbox.type == "checkbox") {
|
499
|
-
checkbox.checked = !checkbox.checked;
|
500
|
-
Utils.fireHtmlEvent(checkbox, "change");
|
501
|
-
respond.value = checkbox.checked;
|
502
|
-
respond.send();
|
503
|
-
return;
|
504
|
-
}
|
505
|
-
} catch(e) {
|
506
|
-
}
|
507
|
-
|
508
|
-
try {
|
509
|
-
var option =
|
510
|
-
element.QueryInterface(Components.interfaces.nsIDOMHTMLOptionElement);
|
511
|
-
|
512
|
-
// Find our containing select and see if it allows multiple selections
|
513
|
-
var select = option.parentNode;
|
514
|
-
while (select && select.tagName != "SELECT") {
|
515
|
-
select = select.parentNode;
|
516
|
-
}
|
517
|
-
|
518
|
-
if (select && select.multiple) {
|
519
|
-
option.selected = !option.selected;
|
520
|
-
Utils.fireHtmlEvent(option, "change");
|
521
|
-
respond.value = option.selected;
|
522
|
-
respond.send();
|
523
|
-
return;
|
524
|
-
}
|
525
|
-
} catch(e) {
|
526
|
-
}
|
527
|
-
|
528
|
-
throw new WebDriverError(ErrorCode.INVALID_ELEMENT_STATE,
|
529
|
-
"You may only toggle an element that is either a checkbox or an " +
|
530
|
-
"option in a select that allows multiple selections");
|
531
|
-
};
|
532
|
-
|
533
|
-
|
534
|
-
FirefoxDriver.prototype.isElementDisplayed = function(respond, parameters) {
|
535
|
-
var element = Utils.getElementAt(parameters.id,
|
536
|
-
respond.session.getDocument());
|
537
|
-
respond.value = Utils.isDisplayed(element, false);
|
538
|
-
respond.send();
|
539
|
-
};
|
540
|
-
|
541
|
-
|
542
|
-
FirefoxDriver.prototype.getElementLocation = function(respond, parameters) {
|
543
|
-
var element = Utils.getElementAt(parameters.id,
|
544
|
-
respond.session.getDocument());
|
545
|
-
|
546
|
-
var location = Utils.getElementLocation(element);
|
547
|
-
|
548
|
-
respond.value = {
|
549
|
-
x: Math.round(location.x),
|
550
|
-
y: Math.round(location.y)
|
551
|
-
};
|
552
|
-
|
553
|
-
respond.send();
|
554
|
-
};
|
555
|
-
|
556
|
-
|
557
|
-
FirefoxDriver.prototype.getElementSize = function(respond, parameters) {
|
558
|
-
var element = Utils.getElementAt(parameters.id,
|
559
|
-
respond.session.getDocument());
|
560
|
-
|
561
|
-
var box = Utils.getLocationOnceScrolledIntoView(element);
|
562
|
-
|
563
|
-
respond.value = {
|
564
|
-
width: Math.round(box.width),
|
565
|
-
height: Math.round(box.height)
|
566
|
-
};
|
567
|
-
respond.send();
|
568
|
-
};
|
569
|
-
|
570
|
-
|
571
|
-
FirefoxDriver.prototype.dragElement = function(respond, parameters) {
|
572
|
-
var element = Utils.getElementAt(parameters.id,
|
573
|
-
respond.session.getDocument());
|
574
|
-
|
575
|
-
if (!Utils.isDisplayed(element, true) && !Utils.isInHead(element)) {
|
576
|
-
throw new WebDriverError(ErrorCode.ELEMENT_NOT_VISIBLE,
|
577
|
-
"Element is not currently visible and so may not be used for " +
|
578
|
-
"drag and drop");
|
579
|
-
}
|
580
|
-
|
581
|
-
// Scroll the first element into view
|
582
|
-
// element.scrollIntoView(true);
|
583
|
-
|
584
|
-
var clientStartXY = Utils.getElementLocation(element);
|
585
|
-
|
586
|
-
var clientStartX = clientStartXY.x;
|
587
|
-
var clientStartY = clientStartXY.y;
|
588
|
-
|
589
|
-
var movementX = parameters.x;
|
590
|
-
var movementY = parameters.y;
|
591
|
-
|
592
|
-
var clientFinishX = ((clientStartX + movementX) < 0) ? 0 : (clientStartX
|
593
|
-
+ movementX);
|
594
|
-
var clientFinishY = ((clientStartY + movementY) < 0) ? 0 : (clientStartY
|
595
|
-
+ movementY);
|
596
|
-
|
597
|
-
// Restrict the desitnation into the sensible dimension
|
598
|
-
var body = element.ownerDocument.body;
|
599
|
-
|
600
|
-
if (clientFinishX > body.scrollWidth)
|
601
|
-
clientFinishX = body.scrollWidth;
|
602
|
-
if (clientFinishY > body.scrollHeight)
|
603
|
-
clientFinishY = body.scrollHeight;
|
604
|
-
|
605
|
-
var mouseSpeed = respond.session.getInputSpeed();
|
606
|
-
var move = function(current, dest) {
|
607
|
-
if (current == dest) return current;
|
608
|
-
if (Math.abs(current - dest) < mouseSpeed) return dest;
|
609
|
-
return (current < dest) ? current + mouseSpeed : current - mouseSpeed;
|
610
|
-
};
|
611
|
-
|
612
|
-
Utils.triggerMouseEvent(element, 'mousedown', clientStartX, clientStartY);
|
613
|
-
Utils.triggerMouseEvent(element, 'mousemove', clientStartX, clientStartY);
|
614
|
-
var clientX = clientStartX;
|
615
|
-
var clientY = clientStartY;
|
616
|
-
|
617
|
-
while ((clientX != clientFinishX) || (clientY != clientFinishY)) {
|
618
|
-
clientX = move(clientX, clientFinishX);
|
619
|
-
clientY = move(clientY, clientFinishY);
|
620
|
-
|
621
|
-
Utils.triggerMouseEvent(element, 'mousemove', clientX, clientY);
|
622
|
-
}
|
623
|
-
|
624
|
-
Utils.triggerMouseEvent(element, 'mousemove', clientFinishX, clientFinishY);
|
625
|
-
|
626
|
-
// TODO(simon.m.stewart) If we can tell which element is under the cursor,
|
627
|
-
// send the mouseup to that
|
628
|
-
Utils.triggerMouseEvent(element, 'mouseup', clientFinishX, clientFinishY);
|
629
|
-
|
630
|
-
var finalLoc = Utils.getElementLocation(element);
|
631
|
-
|
632
|
-
respond.value = finalLoc.x + "," + finalLoc.y;
|
633
|
-
respond.send();
|
634
|
-
};
|
635
|
-
|
636
|
-
|
637
|
-
FirefoxDriver.prototype.getElementValueOfCssProperty = function(respond,
|
638
|
-
parameters) {
|
639
|
-
var element = Utils.getElementAt(parameters.id,
|
640
|
-
respond.session.getDocument());
|
641
|
-
respond.value = Utils.getStyleProperty(element, parameters.propertyName); // Coeerce to a string
|
642
|
-
respond.send();
|
643
|
-
};
|
644
|
-
|
645
|
-
|
646
|
-
FirefoxDriver.prototype.getElementLocationOnceScrolledIntoView = function(
|
647
|
-
respond, parameters) {
|
648
|
-
var element = Utils.getElementAt(parameters.id,
|
649
|
-
respond.session.getDocument());
|
650
|
-
|
651
|
-
if (!Utils.isDisplayed(element, true)) {
|
652
|
-
respond.value = undefined;
|
653
|
-
respond.send();
|
654
|
-
return;
|
655
|
-
}
|
656
|
-
|
657
|
-
var theDoc = element.ownerDocument;
|
658
|
-
theDoc.body.focus();
|
659
|
-
element.scrollIntoView(true);
|
660
|
-
|
661
|
-
var retrieval = Utils.newInstance(
|
662
|
-
"@mozilla.org/accessibleRetrieval;1", "nsIAccessibleRetrieval");
|
663
|
-
|
664
|
-
try {
|
665
|
-
var accessible = retrieval.getAccessibleFor(element);
|
666
|
-
var x = {}, y = {}, width = {}, height = {};
|
667
|
-
accessible.getBounds(x, y, width, height);
|
668
|
-
|
669
|
-
respond.value = {
|
670
|
-
x : x.value,
|
671
|
-
y : y.value
|
672
|
-
};
|
673
|
-
respond.send();
|
674
|
-
return;
|
675
|
-
} catch(e) {
|
676
|
-
// Element doesn't have an accessibility node. Fall through
|
677
|
-
}
|
678
|
-
|
679
|
-
// If we have the box object (which is deprecated) we could try using it
|
680
|
-
var theDoc = respond.session.getDocument();
|
681
|
-
if (theDoc.getBoxObjectFor) {
|
682
|
-
// Fallback. Use the (deprecated) method to find out where the element is in
|
683
|
-
// the viewport. This should be fine to use because we only fall down this
|
684
|
-
// code path on older versions of Firefox (I think!)
|
685
|
-
|
686
|
-
var box = theDoc.getBoxObjectFor(element);
|
687
|
-
|
688
|
-
respond.value = {
|
689
|
-
x : box.screenX,
|
690
|
-
y : box.screenY
|
691
|
-
};
|
692
|
-
respond.send();
|
693
|
-
}
|
694
|
-
|
695
|
-
// Fine. Come up with a good guess. This should be the element location
|
696
|
-
// added to the current window location. It'll probably be off
|
697
|
-
var x = theDoc.defaultView.screenX;
|
698
|
-
var y = theDoc.defaultView.screenY;
|
699
|
-
|
700
|
-
var rect = element.getBoundingClientRect()
|
701
|
-
respond.value = {
|
702
|
-
x : x + rect.left,
|
703
|
-
y : y + rect.top
|
704
|
-
}
|
705
|
-
respond.send();
|
706
|
-
};
|