Class: OmniAI::Tools::Browser::InspectTool

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/omniai/tools/browser/inspect_tool.rb

Overview

Examples:

browser = Watir::Browser.new(:chrome)
tool = OmniAI::Tools::Browser::InspectTool.new(browser:)
tool.execute

Instance Method Summary collapse

Methods inherited from BaseTool

#initialize

Constructor Details

This class inherits a constructor from OmniAI::Tools::Browser::BaseTool

Instance Method Details

#executeString

Returns:

  • (String)


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/omniai/tools/browser/inspect_tool.rb', line 16

def execute
  @logger.info("#{self.class.name}##{__method__}")

  html = @browser.html
  doc = Nokogiri::HTML(html)

  doc.css("link").each(&:remove)
  doc.css("style").each(&:remove)
  doc.css("script").each(&:remove)

  doc.to_html
end