Sha256: 0f5946646e236245b325017edb876206d23b0943040c861064ab33ed0f2069ce

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

module Howitzer
  module Meta
    # This class represents iframe entity within howitzer meta information interface
    class Iframe
      attr_reader :name, :context

      include Howitzer::Meta::Actions

      # Creates new meta iframe element with meta information and utility actions
      # @param name [String] name of the iframe
      # @param context [Howitzer::Web::Page] page which has this iframe
      def initialize(name, context)
        @name = name
        @context = context
      end

      # Finds all instances of iframe on the page and returns them as array of capybara elements
      # @return [Array]
      def capybara_elements
        context.capybara_context.all("iframe[src='#{site_value}']")
      end

      # Finds iframe on the page and returns as a capybara element
      # @param wait [Integer] wait time for element search
      # @return [Capybara::Node::Element, nil]
      def capybara_element(wait: 0)
        context.capybara_context.find("iframe[src='#{site_value}']", match: :first, wait: wait)
      rescue Capybara::ElementNotFound
        nil
      end

      # Returns url value for iframe
      # @return [String]
      def site_value
        return @site_value if @site_value.present?

        context.send("#{name}_iframe") { |frame| @site_value = frame.class.send(:site_value) }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
howitzer-2.6.1 lib/howitzer/meta/iframe.rb
howitzer-2.6.0 lib/howitzer/meta/iframe.rb
howitzer-2.5.0 lib/howitzer/meta/iframe.rb
howitzer-2.4.0 lib/howitzer/meta/iframe.rb
howitzer-2.3.0 lib/howitzer/meta/iframe.rb
howitzer-2.2.0 lib/howitzer/meta/iframe.rb