Sha256: abb292d0d4b5ab9c5880d7586277875d5ed1022d3b72409be3728cfff6cba24c

Contents?: true

Size: 1.69 KB

Versions: 9

Compression:

Stored size: 1.69 KB

Contents

module OperaWatir
  module Compat
    module Window
      include Deprecated

      #
      # Checks whether the body has the given text in it.
      #
      # @param [String] str Text to search for.
      # @return [Boolean] true if the body contains the given text,
      #   false otherwise
      #

      def contains_text(str)
        text.index(str)
      end


      #
      # Find elements that match the given XPath.
      #
      # @param [String] value The XPath expression to search for.
      # @return [OperaWatir::Collection] A collection of matching
      #   elements.
      #

      def elements_by_xpath(value)
        find_by_xpath(value)
      end

      alias_method :element_by_xpath, :elements_by_xpath


      #
      # Opera specific
      #

      def get_hash
        visual_hash
      end

      deprecated :get_hash, 'browser.visual_hash'


      #
      # TODO This is a relic from the old OperaWatir implementation,
      # tests should be updated.
      #

      def frame(selector, argument)
        case selector
        when :name
          driver.switch_to.frame(argument)
        when :index
          driver.switch_to.frame(argument.to_i - 1)  # index starts from 1 in Watir
        else
          raise OperaWatir::Exceptions::NotImplementedException,
            "We do not support the `#{selector}' selector yet"
        end
      end


      def switch_to_default
        driver.switch_to.default_content
      end


      def show_frames
        frames = driver.list_frames
        text = "There are #{frames.length.to_s} frames\n"
        frames.each_with_index { |frame, i| text << "frame index: #{(i.to_i + 1).to_s} name: #{frame.to_s}\n" }
        text
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
operawatir-0.7.pre4-jruby lib/operawatir/compat/window.rb
operawatir-0.7.pre3-jruby lib/operawatir/compat/window.rb
operawatir-0.7.pre2-jruby lib/operawatir/compat/window.rb
operawatir-0.7.pre1-jruby lib/operawatir/compat/window.rb
operawatir-0.6.pre1-jruby lib/operawatir/compat/window.rb
operawatir-0.5.1-jruby lib/operawatir/compat/window.rb
operawatir-0.5-jruby lib/operawatir/compat/window.rb
operawatir-0.5.pre3-jruby lib/operawatir/compat/window.rb
operawatir-0.5.pre2-jruby lib/operawatir/compat/window.rb