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.



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

def initialize(devtools)
  @devtools = devtools
end

Instance Method Details

#cancel_invocation(invocation_id:) ⇒ Object



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

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

#disableObject



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

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

#enableObject



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

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

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



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

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



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

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