Module: Howitzer::Web::IframeDsl::ClassMethods

Defined in:
lib/howitzer/web/iframe_dsl.rb

Overview

This module holds frame dsl class methods

Instance Method Summary collapse

Instance Method Details

#iframe(name, *args) ⇒ Object

Note:

This method generates following dynamic methods:

frame_name_iframe - equals capybara #within_frame(…) method

has_frame_name_iframe? - equals capybara #has_selector(…) method

has_no_frame_name_iframe? - equals capybara #has_no_selector(…) method

Creates a group of methods to interact with described HTML frame on page

Examples:

Using in a page class

class FbPage < Howitzer::Web::Page
  element :like, :xpath, ".//*[text()='Like']"
  def like
    like_element.click
  end

  def liked?
    #some code here
  end
end

class HomePage < Howitzer::Web::Page
  iframe :fb, 1
end

HomePage.on do
  fb_iframe do |frame|
    frame.like
    expect(frame).to be_liked
  end
end
HomePage.on { is_expected.to have_fb_iframe }

Raises:

  • (ArgumentError)

73
74
75
76
77
78
79
# File 'lib/howitzer/web/iframe_dsl.rb', line 73

def iframe(name, *args)
  raise ArgumentError, 'iframe selector arguments must be specified' if args.blank?
  klass = "#{name}_page".classify.constantize
  define_iframe(klass, name, args)
  define_has_iframe(name, args)
  define_has_no_iframe(name, args)
end