Class: HeadlessBrowserTool::Tools::ExecuteScriptTool

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/headless_browser_tool/tools/execute_script_tool.rb

Instance Method Summary collapse

Instance Method Details

#execute(javascript_code:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/headless_browser_tool/tools/execute_script_tool.rb', line 15

def execute(javascript_code:)
  start_time = Time.now
  browser.execute_script(javascript_code)
  execution_time = Time.now - start_time

  {
    javascript_code: javascript_code,
    execution_time: execution_time,
    timestamp: Time.now.iso8601,
    status: "executed"
  }
end