Class: HeadlessBrowserTool::Tools::SwitchToWindowTool

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

Instance Method Summary collapse

Instance Method Details

#execute(window_handle:) ⇒ Object



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

def execute(window_handle:)
  previous_window = browser.current_window
  browser.switch_to_window(window_handle)

  {
    window_handle: window_handle,
    previous_window: previous_window,
    current_url: browser.current_url,
    title: browser.title,
    total_windows: browser.windows.count,
    status: "switched"
  }
end