Sha256: 330991319598458a8b2f24c7054664b29349fe14d4360480019b658aa6537a43

Contents?: true

Size: 1.61 KB

Versions: 92

Compression:

Stored size: 1.61 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 given window handle
      #
      # If given a block, this method will switch back to the original window after
      # block execution.
      #
      # @param id
      #   A window handle, obtained through Driver#window_handles
      #

      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

      #
      # switches to the currently active modal dialog for this particular driver instance
      #

      def alert
        Alert.new(@bridge)
      end

    end # TargetLocator
  end # WebDriver
end  # Selenium

Version data entries

92 entries across 92 versions & 5 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.27.2 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.27.1 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.27.0 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.27.0.rc1 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.26.0 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.26.0.rc1 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.25.0 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.25.0.rc1 lib/selenium/webdriver/common/target_locator.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/common/target_locator.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/common/target_locator.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.24.0 lib/selenium/webdriver/common/target_locator.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.22.2 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.22.2.rc2 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.22.2.rc1 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.22.1 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.22.0 lib/selenium/webdriver/common/target_locator.rb
selenium-webdriver-2.22.0.rc3 lib/selenium/webdriver/common/target_locator.rb