Sha256: 804d22346a29f41164050d6c3a0c3632360a6a8432ddb1e05a503233ebce2638

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

module Selenium
  module WebDriver
    class TargetLocator

      #
      # @api private
      #

      def initialize(bridge)
        @bridge = bridge
      end

      #
      # switch to the frame with the given id
      #

      def frame(id)
        @bridge.switchToFrame id
      end

      #
      # switch to the frame with the given id
      #
      # If given a block, this method will return to the original window after
      # block execution.
      #
      # @param id
      #   A window handle
      #

      def window(id)
        if block_given?
          original = @bridge.getCurrentWindowHandle
          @bridge.switchToWindow id

          begin
            returned = yield
          ensure
            current_handles = @bridge.getWindowHandles

            if current_handles.size == 1
              original = current_handles.shift
            end

            @bridge.switchToWindow original
            returned
          end
        else
          @bridge.switchToWindow id
        end
      end

      #
      # get the active element
      #
      # @return [WebDriver::Element]
      #

      def active_element
        @bridge.switchToActiveElement
      end

      #
      # selects either the first frame on the page, or the main document when a page contains iframes.
      #

      def default_content
        @bridge.switchToDefaultContent
      end

    end # TargetLocator
  end # WebDriver
end  # Selenium

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
selenium-webdriver-0.1.1 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-0.1.0 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-0.0.29 lib/selenium/webdriver/common/target_locator.rb