Sha256: d8025d0ef06e01a6b7821c97d40d810b572c7cbab09cf15518dc1e261921bdf8

Contents?: true

Size: 1.33 KB

Versions: 13

Compression:

Stored size: 1.33 KB

Contents

module Selenium
  module WebDriver
    class TargetLocator

      #
      # @api private
      #

      def initialize(driver)
        @bridge = driver.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

          yield

          current_handles = @bridge.getWindowHandles

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

          @bridge.switchToWindow original
        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

13 entries across 13 versions & 2 rubygems

Version Path
selenium-webdriver-0.0.28 lib/selenium/webdriver/target_locator.rb
selenium-webdriver-0.0.27 lib/selenium/webdriver/target_locator.rb
selenium-webdriver-0.0.26 lib/selenium/webdriver/target_locator.rb
selenium-webdriver-0.0.25 lib/selenium/webdriver/target_locator.rb
selenium-webdriver-0.0.24 common/src/rb/lib/selenium/webdriver/target_locator.rb
selenium-webdriver-0.0.23 common/src/rb/lib/selenium/webdriver/target_locator.rb
selenium-webdriver-0.0.22 common/src/rb/lib/selenium/webdriver/target_locator.rb
selenium-webdriver-0.0.21 common/src/rb/lib/selenium/webdriver/target_locator.rb
selenium-webdriver-0.0.20 common/src/rb/lib/selenium/webdriver/target_locator.rb
selenium-webdriver-0.0.19 common/src/rb/lib/selenium/webdriver/target_locator.rb
selenium-webdriver-0.0.18 common/src/rb/lib/selenium/webdriver/target_locator.rb
rainux-selenium-webdriver-0.0.17 common/src/rb/lib/selenium/webdriver/target_locator.rb
selenium-webdriver-0.0.17 common/src/rb/lib/selenium/webdriver/target_locator.rb