Class: WebDriverScriptAdapter::FrameAdapter::CapybaraAdapter

Inherits:
DumbDelegator
  • Object
show all
Defined in:
lib/webdriver_script_adapter/frame_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(driver) ⇒ CapybaraAdapter

Returns a new instance of CapybaraAdapter.



60
61
62
63
# File 'lib/webdriver_script_adapter/frame_adapter.rb', line 60

def initialize(driver)
  super(driver)
  @driver = driver
end

Instance Method Details

#find_framesObject



88
89
90
# File 'lib/webdriver_script_adapter/frame_adapter.rb', line 88

def find_frames
  find_css("iframe")
end

#within_frame(frame) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/webdriver_script_adapter/frame_adapter.rb', line 65

def within_frame(frame)
  # Patch the `Symbol` class to respond to the :native method.
  # Will be fixed in https://github.com/teamcapybara/capybara/pull/2462
  (:parent).class.define_method(:native) do
    nil
  end
  switch_to_frame frame
  yield
ensure
  begin
    switch_to_frame :parent
  rescue => e
    if /switchToParentFrame|frame\/parent/.match(e.message)
      ::Kernel.warn "WARNING:
      This browser only supports first-level iframes.
      Second-level iframes and beyond will not be audited.
      To skip auditing all iframes,
      set Axe::Configuration#skip_iframes=true"
    end
    switch_to_frame :top
  end
end