Class: HeadlessBrowserTool::Tools::GetWindowHandlesTool

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

Instance Method Summary collapse

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/headless_browser_tool/tools/get_window_handles_tool.rb', line 11

def execute
  handles = browser.get_window_handles
  current_handle = browser.current_window_handle

  {
    current_window: current_handle,
    windows: handles.map.with_index do |handle, index|
      {
        handle: handle,
        index: index,
        is_current: handle == current_handle
      }
    end,
    total_windows: handles.size
  }
end