Class: Selenium::DevTools::V149::WebMCP

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/devtools/v149/web_mcp.rb

Constant Summary collapse

EVENTS =
{
  tools_added: 'toolsAdded',
  tools_removed: 'toolsRemoved',
  tool_invoked: 'toolInvoked',
  tool_responded: 'toolResponded',
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(devtools) ⇒ WebMCP

Returns a new instance of WebMCP.



32
33
34
# File 'lib/selenium/devtools/v149/web_mcp.rb', line 32

def initialize(devtools)
  @devtools = devtools
end

Instance Method Details

#cancel_invocation(invocation_id:) ⇒ Object



56
57
58
59
# File 'lib/selenium/devtools/v149/web_mcp.rb', line 56

def cancel_invocation(invocation_id:)
  @devtools.send_cmd('WebMCP.cancelInvocation',
                     invocationId: invocation_id)
end

#disableObject



45
46
47
# File 'lib/selenium/devtools/v149/web_mcp.rb', line 45

def disable
  @devtools.send_cmd('WebMCP.disable')
end

#enableObject



41
42
43
# File 'lib/selenium/devtools/v149/web_mcp.rb', line 41

def enable
  @devtools.send_cmd('WebMCP.enable')
end

#invoke_tool(frame_id:, tool_name:, input:) ⇒ Object



49
50
51
52
53
54
# File 'lib/selenium/devtools/v149/web_mcp.rb', line 49

def invoke_tool(frame_id:, tool_name:, input:)
  @devtools.send_cmd('WebMCP.invokeTool',
                     frameId: frame_id,
                     toolName: tool_name,
                     input: input)
end

#on(event, &block) ⇒ Object



36
37
38
39
# File 'lib/selenium/devtools/v149/web_mcp.rb', line 36

def on(event, &block)
  event = EVENTS[event] if event.is_a?(Symbol)
  @devtools.callbacks["WebMCP.#{event}"] << block
end