browserstack-webdriver 0.0.1
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.
- checksums.yaml +7 -0
- data/CHANGES +791 -0
- data/README.md +31 -0
- data/build.desc +334 -0
- data/lib/selenium-client.rb +2 -0
- data/lib/selenium-webdriver.rb +1 -0
- data/lib/selenium/client.rb +37 -0
- data/lib/selenium/client/base.rb +132 -0
- data/lib/selenium/client/driver.rb +10 -0
- data/lib/selenium/client/errors.rb +9 -0
- data/lib/selenium/client/extensions.rb +118 -0
- data/lib/selenium/client/idiomatic.rb +488 -0
- data/lib/selenium/client/javascript_expression_builder.rb +116 -0
- data/lib/selenium/client/javascript_frameworks/jquery.rb +13 -0
- data/lib/selenium/client/javascript_frameworks/prototype.rb +13 -0
- data/lib/selenium/client/legacy_driver.rb +1720 -0
- data/lib/selenium/client/protocol.rb +104 -0
- data/lib/selenium/client/selenium_helper.rb +34 -0
- data/lib/selenium/rake/server_task.rb +157 -0
- data/lib/selenium/server.rb +248 -0
- data/lib/selenium/webdriver.rb +71 -0
- data/lib/selenium/webdriver/android.rb +9 -0
- data/lib/selenium/webdriver/android/bridge.rb +47 -0
- data/lib/selenium/webdriver/chrome.rb +26 -0
- data/lib/selenium/webdriver/chrome/bridge.rb +120 -0
- data/lib/selenium/webdriver/chrome/profile.rb +90 -0
- data/lib/selenium/webdriver/chrome/service.rb +75 -0
- data/lib/selenium/webdriver/common.rb +44 -0
- data/lib/selenium/webdriver/common/action_builder.rb +352 -0
- data/lib/selenium/webdriver/common/alert.rb +30 -0
- data/lib/selenium/webdriver/common/bridge_helper.rb +67 -0
- data/lib/selenium/webdriver/common/core_ext/base64.rb +9 -0
- data/lib/selenium/webdriver/common/core_ext/dir.rb +42 -0
- data/lib/selenium/webdriver/common/core_ext/string.rb +5 -0
- data/lib/selenium/webdriver/common/driver.rb +301 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb +17 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +39 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +25 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +13 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +22 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +19 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +22 -0
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +45 -0
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +43 -0
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +46 -0
- data/lib/selenium/webdriver/common/element.rb +293 -0
- data/lib/selenium/webdriver/common/error.rb +207 -0
- data/lib/selenium/webdriver/common/file_reaper.rb +47 -0
- data/lib/selenium/webdriver/common/html5/local_storage.rb +42 -0
- data/lib/selenium/webdriver/common/html5/location.rb +0 -0
- data/lib/selenium/webdriver/common/html5/session_storage.rb +44 -0
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +42 -0
- data/lib/selenium/webdriver/common/json_helper.rb +34 -0
- data/lib/selenium/webdriver/common/keyboard.rb +55 -0
- data/lib/selenium/webdriver/common/keys.rb +109 -0
- data/lib/selenium/webdriver/common/log_entry.rb +29 -0
- data/lib/selenium/webdriver/common/logs.rb +23 -0
- data/lib/selenium/webdriver/common/mouse.rb +72 -0
- data/lib/selenium/webdriver/common/navigation.rb +43 -0
- data/lib/selenium/webdriver/common/options.rb +136 -0
- data/lib/selenium/webdriver/common/platform.rb +218 -0
- data/lib/selenium/webdriver/common/port_prober.rb +42 -0
- data/lib/selenium/webdriver/common/profile_helper.rb +67 -0
- data/lib/selenium/webdriver/common/proxy.rb +149 -0
- data/lib/selenium/webdriver/common/search_context.rb +92 -0
- data/lib/selenium/webdriver/common/socket_poller.rb +105 -0
- data/lib/selenium/webdriver/common/target_locator.rb +81 -0
- data/lib/selenium/webdriver/common/timeouts.rb +38 -0
- data/lib/selenium/webdriver/common/touch_action_builder.rb +64 -0
- data/lib/selenium/webdriver/common/touch_screen.rb +105 -0
- data/lib/selenium/webdriver/common/wait.rb +63 -0
- data/lib/selenium/webdriver/common/window.rb +104 -0
- data/lib/selenium/webdriver/common/zipper.rb +82 -0
- data/lib/selenium/webdriver/firefox.rb +37 -0
- data/lib/selenium/webdriver/firefox/binary.rb +158 -0
- data/lib/selenium/webdriver/firefox/bridge.rb +70 -0
- data/lib/selenium/webdriver/firefox/extension.rb +52 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +106 -0
- data/lib/selenium/webdriver/firefox/profile.rb +263 -0
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +62 -0
- data/lib/selenium/webdriver/firefox/socket_lock.rb +61 -0
- data/lib/selenium/webdriver/firefox/util.rb +29 -0
- data/lib/selenium/webdriver/ie.rb +19 -0
- data/lib/selenium/webdriver/ie/bridge.rb +68 -0
- data/lib/selenium/webdriver/ie/server.rb +86 -0
- data/lib/selenium/webdriver/iphone.rb +9 -0
- data/lib/selenium/webdriver/iphone/bridge.rb +45 -0
- data/lib/selenium/webdriver/opera.rb +24 -0
- data/lib/selenium/webdriver/opera/bridge.rb +112 -0
- data/lib/selenium/webdriver/opera/service.rb +49 -0
- data/lib/selenium/webdriver/phantomjs.rb +22 -0
- data/lib/selenium/webdriver/phantomjs/bridge.rb +59 -0
- data/lib/selenium/webdriver/phantomjs/service.rb +90 -0
- data/lib/selenium/webdriver/remote.rb +22 -0
- data/lib/selenium/webdriver/remote/bridge.rb +644 -0
- data/lib/selenium/webdriver/remote/capabilities.rb +267 -0
- data/lib/selenium/webdriver/remote/commands.rb +193 -0
- data/lib/selenium/webdriver/remote/http/common.rb +74 -0
- data/lib/selenium/webdriver/remote/http/curb.rb +79 -0
- data/lib/selenium/webdriver/remote/http/default.rb +139 -0
- data/lib/selenium/webdriver/remote/http/persistent.rb +38 -0
- data/lib/selenium/webdriver/remote/response.rb +97 -0
- data/lib/selenium/webdriver/remote/server_error.rb +17 -0
- data/lib/selenium/webdriver/safari.rb +46 -0
- data/lib/selenium/webdriver/safari/bridge.rb +110 -0
- data/lib/selenium/webdriver/safari/browser.rb +20 -0
- data/lib/selenium/webdriver/safari/extension.rb +120 -0
- data/lib/selenium/webdriver/safari/server.rb +145 -0
- data/lib/selenium/webdriver/support.rb +5 -0
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +28 -0
- data/lib/selenium/webdriver/support/block_event_listener.rb +17 -0
- data/lib/selenium/webdriver/support/color.rb +110 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +112 -0
- data/lib/selenium/webdriver/support/select.rb +293 -0
- data/ruby.iml +13 -0
- data/spec/integration/selenium/client/api/backward_compatible_api_spec.rb +22 -0
- data/spec/integration/selenium/client/api/browser_xpath_library_spec.rb +17 -0
- data/spec/integration/selenium/client/api/click_spec.rb +39 -0
- data/spec/integration/selenium/client/api/cookie_spec.rb +39 -0
- data/spec/integration/selenium/client/api/element_spec.rb +14 -0
- data/spec/integration/selenium/client/api/highlight_located_element_spec.rb +19 -0
- data/spec/integration/selenium/client/api/retrieve_last_remote_control_logs_spec.rb +33 -0
- data/spec/integration/selenium/client/api/screenshot_spec.rb +31 -0
- data/spec/integration/selenium/client/api/select_window_spec.rb +46 -0
- data/spec/integration/selenium/client/api/start_stop_spec.rb +9 -0
- data/spec/integration/selenium/client/api/wait_for_ajax_spec.rb +27 -0
- data/spec/integration/selenium/client/api/wait_for_element_spec.rb +56 -0
- data/spec/integration/selenium/client/api/wait_for_field_value_spec.rb +52 -0
- data/spec/integration/selenium/client/api/wait_for_text_spec.rb +98 -0
- data/spec/integration/selenium/client/api/webdriver_backed_spec.rb +21 -0
- data/spec/integration/selenium/client/sample-app/public/jquery-1.3.2.js +4376 -0
- data/spec/integration/selenium/client/sample-app/public/jquery.html +55 -0
- data/spec/integration/selenium/client/sample-app/public/prototype-1.6.0.3.js +4320 -0
- data/spec/integration/selenium/client/sample-app/public/prototype.html +59 -0
- data/spec/integration/selenium/client/sample-app/sample_app.rb +32 -0
- data/spec/integration/selenium/client/spec_helper.rb +139 -0
- data/spec/integration/selenium/webdriver/app_cache_spec.rb +47 -0
- data/spec/integration/selenium/webdriver/browser_connection_spec.rb +20 -0
- data/spec/integration/selenium/webdriver/chrome/driver_spec.rb +28 -0
- data/spec/integration/selenium/webdriver/chrome/profile_spec.rb +63 -0
- data/spec/integration/selenium/webdriver/driver_spec.rb +266 -0
- data/spec/integration/selenium/webdriver/element_spec.rb +191 -0
- data/spec/integration/selenium/webdriver/error_spec.rb +30 -0
- data/spec/integration/selenium/webdriver/firefox/driver_spec.rb +21 -0
- data/spec/integration/selenium/webdriver/firefox/profile_spec.rb +141 -0
- data/spec/integration/selenium/webdriver/keyboard_spec.rb +57 -0
- data/spec/integration/selenium/webdriver/location_spec.rb +29 -0
- data/spec/integration/selenium/webdriver/mouse_spec.rb +57 -0
- data/spec/integration/selenium/webdriver/navigation_spec.rb +46 -0
- data/spec/integration/selenium/webdriver/opera/driver_spec.rb +47 -0
- data/spec/integration/selenium/webdriver/options_spec.rb +77 -0
- data/spec/integration/selenium/webdriver/remote/driver_spec.rb +19 -0
- data/spec/integration/selenium/webdriver/remote/element_spec.rb +26 -0
- data/spec/integration/selenium/webdriver/spec_helper.rb +36 -0
- data/spec/integration/selenium/webdriver/spec_support.rb +12 -0
- data/spec/integration/selenium/webdriver/spec_support/guards.rb +110 -0
- data/spec/integration/selenium/webdriver/spec_support/helpers.rb +51 -0
- data/spec/integration/selenium/webdriver/spec_support/rack_server.rb +123 -0
- data/spec/integration/selenium/webdriver/spec_support/test_environment.rb +239 -0
- data/spec/integration/selenium/webdriver/sql_database_spec.rb +59 -0
- data/spec/integration/selenium/webdriver/storage_spec.rb +96 -0
- data/spec/integration/selenium/webdriver/target_locator_spec.rb +186 -0
- data/spec/integration/selenium/webdriver/timeout_spec.rb +69 -0
- data/spec/integration/selenium/webdriver/touch_spec.rb +176 -0
- data/spec/integration/selenium/webdriver/window_spec.rb +70 -0
- data/spec/integration/selenium/webdriver/zipper_spec.rb +66 -0
- data/spec/unit/selenium/client/base_spec.rb +239 -0
- data/spec/unit/selenium/client/extensions_spec.rb +174 -0
- data/spec/unit/selenium/client/idiomatic_spec.rb +500 -0
- data/spec/unit/selenium/client/javascript_expression_builder_spec.rb +79 -0
- data/spec/unit/selenium/client/javascript_frameworks/jquery_spec.rb +10 -0
- data/spec/unit/selenium/client/javascript_frameworks/prototype_spec.rb +10 -0
- data/spec/unit/selenium/client/protocol_spec.rb +124 -0
- data/spec/unit/selenium/client/selenium_helper_spec.rb +56 -0
- data/spec/unit/selenium/client/spec_helper.rb +24 -0
- data/spec/unit/selenium/rake/task_spec.rb +79 -0
- data/spec/unit/selenium/server_spec.rb +150 -0
- data/spec/unit/selenium/webdriver/action_builder_spec.rb +97 -0
- data/spec/unit/selenium/webdriver/android/bridge_spec.rb +43 -0
- data/spec/unit/selenium/webdriver/chrome/bridge_spec.rb +137 -0
- data/spec/unit/selenium/webdriver/chrome/profile_spec.rb +57 -0
- data/spec/unit/selenium/webdriver/chrome/service_spec.rb +44 -0
- data/spec/unit/selenium/webdriver/error_spec.rb +41 -0
- data/spec/unit/selenium/webdriver/firefox/bridge_spec.rb +47 -0
- data/spec/unit/selenium/webdriver/ie/bridge_spec.rb +91 -0
- data/spec/unit/selenium/webdriver/iphone/bridge_spec.rb +42 -0
- data/spec/unit/selenium/webdriver/log_entry_spec.rb +11 -0
- data/spec/unit/selenium/webdriver/opera/bridge_spec.rb +44 -0
- data/spec/unit/selenium/webdriver/phantomjs/bridge_spec.rb +55 -0
- data/spec/unit/selenium/webdriver/proxy_spec.rb +106 -0
- data/spec/unit/selenium/webdriver/remote/bridge_spec.rb +16 -0
- data/spec/unit/selenium/webdriver/remote/capabilities_spec.rb +115 -0
- data/spec/unit/selenium/webdriver/remote/http/common_spec.rb +24 -0
- data/spec/unit/selenium/webdriver/remote/http/default_spec.rb +124 -0
- data/spec/unit/selenium/webdriver/search_context_spec.rb +61 -0
- data/spec/unit/selenium/webdriver/socket_poller_spec.rb +68 -0
- data/spec/unit/selenium/webdriver/spec_helper.rb +27 -0
- data/spec/unit/selenium/webdriver/support/color_spec.rb +119 -0
- data/spec/unit/selenium/webdriver/support/event_firing_spec.rb +111 -0
- data/spec/unit/selenium/webdriver/support/select_spec.rb +290 -0
- data/spec/unit/selenium/webdriver/wait_spec.rb +49 -0
- metadata +370 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
class Dir
|
|
2
|
+
# @api private
|
|
3
|
+
def self.mktmpdir(prefix_suffix=nil, tmpdir=nil)
|
|
4
|
+
case prefix_suffix
|
|
5
|
+
when nil
|
|
6
|
+
prefix = "d"
|
|
7
|
+
suffix = ""
|
|
8
|
+
when String
|
|
9
|
+
prefix = prefix_suffix
|
|
10
|
+
suffix = ""
|
|
11
|
+
when Array
|
|
12
|
+
prefix = prefix_suffix[0]
|
|
13
|
+
suffix = prefix_suffix[1]
|
|
14
|
+
else
|
|
15
|
+
raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
|
|
16
|
+
end
|
|
17
|
+
tmpdir ||= Dir.tmpdir
|
|
18
|
+
t = Time.now.strftime("%Y%m%d")
|
|
19
|
+
n = nil
|
|
20
|
+
begin
|
|
21
|
+
path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
|
22
|
+
path << "-#{n}" if n
|
|
23
|
+
path << suffix
|
|
24
|
+
Dir.mkdir(path, 0700)
|
|
25
|
+
rescue Errno::EEXIST
|
|
26
|
+
n ||= 0
|
|
27
|
+
n += 1
|
|
28
|
+
retry
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
if block_given?
|
|
32
|
+
begin
|
|
33
|
+
yield path
|
|
34
|
+
ensure
|
|
35
|
+
FileUtils.remove_entry_secure path
|
|
36
|
+
end
|
|
37
|
+
else
|
|
38
|
+
path
|
|
39
|
+
end
|
|
40
|
+
end unless respond_to? :mktmpdir # > 1.8.7
|
|
41
|
+
end
|
|
42
|
+
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# The main class through which you control the browser.
|
|
6
|
+
#
|
|
7
|
+
# @see SearchContext
|
|
8
|
+
# @see Navigation
|
|
9
|
+
# @see TargetLocator
|
|
10
|
+
# @see Options
|
|
11
|
+
#
|
|
12
|
+
|
|
13
|
+
class Driver
|
|
14
|
+
include SearchContext
|
|
15
|
+
|
|
16
|
+
class << self
|
|
17
|
+
|
|
18
|
+
#
|
|
19
|
+
# @api private
|
|
20
|
+
#
|
|
21
|
+
# @see Selenium::WebDriver.for
|
|
22
|
+
#
|
|
23
|
+
# @return [Driver]
|
|
24
|
+
#
|
|
25
|
+
|
|
26
|
+
def for(browser, opts = {})
|
|
27
|
+
listener = opts.delete(:listener)
|
|
28
|
+
|
|
29
|
+
bridge = case browser
|
|
30
|
+
when :firefox, :ff
|
|
31
|
+
Firefox::Bridge.new(opts)
|
|
32
|
+
when :remote
|
|
33
|
+
Remote::Bridge.new(opts)
|
|
34
|
+
when :ie, :internet_explorer
|
|
35
|
+
IE::Bridge.new(opts)
|
|
36
|
+
when :chrome
|
|
37
|
+
Chrome::Bridge.new(opts)
|
|
38
|
+
when :android
|
|
39
|
+
Android::Bridge.new(opts)
|
|
40
|
+
when :iphone
|
|
41
|
+
IPhone::Bridge.new(opts)
|
|
42
|
+
when :opera
|
|
43
|
+
Opera::Bridge.new(opts)
|
|
44
|
+
when :phantomjs
|
|
45
|
+
PhantomJS::Bridge.new(opts)
|
|
46
|
+
when :safari
|
|
47
|
+
Safari::Bridge.new(opts)
|
|
48
|
+
else
|
|
49
|
+
raise ArgumentError, "unknown driver: #{browser.inspect}"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
bridge = Support::EventFiringBridge.new(bridge, listener) if listener
|
|
53
|
+
|
|
54
|
+
new(bridge)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
#
|
|
59
|
+
# A new Driver instance with the given bridge.
|
|
60
|
+
# End users should use Selenium::WebDriver.for instead of using this directly.
|
|
61
|
+
#
|
|
62
|
+
# @api private
|
|
63
|
+
#
|
|
64
|
+
|
|
65
|
+
def initialize(bridge)
|
|
66
|
+
@bridge = bridge
|
|
67
|
+
|
|
68
|
+
# TODO: refactor this away
|
|
69
|
+
unless bridge.driver_extensions.empty?
|
|
70
|
+
extend(*bridge.driver_extensions)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def inspect
|
|
75
|
+
'#<%s:0x%x browser=%s>' % [self.class, hash*2, bridge.browser.inspect]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
#
|
|
79
|
+
# @return [Navigation]
|
|
80
|
+
# @see Navigation
|
|
81
|
+
#
|
|
82
|
+
|
|
83
|
+
def navigate
|
|
84
|
+
@navigate ||= WebDriver::Navigation.new(bridge)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
#
|
|
88
|
+
# @return [TargetLocator]
|
|
89
|
+
# @see TargetLocator
|
|
90
|
+
#
|
|
91
|
+
|
|
92
|
+
def switch_to
|
|
93
|
+
@switch_to ||= WebDriver::TargetLocator.new(bridge)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
#
|
|
97
|
+
# @return [Options]
|
|
98
|
+
# @see Options
|
|
99
|
+
#
|
|
100
|
+
|
|
101
|
+
def manage
|
|
102
|
+
@manage ||= WebDriver::Options.new(bridge)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
#
|
|
106
|
+
# Opens the specified URL in the browser.
|
|
107
|
+
#
|
|
108
|
+
|
|
109
|
+
def get(url)
|
|
110
|
+
navigate.to(url)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
#
|
|
114
|
+
# Get the URL of the current page
|
|
115
|
+
#
|
|
116
|
+
# @return [String]
|
|
117
|
+
#
|
|
118
|
+
|
|
119
|
+
def current_url
|
|
120
|
+
bridge.getCurrentUrl
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
#
|
|
124
|
+
# Get the title of the current page
|
|
125
|
+
#
|
|
126
|
+
# @return [String]
|
|
127
|
+
#
|
|
128
|
+
|
|
129
|
+
def title
|
|
130
|
+
bridge.getTitle
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
#
|
|
134
|
+
# Get the source of the current page
|
|
135
|
+
#
|
|
136
|
+
# @return [String]
|
|
137
|
+
#
|
|
138
|
+
|
|
139
|
+
def page_source
|
|
140
|
+
bridge.getPageSource
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
#
|
|
144
|
+
# Get the visibility of the browser. Not applicable for all browsers.
|
|
145
|
+
#
|
|
146
|
+
# @return [Boolean]
|
|
147
|
+
#
|
|
148
|
+
|
|
149
|
+
def visible?
|
|
150
|
+
bridge.getBrowserVisible
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
#
|
|
154
|
+
# Set the visibility of the browser. Not applicable for all browsers.
|
|
155
|
+
#
|
|
156
|
+
# @param [Boolean]
|
|
157
|
+
#
|
|
158
|
+
|
|
159
|
+
def visible=(bool)
|
|
160
|
+
bridge.setBrowserVisible bool
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
#
|
|
164
|
+
# Quit the browser
|
|
165
|
+
#
|
|
166
|
+
|
|
167
|
+
def quit
|
|
168
|
+
bridge.quit
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
#
|
|
172
|
+
# Close the current window, or the browser if no windows are left.
|
|
173
|
+
#
|
|
174
|
+
|
|
175
|
+
def close
|
|
176
|
+
bridge.close
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
#
|
|
180
|
+
# Get the window handles of open browser windows.
|
|
181
|
+
#
|
|
182
|
+
# @return [Array]
|
|
183
|
+
# @see TargetLocator#window
|
|
184
|
+
#
|
|
185
|
+
|
|
186
|
+
def window_handles
|
|
187
|
+
bridge.getWindowHandles
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
#
|
|
191
|
+
# Get the current window handle
|
|
192
|
+
#
|
|
193
|
+
# @return [String]
|
|
194
|
+
#
|
|
195
|
+
|
|
196
|
+
def window_handle
|
|
197
|
+
bridge.getCurrentWindowHandle
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
#
|
|
201
|
+
# Execute the given JavaScript
|
|
202
|
+
#
|
|
203
|
+
# @param [String] script
|
|
204
|
+
# JavaScript source to execute
|
|
205
|
+
# @param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array] *args
|
|
206
|
+
# Arguments will be available in the given script in the 'arguments' pseudo-array.
|
|
207
|
+
#
|
|
208
|
+
# @return [WebDriver::Element,Integer,Float,Boolean,NilClass,String,Array]
|
|
209
|
+
# The value returned from the script.
|
|
210
|
+
#
|
|
211
|
+
|
|
212
|
+
def execute_script(script, *args)
|
|
213
|
+
bridge.executeScript(script, *args)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# Execute an asynchronous piece of JavaScript in the context of the
|
|
217
|
+
# currently selected frame or window. Unlike executing
|
|
218
|
+
# execute_script (synchronous JavaScript), scripts
|
|
219
|
+
# executed with this method must explicitly signal they are finished by
|
|
220
|
+
# invoking the provided callback. This callback is always injected into the
|
|
221
|
+
# executed function as the last argument.
|
|
222
|
+
#
|
|
223
|
+
# @param [String] script
|
|
224
|
+
# JavaSCript source to execute
|
|
225
|
+
# @param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array] *args
|
|
226
|
+
# Arguments to the script. May be empty.
|
|
227
|
+
#
|
|
228
|
+
# @return [WebDriver::Element,Integer,Float,Boolean,NilClass,String,Array]
|
|
229
|
+
#
|
|
230
|
+
|
|
231
|
+
def execute_async_script(script, *args)
|
|
232
|
+
bridge.executeAsyncScript(script, *args)
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
#-------------------------------- sugar --------------------------------
|
|
237
|
+
|
|
238
|
+
#
|
|
239
|
+
# driver.first(:id, 'foo')
|
|
240
|
+
#
|
|
241
|
+
|
|
242
|
+
alias_method :first, :find_element
|
|
243
|
+
|
|
244
|
+
#
|
|
245
|
+
# driver.all(:class, 'bar') #=> [#<WebDriver::Element:0x1011c3b88, ...]
|
|
246
|
+
#
|
|
247
|
+
|
|
248
|
+
alias_method :all, :find_elements
|
|
249
|
+
|
|
250
|
+
#
|
|
251
|
+
# driver.script('function() { ... };')
|
|
252
|
+
#
|
|
253
|
+
|
|
254
|
+
alias_method :script, :execute_script
|
|
255
|
+
|
|
256
|
+
# Get the first element matching the given selector. If given a
|
|
257
|
+
# String or Symbol, it will be used as the id of the element.
|
|
258
|
+
#
|
|
259
|
+
# @param [String,Hash] id or selector
|
|
260
|
+
# @return [WebDriver::Element]
|
|
261
|
+
#
|
|
262
|
+
# Examples:
|
|
263
|
+
#
|
|
264
|
+
# driver['someElementId'] #=> #<WebDriver::Element:0x1011c3b88>
|
|
265
|
+
# driver[:tag_name => 'div'] #=> #<WebDriver::Element:0x1011c3b88>
|
|
266
|
+
#
|
|
267
|
+
|
|
268
|
+
def [](sel)
|
|
269
|
+
if sel.kind_of?(String) || sel.kind_of?(Symbol)
|
|
270
|
+
sel = { :id => sel }
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
find_element sel
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def browser
|
|
277
|
+
bridge.browser
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def capabilities
|
|
281
|
+
bridge.capabilities
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
#
|
|
285
|
+
# @api private
|
|
286
|
+
# @see SearchContext
|
|
287
|
+
#
|
|
288
|
+
|
|
289
|
+
def ref
|
|
290
|
+
nil
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
private
|
|
294
|
+
|
|
295
|
+
def bridge
|
|
296
|
+
@bridge
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
end # Driver
|
|
300
|
+
end # WebDriver
|
|
301
|
+
end # Selenium
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# @api private
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
module DriverExtensions
|
|
9
|
+
module HasInputDevices
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# @return [ActionBuilder]
|
|
13
|
+
# @api public
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
def action
|
|
17
|
+
ActionBuilder.new mouse, keyboard
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
#
|
|
21
|
+
# @api private
|
|
22
|
+
#
|
|
23
|
+
|
|
24
|
+
def mouse
|
|
25
|
+
Mouse.new @bridge
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
#
|
|
29
|
+
# @api private
|
|
30
|
+
#
|
|
31
|
+
|
|
32
|
+
def keyboard
|
|
33
|
+
Keyboard.new @bridge
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end # HasInputDevices
|
|
37
|
+
end # DriverExtensions
|
|
38
|
+
end # WebDriver
|
|
39
|
+
end # Selenium
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
module DriverExtensions
|
|
4
|
+
|
|
5
|
+
module HasLocation
|
|
6
|
+
def location
|
|
7
|
+
@bridge.getLocation
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def location=(loc)
|
|
11
|
+
unless loc.kind_of?(Location)
|
|
12
|
+
raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
@bridge.setLocation loc.latitude, loc.longitude, loc.altitude
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def set_location(lat, lon, alt)
|
|
19
|
+
self.location = Location.new(Float(lat), Float(lon), Float(alt))
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|