selenium-webdriver 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +10 -0
- data/lib/selenium/webdriver.rb +23 -1
- data/lib/selenium/webdriver/chrome/bridge.rb +5 -1
- data/lib/selenium/webdriver/chrome/command_executor.rb +1 -1
- data/lib/selenium/webdriver/chrome/extension.zip +0 -0
- data/lib/selenium/webdriver/chrome/launcher.rb +10 -4
- data/lib/selenium/webdriver/common.rb +1 -0
- data/lib/selenium/webdriver/common/alert.rb +27 -0
- data/lib/selenium/webdriver/common/bridge_helper.rb +10 -7
- data/lib/selenium/webdriver/common/core_ext/dir.rb +1 -1
- data/lib/selenium/webdriver/common/driver.rb +8 -16
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +1 -1
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +1 -1
- data/lib/selenium/webdriver/common/element.rb +4 -4
- data/lib/selenium/webdriver/common/keys.rb +3 -1
- data/lib/selenium/webdriver/common/options.rb +2 -2
- data/lib/selenium/webdriver/common/platform.rb +11 -3
- data/lib/selenium/webdriver/common/socket_poller.rb +5 -1
- data/lib/selenium/webdriver/common/target_locator.rb +11 -3
- data/lib/selenium/webdriver/common/timeouts.rb +10 -0
- data/lib/selenium/webdriver/firefox/binary.rb +4 -2
- data/lib/selenium/webdriver/firefox/bridge.rb +1 -1
- data/lib/selenium/webdriver/firefox/extension.rb +2 -2
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +1 -1
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +2 -2
- data/lib/selenium/webdriver/firefox/socket_lock.rb +1 -1
- data/lib/selenium/webdriver/firefox/util.rb +2 -2
- data/lib/selenium/webdriver/ie.rb +3 -4
- data/lib/selenium/webdriver/ie/bridge.rb +20 -565
- data/lib/selenium/webdriver/ie/lib.rb +4 -99
- data/lib/selenium/webdriver/ie/native/win32/IEDriver.dll +0 -0
- data/lib/selenium/webdriver/ie/native/x64/IEDriver.dll +0 -0
- data/lib/selenium/webdriver/remote.rb +1 -1
- data/lib/selenium/webdriver/remote/bridge.rb +21 -1
- data/lib/selenium/webdriver/remote/commands.rb +6 -1
- data/lib/selenium/webdriver/remote/http/default.rb +2 -1
- data/lib/selenium/webdriver/remote/response.rb +1 -1
- metadata +19 -10
- data/lib/selenium/webdriver/ie/native/win32/InternetExplorerDriver.dll +0 -0
- data/lib/selenium/webdriver/ie/native/x64/InternetExplorerDriver.dll +0 -0
- data/lib/selenium/webdriver/ie/util.rb +0 -138
@@ -3,7 +3,7 @@ module Selenium
|
|
3
3
|
module IE
|
4
4
|
|
5
5
|
#
|
6
|
-
# @private
|
6
|
+
# @api private
|
7
7
|
#
|
8
8
|
|
9
9
|
module Lib
|
@@ -15,107 +15,12 @@ module Selenium
|
|
15
15
|
ffi_lib WebDriver::IE::DLLS[:win32]
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
attach_function :wdAddCookie, [:pointer, :pointer ], :int
|
20
|
-
attach_function :wdAddDoubleScriptArg, [:pointer, :double ], :int
|
21
|
-
attach_function :wdAddElementScriptArg, [:pointer, :pointer ], :int
|
22
|
-
attach_function :wdAddNumberScriptArg, [:pointer, :long ], :int
|
23
|
-
attach_function :wdAddStringScriptArg, [:pointer, :pointer ], :int
|
24
|
-
attach_function :wdcGetElementAtIndex, [:pointer, :int, :pointer ], :int
|
25
|
-
attach_function :wdcGetElementCollectionLength, [:pointer, :pointer ], :int
|
26
|
-
attach_function :wdcGetStringAtIndex, [:pointer, :int, :pointer ], :int
|
27
|
-
attach_function :wdcGetStringCollectionLength, [:pointer, :pointer ], :int
|
28
|
-
attach_function :wdClose, [:pointer ], :int
|
29
|
-
attach_function :wdCopyString, [:pointer, :int, :pointer ], :int
|
30
|
-
attach_function :wdeClear, [:pointer ], :int
|
31
|
-
attach_function :wdeClick, [:pointer ], :int
|
32
|
-
attach_function :wdeGetAttribute, [:pointer, :pointer, :pointer, :pointer ], :int
|
33
|
-
attach_function :wdeGetDetailsOnceScrolledOnToScreen, [:pointer, :pointer, :pointer, :pointer, :pointer, :pointer ], :int
|
34
|
-
attach_function :wdeGetLocation, [:pointer, :pointer, :pointer ], :int
|
35
|
-
attach_function :wdeGetSize, [:pointer, :pointer, :pointer ], :int
|
36
|
-
attach_function :wdeGetTagName, [:pointer, :pointer ], :int
|
37
|
-
attach_function :wdeGetText, [:pointer, :pointer ], :int
|
38
|
-
attach_function :wdeGetValueOfCssProperty, [:pointer, :pointer, :pointer ], :int
|
39
|
-
attach_function :wdeIsDisplayed, [:pointer, :pointer ], :int
|
40
|
-
attach_function :wdeIsEnabled, [:pointer, :pointer ], :int
|
41
|
-
attach_function :wdeIsSelected, [:pointer, :pointer ], :int
|
42
|
-
attach_function :wdeMouseDownAt, [:pointer, :long, :long ], :int #hwnd, nativelong
|
43
|
-
attach_function :wdeMouseMoveTo, [:pointer, :long, :long, :long, :long, :long ], :int # hwnd, 5x nativelong
|
44
|
-
attach_function :wdeMouseUpAt, [:pointer, :long, :long ], :int # hwnd
|
45
|
-
attach_function :wdeSendKeys, [:pointer, :pointer ], :int
|
46
|
-
attach_function :wdeSetSelected, [:pointer ], :int
|
47
|
-
attach_function :wdeSubmit, [:pointer ], :int
|
48
|
-
attach_function :wdeToggle, [:pointer, :pointer ], :int
|
49
|
-
attach_function :wdExecuteScript, [:pointer, :pointer, :pointer, :pointer ], :int
|
50
|
-
attach_function :wdeFreeElement, [:pointer ], :int
|
51
|
-
attach_function :wdFindElementByClassName, [:pointer, :pointer, :pointer, :pointer ], :int
|
52
|
-
attach_function :wdFindElementByCss, [:pointer, :pointer, :pointer, :pointer ], :int
|
53
|
-
attach_function :wdFindElementById, [:pointer, :pointer, :pointer, :pointer ], :int
|
54
|
-
attach_function :wdFindElementByLinkText, [:pointer, :pointer, :pointer, :pointer ], :int
|
55
|
-
attach_function :wdFindElementByName, [:pointer, :pointer, :pointer, :pointer ], :int
|
56
|
-
attach_function :wdFindElementByPartialLinkText, [:pointer, :pointer, :pointer, :pointer ], :int
|
57
|
-
attach_function :wdFindElementByTagName, [:pointer, :pointer, :pointer, :pointer ], :int
|
58
|
-
attach_function :wdFindElementByXPath, [:pointer, :pointer, :pointer, :pointer ], :int
|
59
|
-
attach_function :wdFindElementsByClassName, [:pointer, :pointer, :pointer, :pointer ], :int
|
60
|
-
attach_function :wdFindElementsByCss, [:pointer, :pointer, :pointer, :pointer ], :int
|
61
|
-
attach_function :wdFindElementsById, [:pointer, :pointer, :pointer, :pointer ], :int
|
62
|
-
attach_function :wdFindElementsByLinkText, [:pointer, :pointer, :pointer, :pointer ], :int
|
63
|
-
attach_function :wdFindElementsByName, [:pointer, :pointer, :pointer, :pointer ], :int
|
64
|
-
attach_function :wdFindElementsByPartialLinkText, [:pointer, :pointer, :pointer, :pointer ], :int
|
65
|
-
attach_function :wdFindElementsByTagName, [:pointer, :pointer, :pointer, :pointer ], :int
|
66
|
-
attach_function :wdFindElementsByXPath, [:pointer, :pointer, :pointer, :pointer ], :int
|
67
|
-
attach_function :wdFreeDriver, [:pointer ], :int
|
68
|
-
attach_function :wdFreeElementCollection, [:pointer, :int ], :int
|
69
|
-
attach_function :wdFreeScriptArgs, [:pointer ], :int
|
70
|
-
attach_function :wdFreeScriptResult, [:pointer ], :int
|
71
|
-
attach_function :wdFreeString, [:pointer ], :int
|
72
|
-
attach_function :wdFreeStringCollection, [:pointer ], :int
|
73
|
-
attach_function :wdGet, [:pointer, :pointer ], :int
|
74
|
-
attach_function :wdGetArrayLengthScriptResult, [:pointer, :pointer, :pointer ], :int
|
75
|
-
attach_function :wdGetArrayItemFromScriptResult, [:pointer, :pointer, :int, :pointer ], :int
|
76
|
-
attach_function :wdGetAllWindowHandles, [:pointer, :pointer ], :int
|
77
|
-
attach_function :wdGetBooleanScriptResult, [:pointer, :pointer ], :int
|
78
|
-
attach_function :wdGetCookies, [:pointer, :pointer ], :int
|
79
|
-
attach_function :wdGetCurrentUrl, [:pointer, :pointer ], :int
|
80
|
-
attach_function :wdGetCurrentWindowHandle, [:pointer, :pointer ], :int
|
81
|
-
attach_function :wdGetDoubleScriptResult, [:pointer, :pointer ], :int
|
82
|
-
attach_function :wdGetElementScriptResult, [:pointer, :pointer, :pointer ], :int
|
83
|
-
attach_function :wdGetNumberScriptResult, [:pointer, :pointer ], :int
|
84
|
-
attach_function :wdGetPageSource, [:pointer, :pointer ], :int
|
85
|
-
attach_function :wdGetScriptResultType, [:pointer, :pointer, :pointer ], :int
|
86
|
-
attach_function :wdGetStringScriptResult, [:pointer, :pointer ], :int
|
87
|
-
attach_function :wdGetTitle, [:pointer, :pointer ], :int
|
88
|
-
attach_function :wdGetVisible, [:pointer, :pointer ], :int
|
89
|
-
attach_function :wdGoBack, [:pointer ], :int
|
90
|
-
attach_function :wdGoForward, [:pointer ], :int
|
91
|
-
attach_function :wdNewDriverInstance, [:pointer ], :int
|
92
|
-
attach_function :wdNewScriptArgs, [:pointer, :int ], :int
|
93
|
-
attach_function :wdRefresh, [:pointer, ], :int
|
94
|
-
attach_function :wdSetImplicitWaitTimeout, [:pointer, :long ], :int
|
95
|
-
attach_function :wdSetVisible, [:pointer, :int ], :int
|
96
|
-
attach_function :wdStringLength, [:pointer, :pointer ], :int
|
97
|
-
attach_function :wdSwitchToActiveElement, [:pointer, :pointer ], :int
|
98
|
-
attach_function :wdSwitchToFrame, [:pointer, :pointer ], :int
|
99
|
-
attach_function :wdSwitchToWindow, [:pointer, :pointer ], :int
|
100
|
-
attach_function :wdWaitForLoadToComplete, [:pointer ], :int
|
18
|
+
ffi_convention :stdcall
|
101
19
|
|
102
|
-
|
103
|
-
|
104
|
-
if err = WebDriver::Error.for_code(code)
|
105
|
-
raise err, "could not free element (#{ptr})"
|
106
|
-
end
|
107
|
-
end
|
20
|
+
attach_function :start_server, :StartServer, [:int], :pointer
|
21
|
+
attach_function :stop_server, :StopServer, [:pointer], :void
|
108
22
|
|
109
23
|
end # Lib
|
110
|
-
|
111
|
-
module Kernel32
|
112
|
-
extend FFI::Library
|
113
|
-
|
114
|
-
ffi_lib "kernel32.dll"
|
115
|
-
|
116
|
-
attach_function :MultiByteToWideChar, [:int, :long, :pointer, :int, :pointer, :int ], :int
|
117
|
-
attach_function :WideCharToMultiByte, [:int, :long, :pointer, :int, :pointer, :int, :pointer, :pointer], :int
|
118
|
-
end
|
119
24
|
end # IE
|
120
25
|
end # WebDriver
|
121
26
|
end # Selenium
|
Binary file
|
Binary file
|
@@ -7,7 +7,7 @@ module Selenium
|
|
7
7
|
#
|
8
8
|
# Low level bridge to the remote server, through which the rest of the API works.
|
9
9
|
#
|
10
|
-
# @private
|
10
|
+
# @api private
|
11
11
|
#
|
12
12
|
|
13
13
|
class Bridge
|
@@ -104,6 +104,26 @@ module Selenium
|
|
104
104
|
execute :setImplicitWaitTimeout, {}, :ms => milliseconds
|
105
105
|
end
|
106
106
|
|
107
|
+
def setScriptTimeout(milliseconds)
|
108
|
+
execute :setScriptTimeout, {}, :ms => milliseconds
|
109
|
+
end
|
110
|
+
|
111
|
+
def acceptAlert
|
112
|
+
execute :acceptAlert
|
113
|
+
end
|
114
|
+
|
115
|
+
def dismissAlert
|
116
|
+
execute :dismissAlert
|
117
|
+
end
|
118
|
+
|
119
|
+
def setAlertValue(keys)
|
120
|
+
execute :setAlertValue, {}, :text => keys.to_s
|
121
|
+
end
|
122
|
+
|
123
|
+
def getAlertText
|
124
|
+
execute :getAlertText
|
125
|
+
end
|
126
|
+
|
107
127
|
def goBack
|
108
128
|
execute :goBack
|
109
129
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# @private
|
1
|
+
# @api private
|
2
2
|
class Selenium::WebDriver::Remote::Bridge
|
3
3
|
|
4
4
|
#
|
@@ -9,10 +9,15 @@ class Selenium::WebDriver::Remote::Bridge
|
|
9
9
|
command :getCapabilities, :get, "session/:session_id"
|
10
10
|
command :quit, :delete, "session/:session_id"
|
11
11
|
command :setImplicitWaitTimeout, :post, "session/:session_id/timeouts/implicit_wait"
|
12
|
+
command :setScriptTimeout, :post, "session/:session_id/timeouts/async_script"
|
12
13
|
command :getCurrentWindowHandle, :get, "session/:session_id/window_handle"
|
13
14
|
command :getWindowHandles, :get, "session/:session_id/window_handles"
|
14
15
|
command :getCurrentUrl, :get, "session/:session_id/url"
|
15
16
|
command :get, :post, "session/:session_id/url"
|
17
|
+
command :dismissAlert, :post, "session/:session_id/dismiss_alert"
|
18
|
+
command :acceptAlert, :post, "session/:session_id/accept_alert"
|
19
|
+
command :getAlertText, :get, "session/:session_id/alert_text"
|
20
|
+
command :setAlertValue, :post, "session/:session_id/alert_text"
|
16
21
|
command :goForward, :post, "session/:session_id/forward"
|
17
22
|
command :goBack, :post, "session/:session_id/back"
|
18
23
|
command :refresh, :post, "session/:session_id/refresh"
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jari Bakken
|
@@ -14,13 +14,14 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-12-22 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: json_pure
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
@@ -33,6 +34,7 @@ dependencies:
|
|
33
34
|
name: rubyzip
|
34
35
|
prerelease: false
|
35
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
36
38
|
requirements:
|
37
39
|
- - ">="
|
38
40
|
- !ruby/object:Gem::Version
|
@@ -45,20 +47,22 @@ dependencies:
|
|
45
47
|
name: childprocess
|
46
48
|
prerelease: false
|
47
49
|
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
48
51
|
requirements:
|
49
|
-
- -
|
52
|
+
- - ~>
|
50
53
|
- !ruby/object:Gem::Version
|
51
54
|
segments:
|
52
55
|
- 0
|
53
56
|
- 1
|
54
|
-
-
|
55
|
-
version: 0.1.
|
57
|
+
- 5
|
58
|
+
version: 0.1.5
|
56
59
|
type: :runtime
|
57
60
|
version_requirements: *id003
|
58
61
|
- !ruby/object:Gem::Dependency
|
59
62
|
name: ffi
|
60
63
|
prerelease: false
|
61
64
|
requirement: &id004 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
62
66
|
requirements:
|
63
67
|
- - ~>
|
64
68
|
- !ruby/object:Gem::Version
|
@@ -73,6 +77,7 @@ dependencies:
|
|
73
77
|
name: rspec
|
74
78
|
prerelease: false
|
75
79
|
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
76
81
|
requirements:
|
77
82
|
- - "="
|
78
83
|
- !ruby/object:Gem::Version
|
@@ -87,6 +92,7 @@ dependencies:
|
|
87
92
|
name: rack
|
88
93
|
prerelease: false
|
89
94
|
requirement: &id006 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
90
96
|
requirements:
|
91
97
|
- - ~>
|
92
98
|
- !ruby/object:Gem::Version
|
@@ -100,6 +106,7 @@ dependencies:
|
|
100
106
|
name: ci_reporter
|
101
107
|
prerelease: false
|
102
108
|
requirement: &id007 !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
103
110
|
requirements:
|
104
111
|
- - ~>
|
105
112
|
- !ruby/object:Gem::Version
|
@@ -148,6 +155,7 @@ files:
|
|
148
155
|
- lib/selenium/webdriver/chrome/command_executor.rb
|
149
156
|
- lib/selenium/webdriver/chrome/extension.zip
|
150
157
|
- lib/selenium/webdriver/chrome/launcher.rb
|
158
|
+
- lib/selenium/webdriver/common/alert.rb
|
151
159
|
- lib/selenium/webdriver/common/bridge_helper.rb
|
152
160
|
- lib/selenium/webdriver/common/driver.rb
|
153
161
|
- lib/selenium/webdriver/common/element.rb
|
@@ -181,9 +189,8 @@ files:
|
|
181
189
|
- lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so
|
182
190
|
- lib/selenium/webdriver/ie/bridge.rb
|
183
191
|
- lib/selenium/webdriver/ie/lib.rb
|
184
|
-
- lib/selenium/webdriver/ie/
|
185
|
-
- lib/selenium/webdriver/ie/native/
|
186
|
-
- lib/selenium/webdriver/ie/native/x64/InternetExplorerDriver.dll
|
192
|
+
- lib/selenium/webdriver/ie/native/win32/IEDriver.dll
|
193
|
+
- lib/selenium/webdriver/ie/native/x64/IEDriver.dll
|
187
194
|
- lib/selenium/webdriver/iphone/bridge.rb
|
188
195
|
- lib/selenium/webdriver/remote/bridge.rb
|
189
196
|
- lib/selenium/webdriver/remote/capabilities.rb
|
@@ -205,6 +212,7 @@ rdoc_options: []
|
|
205
212
|
require_paths:
|
206
213
|
- lib
|
207
214
|
required_ruby_version: !ruby/object:Gem::Requirement
|
215
|
+
none: false
|
208
216
|
requirements:
|
209
217
|
- - ">="
|
210
218
|
- !ruby/object:Gem::Version
|
@@ -212,6 +220,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
220
|
- 0
|
213
221
|
version: "0"
|
214
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
|
+
none: false
|
215
224
|
requirements:
|
216
225
|
- - ">="
|
217
226
|
- !ruby/object:Gem::Version
|
@@ -221,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
230
|
requirements: []
|
222
231
|
|
223
232
|
rubyforge_project:
|
224
|
-
rubygems_version: 1.3.
|
233
|
+
rubygems_version: 1.3.7
|
225
234
|
signing_key:
|
226
235
|
specification_version: 3
|
227
236
|
summary: The next generation developer focused tool for automated testing of webapps
|
Binary file
|
Binary file
|
@@ -1,138 +0,0 @@
|
|
1
|
-
module Selenium
|
2
|
-
module WebDriver
|
3
|
-
module IE
|
4
|
-
|
5
|
-
#
|
6
|
-
# @private
|
7
|
-
#
|
8
|
-
|
9
|
-
module Util
|
10
|
-
CP_UTF8 = 65001
|
11
|
-
|
12
|
-
def string_array_from(raw_strings)
|
13
|
-
strings_ptr = raw_strings.get_pointer(0)
|
14
|
-
length_ptr = FFI::MemoryPointer.new :int
|
15
|
-
result = Lib.wdcGetStringCollectionLength(strings_ptr, length_ptr)
|
16
|
-
|
17
|
-
if result != 0
|
18
|
-
raise Error::WebDriverError, "cannot extract strings from collection, error code: #{result.inspect}"
|
19
|
-
end
|
20
|
-
|
21
|
-
arr = []
|
22
|
-
|
23
|
-
length_ptr.get_int(0).times do |idx|
|
24
|
-
str_ptr_ref = FFI::MemoryPointer.new :pointer
|
25
|
-
result = Lib.wdcGetStringAtIndex(strings_ptr, idx, str_ptr_ref)
|
26
|
-
|
27
|
-
if result != 0
|
28
|
-
raise Error::WebDriverError, "unable to get string at index: #{idx}, error: #{result}"
|
29
|
-
end
|
30
|
-
|
31
|
-
arr << extract_string_from(str_ptr_ref)
|
32
|
-
end
|
33
|
-
|
34
|
-
arr
|
35
|
-
ensure
|
36
|
-
Lib.wdFreeStringCollection(strings_ptr)
|
37
|
-
end
|
38
|
-
|
39
|
-
def create_element(&blk)
|
40
|
-
element_ptr_ref = FFI::MemoryPointer.new :pointer
|
41
|
-
yield element_ptr_ref
|
42
|
-
|
43
|
-
auto_ptr = FFI::AutoPointer.new(element_ptr_ref.get_pointer(0), Lib.method(:finalize_element))
|
44
|
-
Element.new(self, auto_ptr)
|
45
|
-
end
|
46
|
-
|
47
|
-
def create_element_collection(&blk)
|
48
|
-
elements_ptr_ref = FFI::MemoryPointer.new :pointer
|
49
|
-
yield elements_ptr_ref
|
50
|
-
|
51
|
-
extract_elements_from elements_ptr_ref
|
52
|
-
end
|
53
|
-
|
54
|
-
def create_string(&blk)
|
55
|
-
wrapper = FFI::MemoryPointer.new :pointer
|
56
|
-
yield wrapper
|
57
|
-
|
58
|
-
extract_string_from wrapper
|
59
|
-
end
|
60
|
-
|
61
|
-
def extract_string_from(string_ptr_ref)
|
62
|
-
string_ptr = string_ptr_ref.get_pointer(0)
|
63
|
-
return if string_ptr.null? # getElementAttribute()
|
64
|
-
|
65
|
-
length_ptr = FFI::MemoryPointer.new :int
|
66
|
-
|
67
|
-
if Lib.wdStringLength(string_ptr, length_ptr) != 0
|
68
|
-
raise Error::WebDriverError, "cannot determine length of string"
|
69
|
-
end
|
70
|
-
|
71
|
-
length = length_ptr.get_int(0)
|
72
|
-
raw_string = wstring_ptr(" "*length)
|
73
|
-
|
74
|
-
if Lib.wdCopyString(string_ptr, length, raw_string) != 0
|
75
|
-
raise Error::WebDriverError, "cannot copy string from native data to Ruby string"
|
76
|
-
end
|
77
|
-
|
78
|
-
wstring_to_bytestring raw_string
|
79
|
-
ensure
|
80
|
-
Lib.wdFreeString(string_ptr) unless string_ptr.null?
|
81
|
-
end
|
82
|
-
|
83
|
-
def extract_elements_from(elements_ptr_ref)
|
84
|
-
elements_ptr = elements_ptr_ref.get_pointer(0)
|
85
|
-
length_ptr = FFI::MemoryPointer.new :int
|
86
|
-
|
87
|
-
check_error_code Lib.wdcGetElementCollectionLength(elements_ptr, length_ptr),
|
88
|
-
"Cannot extract elements from collection"
|
89
|
-
|
90
|
-
arr = []
|
91
|
-
|
92
|
-
length_ptr.get_int(0).times do |idx|
|
93
|
-
arr << create_element do |ptr|
|
94
|
-
result = Lib.wdcGetElementAtIndex(elements_ptr, idx, ptr)
|
95
|
-
|
96
|
-
if e = WebDriver::Error.for_code(result)
|
97
|
-
Lib.wdFreeElementCollection(elements_ptr, 1)
|
98
|
-
raise e, "unable to create element from collection at index #{idx} (#{result})"
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
Lib.wdFreeElementCollection(elements_ptr, 0)
|
104
|
-
|
105
|
-
arr
|
106
|
-
end
|
107
|
-
|
108
|
-
def wstring_ptr(str)
|
109
|
-
str = str.to_s
|
110
|
-
size = Kernel32.MultiByteToWideChar(CP_UTF8, 0, str, -1, nil, 0)
|
111
|
-
|
112
|
-
unless size > 0
|
113
|
-
raise Error::WebDriverError, "unable to convert #{str.inspect} to wchar ptr"
|
114
|
-
end
|
115
|
-
|
116
|
-
buf = FFI::MemoryPointer.new :pointer, size
|
117
|
-
Kernel32.MultiByteToWideChar(CP_UTF8, 0, str, -1, buf, size)
|
118
|
-
|
119
|
-
buf
|
120
|
-
end
|
121
|
-
|
122
|
-
def wstring_to_bytestring(wstring)
|
123
|
-
size = Kernel32.WideCharToMultiByte(CP_UTF8, 0, wstring, -1, nil, 0, nil, nil)
|
124
|
-
|
125
|
-
unless size > 0
|
126
|
-
raise Error::WebDriverError, "could not convert wstring pointer to bytestring"
|
127
|
-
end
|
128
|
-
|
129
|
-
buf = FFI::MemoryPointer.new :pointer, size
|
130
|
-
Kernel32.WideCharToMultiByte(CP_UTF8, 0, wstring, -1, buf, size, nil, nil )
|
131
|
-
|
132
|
-
buf.get_bytes(0, size - 1)
|
133
|
-
end
|
134
|
-
|
135
|
-
end # Util
|
136
|
-
end # IE
|
137
|
-
end # WebDriver
|
138
|
-
end # Selenium
|