Class: Selenium::WebDriver::DevTools
- Inherits:
-
Object
- Object
- Selenium::WebDriver::DevTools
show all
- Defined in:
- lib/selenium/webdriver/devtools.rb,
lib/selenium/webdriver/devtools/request.rb,
lib/selenium/webdriver/devtools/response.rb,
lib/selenium/webdriver/devtools/console_event.rb,
lib/selenium/webdriver/devtools/pinned_script.rb,
lib/selenium/webdriver/devtools/mutation_event.rb,
lib/selenium/webdriver/devtools/exception_event.rb
Defined Under Namespace
Classes: ConsoleEvent, ExceptionEvent, MutationEvent, PinnedScript, Request, Response
Instance Method Summary
collapse
Constructor Details
#initialize(url:) ⇒ DevTools
Returns a new instance of DevTools.
30
31
32
33
34
|
# File 'lib/selenium/webdriver/devtools.rb', line 30
def initialize(url:)
@ws = WebSocketConnection.new(url: url)
@session_id = nil
start_session
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *_args) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/selenium/webdriver/devtools.rb', line 53
def method_missing(method, *_args)
desired_class = "Selenium::DevTools::V#{Selenium::DevTools.version}::#{method.capitalize}"
return unless Object.const_defined?(desired_class)
self.class.class_eval do
define_method(method) do
Object.const_get(desired_class).new(self)
end
end
send(method)
end
|
Instance Method Details
#callbacks ⇒ Object
40
41
42
|
# File 'lib/selenium/webdriver/devtools.rb', line 40
def callbacks
@ws.callbacks
end
|
#close ⇒ Object
36
37
38
|
# File 'lib/selenium/webdriver/devtools.rb', line 36
def close
@ws.close
end
|
#respond_to_missing?(method, *_args) ⇒ Boolean
66
67
68
69
|
# File 'lib/selenium/webdriver/devtools.rb', line 66
def respond_to_missing?(method, *_args)
desired_class = "Selenium::DevTools::V#{Selenium::DevTools.version}::#{method.capitalize}"
Object.const_defined?(desired_class)
end
|
#send_cmd(method, **params) ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/selenium/webdriver/devtools.rb', line 44
def send_cmd(method, **params)
data = {method: method, params: params.compact}
data[:sessionId] = @session_id if @session_id
message = @ws.send_cmd(**data)
raise Error::WebDriverError, error_message(message['error']) if message['error']
message
end
|