selenium-webdriver 0.0.14 → 0.0.15
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.
- data/chrome/src/rb/lib/selenium/webdriver/chrome/bridge.rb +12 -0
- data/chrome/src/rb/lib/selenium/webdriver/chrome/command_executor.rb +5 -1
- data/common/src/js/core/scripts/htmlutils.js +404 -76
- data/common/src/js/core/scripts/rpc-optimizing-user-extension.js +5206 -0
- data/common/src/js/core/scripts/selenium-api.js +10 -15
- data/common/src/js/core/scripts/selenium-browserbot.js +26 -21
- data/common/src/rb/lib/selenium/webdriver/child_process.rb +62 -8
- data/common/src/rb/lib/selenium/webdriver/find.rb +12 -11
- data/common/src/rb/lib/selenium/webdriver/platform.rb +34 -36
- data/common/src/rb/lib/selenium/webdriver/target_locator.rb +8 -0
- data/firefox/prebuilt/linux/Release/libwebdriver-firefox.so +0 -0
- data/firefox/src/extension/components/badCertListener.js +121 -19
- data/firefox/src/extension/components/screenshooter.js +1 -1
- data/firefox/src/extension/components/utils.js +19 -10
- data/firefox/src/extension/components/wrappedElement.js +8 -8
- data/firefox/src/rb/lib/selenium/webdriver/firefox.rb +8 -1
- data/firefox/src/rb/lib/selenium/webdriver/firefox/binary.rb +1 -1
- data/firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb +12 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb +1 -1
- data/firefox/src/rb/lib/selenium/webdriver/firefox/launcher.rb +4 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb +18 -9
- 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/bridge.rb +4 -0
- data/jobbie/src/rb/lib/selenium/webdriver/ie/util.rb +3 -2
- data/remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb +4 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/default_http_client.rb +1 -1
- metadata +3 -2
@@ -37,7 +37,7 @@ Screenshooter.grab = function(window) {
|
|
37
37
|
canvas.width = width;
|
38
38
|
canvas.height = height;
|
39
39
|
var context = canvas.getContext('2d');
|
40
|
-
context.drawWindow(window, 0, 0, width, height, 'rgb(
|
40
|
+
context.drawWindow(window, 0, 0, width, height, 'rgb(255,255,255)');
|
41
41
|
return canvas;
|
42
42
|
};
|
43
43
|
|
@@ -154,7 +154,7 @@ function getTextFromNode(node, toReturn, textSoFar) {
|
|
154
154
|
|
155
155
|
// Or is this just plain text?
|
156
156
|
if (child.nodeName == "#text") {
|
157
|
-
if (Utils.isDisplayed(child)) {
|
157
|
+
if (Utils.isDisplayed(child, false)) {
|
158
158
|
var textToAdd = child.nodeValue;
|
159
159
|
textToAdd =
|
160
160
|
textToAdd.replace(new RegExp(String.fromCharCode(160), "gm"), " ");
|
@@ -211,7 +211,10 @@ Utils.isInHead = function(element) {
|
|
211
211
|
};
|
212
212
|
|
213
213
|
|
214
|
-
|
214
|
+
/**
|
215
|
+
* Checks that the element is not hidden by dimensions or CSS
|
216
|
+
*/
|
217
|
+
Utils.isDisplayed = function(element, scrollIfNecessary) {
|
215
218
|
// Ensure that we're dealing with an element.
|
216
219
|
var el = element;
|
217
220
|
while (el.nodeType != 1 && !(el.nodeType >= 9 && el.nodeType <= 11)) {
|
@@ -227,7 +230,7 @@ Utils.isDisplayed = function(element) {
|
|
227
230
|
return false;
|
228
231
|
}
|
229
232
|
|
230
|
-
var box = Utils.getLocationOnceScrolledIntoView(el);
|
233
|
+
var box = scrollIfNecessary ? Utils.getLocationOnceScrolledIntoView(el) : Utils.getLocation(el);
|
231
234
|
// Elements with zero width or height are never displayed
|
232
235
|
if (box.width == 0 || box.height == 0) {
|
233
236
|
return false;
|
@@ -427,6 +430,7 @@ Utils.type = function(context, element, text, opt_useNativeEvents) {
|
|
427
430
|
var inputtype = element.getAttribute("type");
|
428
431
|
if (inputtype && inputtype.toLowerCase() == "file") {
|
429
432
|
element.value = text;
|
433
|
+
Utils.fireHtmlEvent(context, element, "change");
|
430
434
|
return;
|
431
435
|
}
|
432
436
|
}
|
@@ -1085,13 +1089,7 @@ Utils.findElementsByXPath = function (xpath, contextNode, context) {
|
|
1085
1089
|
};
|
1086
1090
|
|
1087
1091
|
|
1088
|
-
Utils.
|
1089
|
-
// Some elements may not a scrollIntoView function - for example,
|
1090
|
-
// elements under an SVG element. Call those only if they exist.
|
1091
|
-
if (typeof element.scrollIntoView == 'function') {
|
1092
|
-
element.scrollIntoView(true);
|
1093
|
-
}
|
1094
|
-
|
1092
|
+
Utils.getLocation = function(element) {
|
1095
1093
|
var retrieval = Utils.newInstance(
|
1096
1094
|
"@mozilla.org/accessibleRetrieval;1", "nsIAccessibleRetrieval");
|
1097
1095
|
|
@@ -1175,6 +1173,17 @@ Utils.getLocationOnceScrolledIntoView = function(element) {
|
|
1175
1173
|
};
|
1176
1174
|
|
1177
1175
|
|
1176
|
+
Utils.getLocationOnceScrolledIntoView = function(element) {
|
1177
|
+
// Some elements may not a scrollIntoView function - for example,
|
1178
|
+
// elements under an SVG element. Call those only if they exist.
|
1179
|
+
if (typeof element.scrollIntoView == 'function') {
|
1180
|
+
element.scrollIntoView(true);
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
return Utils.getLocation(element);
|
1184
|
+
};
|
1185
|
+
|
1186
|
+
|
1178
1187
|
Utils.unwrapParameters = function(wrappedParameters, resultArray, context) {
|
1179
1188
|
while (wrappedParameters && wrappedParameters.length > 0) {
|
1180
1189
|
var t = wrappedParameters.shift();
|
@@ -20,7 +20,7 @@
|
|
20
20
|
FirefoxDriver.prototype.click = function(respond) {
|
21
21
|
var element = Utils.getElementAt(respond.elementId, respond.context);
|
22
22
|
|
23
|
-
if (!Utils.isDisplayed(element) && !Utils.isInHead(element)) {
|
23
|
+
if (!Utils.isDisplayed(element, true) && !Utils.isInHead(element)) {
|
24
24
|
respond.isError = true;
|
25
25
|
respond.response =
|
26
26
|
"Element is not currently visible and so may not be clicked";
|
@@ -164,7 +164,7 @@ FirefoxDriver.prototype.getValue = function(respond) {
|
|
164
164
|
FirefoxDriver.prototype.sendKeys = function(respond, value) {
|
165
165
|
var element = Utils.getElementAt(respond.elementId, respond.context);
|
166
166
|
|
167
|
-
if (!Utils.isDisplayed(element) && !Utils.isInHead(element)) {
|
167
|
+
if (!Utils.isDisplayed(element, true) && !Utils.isInHead(element)) {
|
168
168
|
respond.isError = true;
|
169
169
|
respond.response =
|
170
170
|
"Element is not currently visible and so may not be used for typing";
|
@@ -198,7 +198,7 @@ FirefoxDriver.prototype.sendKeys = function(respond, value) {
|
|
198
198
|
FirefoxDriver.prototype.clear = function(respond) {
|
199
199
|
var element = Utils.getElementAt(respond.elementId, respond.context);
|
200
200
|
|
201
|
-
if (!Utils.isDisplayed(element) && !Utils.isInHead(element)) {
|
201
|
+
if (!Utils.isDisplayed(element, true) && !Utils.isInHead(element)) {
|
202
202
|
respond.isError = true;
|
203
203
|
respond.response =
|
204
204
|
"Element is not currently visible and so may not be cleared";
|
@@ -322,7 +322,7 @@ FirefoxDriver.prototype.submit = function(respond) {
|
|
322
322
|
while (element.parentNode != null && element.tagName.toLowerCase() != "form") {
|
323
323
|
element = element.parentNode;
|
324
324
|
}
|
325
|
-
if (element.tagName.toLowerCase() == "form") {
|
325
|
+
if (element.tagName && element.tagName.toLowerCase() == "form") {
|
326
326
|
if (Utils.fireHtmlEvent(respond.context, element, "submit")) {
|
327
327
|
new WebLoadingListener(Utils.getBrowser(respond.context), function() {
|
328
328
|
respond.send();
|
@@ -375,7 +375,7 @@ FirefoxDriver.prototype.isSelected = function(respond) {
|
|
375
375
|
FirefoxDriver.prototype.setSelected = function(respond) {
|
376
376
|
var element = Utils.getElementAt(respond.elementId, respond.context);
|
377
377
|
|
378
|
-
if (!Utils.isDisplayed(element) && !Utils.isInHead(element)) {
|
378
|
+
if (!Utils.isDisplayed(element, true) && !Utils.isInHead(element)) {
|
379
379
|
respond.isError = true;
|
380
380
|
respond.response =
|
381
381
|
"Element is not currently visible and so may not be selected";
|
@@ -491,7 +491,7 @@ FirefoxDriver.prototype.toggle = function(respond) {
|
|
491
491
|
|
492
492
|
FirefoxDriver.prototype.isDisplayed = function(respond) {
|
493
493
|
var element = Utils.getElementAt(respond.elementId, respond.context);
|
494
|
-
respond.response = Utils.isDisplayed(element);
|
494
|
+
respond.response = Utils.isDisplayed(element, false);
|
495
495
|
respond.send();
|
496
496
|
};
|
497
497
|
|
@@ -525,7 +525,7 @@ FirefoxDriver.prototype.getSize = function(respond) {
|
|
525
525
|
FirefoxDriver.prototype.dragElement = function(respond, movementString) {
|
526
526
|
var element = Utils.getElementAt(respond.elementId, respond.context);
|
527
527
|
|
528
|
-
if (!Utils.isDisplayed(element) && !Utils.isInHead(element)) {
|
528
|
+
if (!Utils.isDisplayed(element, true) && !Utils.isInHead(element)) {
|
529
529
|
respond.isError = true;
|
530
530
|
respond.response =
|
531
531
|
"Element is not currently visible and so may not be used for drag and drop";
|
@@ -601,7 +601,7 @@ FirefoxDriver.prototype.getValueOfCssProperty = function(respond,
|
|
601
601
|
FirefoxDriver.prototype.getLocationOnceScrolledIntoView = function(respond) {
|
602
602
|
var element = Utils.getElementAt(respond.elementId, respond.context);
|
603
603
|
|
604
|
-
if (!Utils.isDisplayed(element)) {
|
604
|
+
if (!Utils.isDisplayed(element, true)) {
|
605
605
|
respond.response = undefined;
|
606
606
|
respond.send();
|
607
607
|
return;
|
@@ -15,8 +15,15 @@ module Selenium
|
|
15
15
|
|
16
16
|
DEFAULT_PROFILE_NAME = "WebDriver".freeze
|
17
17
|
DEFAULT_PORT = 7055
|
18
|
-
DEFAULT_ENABLE_NATIVE_EVENTS = Platform.
|
18
|
+
DEFAULT_ENABLE_NATIVE_EVENTS = [:windows, :linux].include? Platform.os
|
19
19
|
|
20
20
|
end
|
21
21
|
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# SocketError was added in Ruby 1.8.7.
|
26
|
+
# If it's not defined, we add it here so it can be used in rescues.
|
27
|
+
unless defined? SocketError
|
28
|
+
class SocketError < IOError; end
|
22
29
|
end
|
@@ -151,6 +151,14 @@ module Selenium
|
|
151
151
|
find_elements_by 'xpath', xpath, parent
|
152
152
|
end
|
153
153
|
|
154
|
+
def findElementByCssSelector(parent, selector)
|
155
|
+
find_element_by 'css selector', selector, parent
|
156
|
+
end
|
157
|
+
|
158
|
+
def findElementsByCssSelector(parent, selector)
|
159
|
+
find_elements_by 'css selector', selector, parent
|
160
|
+
end
|
161
|
+
|
154
162
|
#
|
155
163
|
# Element functions
|
156
164
|
#
|
@@ -327,6 +335,10 @@ module Selenium
|
|
327
335
|
:parameters => [name.to_s]
|
328
336
|
end
|
329
337
|
|
338
|
+
def switchToDefaultContent
|
339
|
+
execute :switchToDefaultContent
|
340
|
+
end
|
341
|
+
|
330
342
|
def switchToWindow(name)
|
331
343
|
@context = execute :switchToWindow,
|
332
344
|
:parameters => [name.to_s]
|
@@ -13,7 +13,7 @@ module Selenium
|
|
13
13
|
loop do
|
14
14
|
begin
|
15
15
|
return new_socket
|
16
|
-
rescue Errno::ECONNREFUSED, Errno::ENOTCONN => e
|
16
|
+
rescue Errno::ECONNREFUSED, Errno::ENOTCONN, SocketError => e
|
17
17
|
$stderr.puts "#{self} caught #{e.message} for #{@host}:#{@port}" if $DEBUG
|
18
18
|
sleep 0.25
|
19
19
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "fcntl"
|
2
|
+
|
1
3
|
module Selenium
|
2
4
|
module WebDriver
|
3
5
|
module Firefox
|
@@ -29,6 +31,8 @@ module Selenium
|
|
29
31
|
|
30
32
|
def with_lock
|
31
33
|
socket_lock = TCPServer.new(@host, @port - 1)
|
34
|
+
socket_lock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC
|
35
|
+
|
32
36
|
yield
|
33
37
|
ensure
|
34
38
|
socket_lock.close if socket_lock
|
@@ -16,14 +16,15 @@ module Selenium
|
|
16
16
|
["#{WebDriver.root}/firefox/prebuilt/nsIResponseHandler.xpt", "components/nsIResponseHandler.xpt"],
|
17
17
|
]
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
NATIVE_WINDOWS = ["#{WebDriver.root}/firefox/prebuilt/Win32/Release/webdriver-firefox.dll", "platform/WINNT_x86-msvc/components/webdriver-firefox.dll"]
|
20
|
+
NATIVE_LINUX = [
|
21
|
+
["#{WebDriver.root}/firefox/prebuilt/linux/Release/libwebdriver-firefox.so", "platform/Linux_x86-gcc3/components/libwebdriver-firefox.so"],
|
22
|
+
["#{WebDriver.root}/firefox/prebuilt/linux64/Release/libwebdriver-firefox.so", "platform/Linux_x86_64-gcc3/components/libwebdriver-firefox.so"]
|
23
|
+
]
|
23
24
|
|
24
25
|
NO_FOCUS = [
|
25
|
-
["#{WebDriver.root}/firefox/prebuilt/linux64/Release/x_ignore_nofocus.so"
|
26
|
-
["#{WebDriver.root}/firefox/prebuilt/linux/Release/x_ignore_nofocus.so"
|
26
|
+
["#{WebDriver.root}/firefox/prebuilt/linux64/Release/x_ignore_nofocus.so", "amd64/x_ignore_nofocus.so"],
|
27
|
+
["#{WebDriver.root}/firefox/prebuilt/linux/Release/x_ignore_nofocus.so", "x86/x_ignore_nofocus.so"],
|
27
28
|
]
|
28
29
|
|
29
30
|
SHARED = [
|
@@ -90,13 +91,21 @@ module Selenium
|
|
90
91
|
from_to = XPTS + SHARED
|
91
92
|
|
92
93
|
if native_events?
|
93
|
-
|
94
|
-
|
94
|
+
case Platform.os
|
95
|
+
when :linux
|
96
|
+
NATIVE_LINUX.each do |lib|
|
97
|
+
from_to << lib
|
98
|
+
end
|
99
|
+
when :windows
|
100
|
+
from_to << NATIVE_WINDOWS
|
101
|
+
else
|
102
|
+
raise Error::WebDriverError, "can't enable native events on #{Platform.os.inspect}"
|
103
|
+
end
|
95
104
|
end
|
96
105
|
|
97
106
|
if Platform.os == :linux || load_no_focus_lib?
|
98
107
|
from_to += NO_FOCUS
|
99
|
-
modify_link_library_path(NO_FOCUS.map { |source, dest| File.join(ext_path, dest) })
|
108
|
+
modify_link_library_path(NO_FOCUS.map { |source, dest| File.join(ext_path, File.dirname(dest)) })
|
100
109
|
end
|
101
110
|
|
102
111
|
from_to.each do |source, destination|
|
Binary file
|
Binary file
|
@@ -62,6 +62,7 @@ module Selenium
|
|
62
62
|
|
63
63
|
def extract_string_from(string_ptr_ref)
|
64
64
|
string_ptr = string_ptr_ref.get_pointer(0)
|
65
|
+
return if string_ptr.null? # getElementAttribute()
|
65
66
|
|
66
67
|
length_ptr = FFI::MemoryPointer.new :int
|
67
68
|
|
@@ -78,7 +79,7 @@ module Selenium
|
|
78
79
|
|
79
80
|
wstring_to_bytestring raw_string
|
80
81
|
ensure
|
81
|
-
Lib.wdFreeString(string_ptr)
|
82
|
+
Lib.wdFreeString(string_ptr) unless string_ptr.null?
|
82
83
|
string_ptr_ref.free
|
83
84
|
end
|
84
85
|
|
@@ -87,7 +88,7 @@ module Selenium
|
|
87
88
|
length_ptr = FFI::MemoryPointer.new :int
|
88
89
|
|
89
90
|
check_error_code Lib.wdcGetElementCollectionLength(elements_ptr, length_ptr),
|
90
|
-
|
91
|
+
"Cannot extract elements from collection"
|
91
92
|
|
92
93
|
arr = []
|
93
94
|
|
@@ -56,7 +56,7 @@ module Selenium
|
|
56
56
|
if res.content_type == CONTENT_TYPE
|
57
57
|
Response.new do |r|
|
58
58
|
r.code = res.code.to_i
|
59
|
-
r.payload = JSON.parse(res.body)
|
59
|
+
r.payload = JSON.parse(res.body.strip)
|
60
60
|
end
|
61
61
|
elsif res.code == '204'
|
62
62
|
Response.new { |r| r.code = res.code.to_i }
|
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.
|
4
|
+
version: 0.0.15
|
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: 2010-01-
|
12
|
+
date: 2010-01-21 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- common/src/js/core/scripts/find_matching_child.js
|
112
112
|
- common/src/js/core/scripts/htmlutils.js
|
113
113
|
- common/src/js/core/scripts/injection.html
|
114
|
+
- common/src/js/core/scripts/rpc-optimizing-user-extension.js
|
114
115
|
- common/src/js/core/scripts/selenium-api.js
|
115
116
|
- common/src/js/core/scripts/selenium-browserbot.js
|
116
117
|
- common/src/js/core/scripts/selenium-browserdetect.js
|