Method: Capybara::Session#within_frame

Defined in:
lib/capybara/session.rb

#within_frame(element) ⇒ Object #within_frame([kind = :frame], locator, **options) ⇒ Object #within_frame(index) ⇒ Object

Execute the given block within the given iframe using given frame, frame name/id or index. May not be supported by all drivers.

Overloads:

  • #within_frame(element) ⇒ Object

    Parameters:

  • #within_frame([kind = :frame], locator, **options) ⇒ Object

    Parameters:

    • kind (Symbol)

      Optional selector type (:frame, :css, :xpath, etc.) - Defaults to :frame

    • locator (String)

      The locator for the given selector kind. For :frame this is the name/id of a frame/iframe element

  • #within_frame(index) ⇒ Object

    Parameters:

    • index (Integer)

      index of a frame (0 based)


426
427
428
429
430
431
432
433
# File 'lib/capybara/session.rb', line 426

def within_frame(*args, **kw_args)
  switch_to_frame(_find_frame(*args, **kw_args))
  begin
    yield if block_given?
  ensure
    switch_to_frame(:parent)
  end
end