Class: Capybara::Webkit::Driver
- Inherits:
-
Object
- Object
- Capybara::Webkit::Driver
- Defined in:
- lib/capybara/webkit/driver.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
Instance Method Summary collapse
- #body ⇒ Object
- #console_messages ⇒ Object
- #cookies ⇒ Object
- #current_url ⇒ Object
- #enable_logging ⇒ Object
- #error_messages ⇒ Object
- #evaluate_script(script) ⇒ Object
- #execute_script(script) ⇒ Object
- #find(query) ⇒ Object
- #has_shortcircuit_timeout? ⇒ Boolean
- #header(key, value) ⇒ Object
-
#initialize(app, options = {}) ⇒ Driver
constructor
A new instance of Driver.
- #invalid_element_errors ⇒ Object
- #render(path, options = {}) ⇒ Object
- #requested_url ⇒ Object
- #reset! ⇒ Object
- #resize_window(width, height) ⇒ Object
- #response_headers ⇒ Object
- #server_port ⇒ Object
- #source ⇒ Object
- #status_code ⇒ Object
- #visit(path) ⇒ Object
- #wait? ⇒ Boolean
- #wait_until(*args) ⇒ Object
- #window_handle ⇒ Object
- #window_handles ⇒ Object
- #within_frame(frame_id_or_index) ⇒ Object
- #within_window(selector) ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ Driver
Returns a new instance of Driver.
14 15 16 17 18 19 20 |
# File 'lib/capybara/webkit/driver.rb', line 14 def initialize(app, ={}) @app = app @options = @rack_server = Capybara::Server.new(@app) @rack_server.boot if Capybara.run_server @browser = [:browser] || Browser.new(Connection.new()) end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
12 13 14 |
# File 'lib/capybara/webkit/driver.rb', line 12 def browser @browser end |
Instance Method Details
#body ⇒ Object
46 47 48 |
# File 'lib/capybara/webkit/driver.rb', line 46 def body browser.body end |
#console_messages ⇒ Object
63 64 65 |
# File 'lib/capybara/webkit/driver.rb', line 63 def browser. end |
#cookies ⇒ Object
136 137 138 |
# File 'lib/capybara/webkit/driver.rb', line 136 def @cookie_jar ||= CookieJar.new(browser) end |
#current_url ⇒ Object
26 27 28 |
# File 'lib/capybara/webkit/driver.rb', line 26 def current_url browser.current_url end |
#enable_logging ⇒ Object
22 23 24 |
# File 'lib/capybara/webkit/driver.rb', line 22 def enable_logging browser.enable_logging end |
#error_messages ⇒ Object
67 68 69 |
# File 'lib/capybara/webkit/driver.rb', line 67 def browser. end |
#evaluate_script(script) ⇒ Object
59 60 61 |
# File 'lib/capybara/webkit/driver.rb', line 59 def evaluate_script(script) browser.evaluate_script script end |
#execute_script(script) ⇒ Object
54 55 56 57 |
# File 'lib/capybara/webkit/driver.rb', line 54 def execute_script(script) value = browser.execute_script script value.empty? ? nil : value end |
#find(query) ⇒ Object
38 39 40 |
# File 'lib/capybara/webkit/driver.rb', line 38 def find(query) browser.find(query).map { |native| Node.new(self, native) } end |
#has_shortcircuit_timeout? ⇒ Boolean
121 122 123 |
# File 'lib/capybara/webkit/driver.rb', line 121 def has_shortcircuit_timeout? false end |
#header(key, value) ⇒ Object
50 51 52 |
# File 'lib/capybara/webkit/driver.rb', line 50 def header(key, value) browser.header(key, value) end |
#invalid_element_errors ⇒ Object
140 141 142 |
# File 'lib/capybara/webkit/driver.rb', line 140 def invalid_element_errors [] end |
#render(path, options = {}) ⇒ Object
125 126 127 128 129 130 |
# File 'lib/capybara/webkit/driver.rb', line 125 def render(path, ={}) [:width] ||= 1000 [:height] ||= 10 browser.render path, [:width], [:height] end |
#requested_url ⇒ Object
30 31 32 |
# File 'lib/capybara/webkit/driver.rb', line 30 def requested_url browser.requested_url end |
#reset! ⇒ Object
117 118 119 |
# File 'lib/capybara/webkit/driver.rb', line 117 def reset! browser.reset! end |
#resize_window(width, height) ⇒ Object
79 80 81 |
# File 'lib/capybara/webkit/driver.rb', line 79 def resize_window(width, height) browser.resize_window(width, height) end |
#response_headers ⇒ Object
71 72 73 |
# File 'lib/capybara/webkit/driver.rb', line 71 def response_headers browser.response_headers end |
#server_port ⇒ Object
132 133 134 |
# File 'lib/capybara/webkit/driver.rb', line 132 def server_port @rack_server.port end |
#source ⇒ Object
42 43 44 |
# File 'lib/capybara/webkit/driver.rb', line 42 def source browser.source end |
#status_code ⇒ Object
75 76 77 |
# File 'lib/capybara/webkit/driver.rb', line 75 def status_code browser.status_code end |
#visit(path) ⇒ Object
34 35 36 |
# File 'lib/capybara/webkit/driver.rb', line 34 def visit(path) browser.visit(url(path)) end |
#wait? ⇒ Boolean
110 111 112 |
# File 'lib/capybara/webkit/driver.rb', line 110 def wait? true end |
#wait_until(*args) ⇒ Object
114 115 |
# File 'lib/capybara/webkit/driver.rb', line 114 def wait_until(*args) end |
#window_handle ⇒ Object
106 107 108 |
# File 'lib/capybara/webkit/driver.rb', line 106 def window_handle browser.get_window_handle end |
#window_handles ⇒ Object
102 103 104 |
# File 'lib/capybara/webkit/driver.rb', line 102 def window_handles browser.get_window_handles end |
#within_frame(frame_id_or_index) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/capybara/webkit/driver.rb', line 83 def within_frame(frame_id_or_index) browser.frame_focus(frame_id_or_index) begin yield ensure browser.frame_focus end end |
#within_window(selector) ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'lib/capybara/webkit/driver.rb', line 92 def within_window(selector) current_window = window_handle browser.window_focus(selector) begin yield ensure browser.window_focus(current_window) end end |