class Selenium::WebDriver::TargetLocator

def active_element

def active_element
  @bridge.switch_to_active_element
end

def alert

def alert
  Alert.new(@bridge)
end

def default_content

def default_content
  @bridge.switch_to_default_content
end

def frame(id)

def frame(id)
  @bridge.switch_to_frame id
end

def initialize(bridge)

def initialize(bridge)
  @bridge = bridge
end

def new_window(type = :window)

steep:ignore:start
def new_window(type = :window)
  raise ArgumentError, "Valid types are :tab and :window, received: #{type.inspect}" unless %i[window
                                                                                               tab].include?(type)
  handle = @bridge.new_window(type)['handle']
  if block_given?
    execute_and_close = proc do
      yield(self)
      begin
        @bridge.close
      rescue Error::NoSuchWindowError
        # window already closed
      end
    end
    window(handle, &execute_and_close)
  else
    window(handle)
  end
end

def parent_frame

def parent_frame
  @bridge.switch_to_parent_frame
end

def window(id)

def window(id)
  if block_given?
    original = begin
      @bridge.window_handle
    rescue Error::NoSuchWindowError
      nil
    end
    unless @bridge.window_handles.include? id
      raise Error::NoSuchWindowError, "The specified identifier '#{id}' is not found in the window handle list"
    end
    @bridge.switch_to_window id
    begin
      yield
    ensure
      current_handles = @bridge.window_handles
      original = current_handles.first unless current_handles.include? original
      @bridge.switch_to_window original
    end
  else
    @bridge.switch_to_window id
  end
end