Class: Capybara::Webkit::Driver
- Inherits:
-
Driver::Base
- Object
- Driver::Base
- Capybara::Webkit::Driver
- Defined in:
- lib/capybara/webkit/driver.rb
Instance Method Summary collapse
- #accept_js_confirms! ⇒ Object
- #accept_js_prompts! ⇒ Object
- #accept_modal(type, options = {}) ⇒ Object
- #alert_messages ⇒ Object
- #allow_unknown_urls ⇒ Object
- #allow_url(url) ⇒ Object
- #authenticate(username, password) ⇒ Object
- #block_unknown_urls ⇒ Object
- #block_url(url) ⇒ Object
- #browser ⇒ Object
- #clear_cookies ⇒ Object
- #close_window(selector) ⇒ Object
- #confirm_messages ⇒ Object
- #console_messages ⇒ Object
- #cookies ⇒ Object
- #current_url ⇒ Object
- #current_window_handle ⇒ Object
- #dismiss_js_confirms! ⇒ Object
- #dismiss_js_prompts! ⇒ Object
- #dismiss_modal(type, options = {}) ⇒ Object
- #enable_logging ⇒ Object
- #error_messages ⇒ Object
- #evaluate_async_script(script, *args) ⇒ Object
- #evaluate_script(script, *args) ⇒ Object
- #execute_script(script, *args) ⇒ Object
- #find_css(selector) ⇒ Object
- #find_xpath(xpath) ⇒ Object (also: #find)
- #go_back ⇒ Object
- #go_forward ⇒ Object
- #has_shortcircuit_timeout? ⇒ Boolean
- #header(key, value) ⇒ Object
- #html ⇒ Object
-
#initialize(app, options = {}) ⇒ Driver
constructor
A new instance of Driver.
- #invalid_element_errors ⇒ Object
- #js_prompt_input=(value) ⇒ Object
- #maximize_window(selector) ⇒ Object
- #needs_server? ⇒ Boolean
- #no_such_window_error ⇒ Object
- #open_new_window ⇒ Object
- #prompt_messages ⇒ Object
- #refresh ⇒ Object
- #reset! ⇒ Object
- #resize_window(width, height) ⇒ Object
- #resize_window_to(handle, width, height) ⇒ Object
- #response_headers ⇒ Object
- #save_screenshot(path, options = {}) ⇒ Object
- #set_cookie(cookie) ⇒ Object
- #status_code ⇒ Object
- #switch_to_frame(frame) ⇒ Object
- #switch_to_window(selector) ⇒ Object
- #timeout ⇒ Object
- #timeout=(timeout) ⇒ Object
- #title ⇒ Object
- #version ⇒ Object
- #visit(path) ⇒ Object
- #wait? ⇒ Boolean
- #window_handles ⇒ Object
- #window_size(handle) ⇒ Object
- #within_frame(selector) ⇒ Object
- #within_window(selector) ⇒ Object
Constructor Details
Instance Method Details
#accept_js_confirms! ⇒ Object
207 208 209 210 211 |
# File 'lib/capybara/webkit/driver.rb', line 207 def accept_js_confirms! warn '[DEPRECATION] Capybara::Webkit::Driver#accept_js_confirms! ' \ 'is deprecated. Please use Capybara::Session#accept_confirm instead.' @browser.accept_js_confirms end |
#accept_js_prompts! ⇒ Object
219 220 221 222 223 |
# File 'lib/capybara/webkit/driver.rb', line 219 def accept_js_prompts! warn '[DEPRECATION] Capybara::Webkit::Driver#accept_js_prompts! ' \ 'is deprecated. Please use Capybara::Session#accept_prompt instead.' @browser.accept_js_prompts end |
#accept_modal(type, options = {}) ⇒ Object
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/capybara/webkit/driver.rb', line 253 def accept_modal(type, ={}) = () case type when :confirm id = @browser.accept_confirm() when :prompt id = @browser.accept_prompt() else id = @browser.accept_alert() end yield find_modal(type, id, ) end |
#alert_messages ⇒ Object
107 108 109 110 111 |
# File 'lib/capybara/webkit/driver.rb', line 107 def warn '[DEPRECATION] Capybara::Webkit::Driver#alert_messages ' \ 'is deprecated. Please use Capybara::Session#accept_alert instead.' @browser. end |
#allow_unknown_urls ⇒ Object
40 41 42 43 |
# File 'lib/capybara/webkit/driver.rb', line 40 def allow_unknown_urls deprecate_and_replace_with_config "allow_unknown_urls" @browser.allow_url("*") end |
#allow_url(url) ⇒ Object
25 26 27 28 |
# File 'lib/capybara/webkit/driver.rb', line 25 def allow_url(url) deprecate_and_replace_with_config "allow_url", "allow_url(#{url.inspect})" @browser.allow_url(url) end |
#authenticate(username, password) ⇒ Object
338 339 340 |
# File 'lib/capybara/webkit/driver.rb', line 338 def authenticate(username, password) @browser.authenticate(username, password) end |
#block_unknown_urls ⇒ Object
35 36 37 38 |
# File 'lib/capybara/webkit/driver.rb', line 35 def block_unknown_urls deprecate_and_replace_with_config "block_unknown_urls" @browser.block_unknown_urls end |
#block_url(url) ⇒ Object
30 31 32 33 |
# File 'lib/capybara/webkit/driver.rb', line 30 def block_url(url) deprecate_and_replace_with_config "block_url", "block_url(#{url.inspect})" @browser.block_url(url) end |
#browser ⇒ Object
355 356 357 358 |
# File 'lib/capybara/webkit/driver.rb', line 355 def browser warn "[DEPRECATION] Capybara::Webkit::Driver#browser is deprecated." @browser end |
#clear_cookies ⇒ Object
317 318 319 |
# File 'lib/capybara/webkit/driver.rb', line 317 def @browser. end |
#close_window(selector) ⇒ Object
199 200 201 |
# File 'lib/capybara/webkit/driver.rb', line 199 def close_window(selector) @browser.window_close(selector) end |
#confirm_messages ⇒ Object
113 114 115 116 117 118 |
# File 'lib/capybara/webkit/driver.rb', line 113 def warn '[DEPRECATION] Capybara::Webkit::Driver#confirm_messages ' \ 'is deprecated. Please use Capybara::Session#accept_confirm ' \ 'or Capybara::Session#dismiss_confirm instead.' @browser. end |
#console_messages ⇒ Object
99 100 101 |
# File 'lib/capybara/webkit/driver.rb', line 99 def @browser. end |
#cookies ⇒ Object
309 310 311 |
# File 'lib/capybara/webkit/driver.rb', line 309 def @cookie_jar ||= CookieJar.new(@browser) end |
#current_url ⇒ Object
45 46 47 |
# File 'lib/capybara/webkit/driver.rb', line 45 def current_url @browser.current_url end |
#current_window_handle ⇒ Object
191 192 193 |
# File 'lib/capybara/webkit/driver.rb', line 191 def current_window_handle @browser.get_window_handle end |
#dismiss_js_confirms! ⇒ Object
213 214 215 216 217 |
# File 'lib/capybara/webkit/driver.rb', line 213 def dismiss_js_confirms! warn '[DEPRECATION] Capybara::Webkit::Driver#dismiss_js_confirms! ' \ 'is deprecated. Please use Capybara::Session#dismiss_confirm instead.' @browser.reject_js_confirms end |
#dismiss_js_prompts! ⇒ Object
225 226 227 228 229 |
# File 'lib/capybara/webkit/driver.rb', line 225 def dismiss_js_prompts! warn '[DEPRECATION] Capybara::Webkit::Driver#dismiss_js_prompts! ' \ 'is deprecated. Please use Capybara::Session#dismiss_prompt instead.' @browser.reject_js_prompts end |
#dismiss_modal(type, options = {}) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/capybara/webkit/driver.rb', line 270 def dismiss_modal(type, ={}) = () case type when :confirm id = @browser.reject_confirm() else id = @browser.reject_prompt() end yield find_modal(type, id, ) end |
#enable_logging ⇒ Object
20 21 22 23 |
# File 'lib/capybara/webkit/driver.rb', line 20 def enable_logging deprecate_and_replace_with_config "enable_logging", "debug = true" @browser.enable_logging end |
#error_messages ⇒ Object
103 104 105 |
# File 'lib/capybara/webkit/driver.rb', line 103 def @browser. end |
#evaluate_async_script(script, *args) ⇒ Object
94 95 96 97 |
# File 'lib/capybara/webkit/driver.rb', line 94 def evaluate_async_script(script, *args) result = @browser.evaluate_async_script(script, *encode_args(args)) decode_result(result) end |
#evaluate_script(script, *args) ⇒ Object
89 90 91 92 |
# File 'lib/capybara/webkit/driver.rb', line 89 def evaluate_script(script, *args) result = @browser.evaluate_script(script, *encode_args(args)) decode_result(result) end |
#execute_script(script, *args) ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/capybara/webkit/driver.rb', line 79 def execute_script(script, *args) value = @browser.execute_script(script, *encode_args(args)) if value.empty? nil else value end end |
#find_css(selector) ⇒ Object
61 62 63 64 65 |
# File 'lib/capybara/webkit/driver.rb', line 61 def find_css(selector) @browser. find_css(selector). map { |native| Node.new(self, native, @browser) } end |
#find_xpath(xpath) ⇒ Object Also known as: find
53 54 55 56 57 |
# File 'lib/capybara/webkit/driver.rb', line 53 def find_xpath(xpath) @browser. find_xpath(xpath). map { |native| Node.new(self, native, @browser) } end |
#go_back ⇒ Object
241 242 243 |
# File 'lib/capybara/webkit/driver.rb', line 241 def go_back @browser.go_back end |
#go_forward ⇒ Object
245 246 247 |
# File 'lib/capybara/webkit/driver.rb', line 245 def go_forward @browser.go_forward end |
#has_shortcircuit_timeout? ⇒ Boolean
298 299 300 |
# File 'lib/capybara/webkit/driver.rb', line 298 def has_shortcircuit_timeout? false end |
#header(key, value) ⇒ Object
71 72 73 |
# File 'lib/capybara/webkit/driver.rb', line 71 def header(key, value) @browser.header(key, value) end |
#html ⇒ Object
67 68 69 |
# File 'lib/capybara/webkit/driver.rb', line 67 def html @browser.body end |
#invalid_element_errors ⇒ Object
321 322 323 324 |
# File 'lib/capybara/webkit/driver.rb', line 321 def invalid_element_errors [Capybara::Webkit::ClickFailed, Capybara::Webkit::NodeNotAttachedError] end |
#js_prompt_input=(value) ⇒ Object
231 232 233 234 235 236 237 238 239 |
# File 'lib/capybara/webkit/driver.rb', line 231 def js_prompt_input=(value) warn '[DEPRECATION] Capybara::Webkit::Driver#js_prompt_input= ' \ 'is deprecated. Please use Capybara::Session#accept_prompt instead.' if value.nil? @browser.clear_prompt_text else @browser.set_prompt_text_to(value) end end |
#maximize_window(selector) ⇒ Object
203 204 205 |
# File 'lib/capybara/webkit/driver.rb', line 203 def maximize_window(selector) @browser.window_maximize(selector) end |
#needs_server? ⇒ Boolean
289 290 291 |
# File 'lib/capybara/webkit/driver.rb', line 289 def needs_server? true end |
#no_such_window_error ⇒ Object
326 327 328 |
# File 'lib/capybara/webkit/driver.rb', line 326 def no_such_window_error Capybara::Webkit::NoSuchWindowError end |
#open_new_window ⇒ Object
195 196 197 |
# File 'lib/capybara/webkit/driver.rb', line 195 def open_new_window @browser.window_open end |
#prompt_messages ⇒ Object
120 121 122 123 124 125 |
# File 'lib/capybara/webkit/driver.rb', line 120 def warn '[DEPRECATION] Capybara::Webkit::Driver#prompt_messages ' \ 'is deprecated. Please use Capybara::Session#accept_prompt ' \ 'or Capybara::Session#dismiss_prompt instead.' @browser. end |
#refresh ⇒ Object
249 250 251 |
# File 'lib/capybara/webkit/driver.rb', line 249 def refresh @browser.refresh end |
#reset! ⇒ Object
293 294 295 296 |
# File 'lib/capybara/webkit/driver.rb', line 293 def reset! @browser.reset! end |
#resize_window(width, height) ⇒ Object
135 136 137 138 139 |
# File 'lib/capybara/webkit/driver.rb', line 135 def resize_window(width, height) warn '[DEPRECATION] Capybara::Webkit::Driver#resize_window ' \ 'is deprecated. Please use Capybara::Window#resize_to instead.' resize_window_to(current_window_handle, width, height) end |
#resize_window_to(handle, width, height) ⇒ Object
141 142 143 |
# File 'lib/capybara/webkit/driver.rb', line 141 def resize_window_to(handle, width, height) @browser.window_resize(handle, width, height) end |
#response_headers ⇒ Object
127 128 129 |
# File 'lib/capybara/webkit/driver.rb', line 127 def response_headers @browser.response_headers end |
#save_screenshot(path, options = {}) ⇒ Object
302 303 304 305 306 307 |
# File 'lib/capybara/webkit/driver.rb', line 302 def save_screenshot(path, ={}) [:width] ||= 1000 [:height] ||= 10 @browser.render path, [:width], [:height] end |
#set_cookie(cookie) ⇒ Object
313 314 315 |
# File 'lib/capybara/webkit/driver.rb', line 313 def () @browser.() end |
#status_code ⇒ Object
131 132 133 |
# File 'lib/capybara/webkit/driver.rb', line 131 def status_code @browser.status_code end |
#switch_to_frame(frame) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/capybara/webkit/driver.rb', line 158 def switch_to_frame(frame) case frame when :top begin loop { @browser.frame_focus } rescue Capybara::Webkit::InvalidResponseError => e raise unless e. =~ /Already at parent frame/ end when :parent @browser.frame_focus else @browser.frame_focus(frame) end end |
#switch_to_window(selector) ⇒ Object
183 184 185 |
# File 'lib/capybara/webkit/driver.rb', line 183 def switch_to_window(selector) @browser.window_focus(selector) end |
#timeout ⇒ Object
342 343 344 345 |
# File 'lib/capybara/webkit/driver.rb', line 342 def timeout deprecate_and_replace_with_config "timeout" @browser.timeout end |
#timeout=(timeout) ⇒ Object
347 348 349 350 351 352 353 |
# File 'lib/capybara/webkit/driver.rb', line 347 def timeout=(timeout) deprecate_and_replace_with_config( "timeout=", "timeout = #{timeout.inspect}" ) @browser.timeout = timeout end |
#title ⇒ Object
75 76 77 |
# File 'lib/capybara/webkit/driver.rb', line 75 def title @browser.title end |
#version ⇒ Object
330 331 332 333 334 335 336 |
# File 'lib/capybara/webkit/driver.rb', line 330 def version [ "Capybara: #{Capybara::VERSION}", "capybara-webkit: #{Capybara::Driver::Webkit::VERSION}", @browser.version ].join("\n") end |
#visit(path) ⇒ Object
49 50 51 |
# File 'lib/capybara/webkit/driver.rb', line 49 def visit(path) @browser.visit(path) end |
#wait? ⇒ Boolean
285 286 287 |
# File 'lib/capybara/webkit/driver.rb', line 285 def wait? true end |
#window_handles ⇒ Object
187 188 189 |
# File 'lib/capybara/webkit/driver.rb', line 187 def window_handles @browser.get_window_handles end |
#window_size(handle) ⇒ Object
145 146 147 |
# File 'lib/capybara/webkit/driver.rb', line 145 def window_size(handle) @browser.window_size(handle) end |
#within_frame(selector) ⇒ Object
149 150 151 152 153 154 155 156 |
# File 'lib/capybara/webkit/driver.rb', line 149 def within_frame(selector) @browser.frame_focus(selector) begin yield ensure @browser.frame_focus end end |
#within_window(selector) ⇒ Object
173 174 175 176 177 178 179 180 181 |
# File 'lib/capybara/webkit/driver.rb', line 173 def within_window(selector) current_window = current_window_handle switch_to_window(selector) begin yield ensure @browser.window_focus(current_window) end end |