Sha256: 217fb9a69674b9bea40f76110fb918ee3427ca9578dba3d1c70f2f828d18f75e

Contents?: true

Size: 1.32 KB

Versions: 46

Compression:

Stored size: 1.32 KB

Contents

module Selenium
  module WebDriver

    #
    # @api private
    # @see ActionBuilder
    #

    class Mouse

      def initialize(bridge)
        @bridge = bridge
      end

      def click(element = nil)
        move_if_needed element
        @bridge.click
      end

      def double_click(element = nil)
        move_if_needed element
        @bridge.doubleClick
      end

      def context_click(element = nil)
        move_if_needed element
        @bridge.contextClick
      end

      def down(element = nil)
        move_if_needed element
        @bridge.mouseDown
      end

      def up(element = nil)
        move_if_needed element
        @bridge.mouseUp
      end

      #
      # Move the mouse.
      #
      # Examples:
      #
      #   driver.mouse.move_to(element)
      #   driver.mouse.move_to(element, 5, 5)
      #

      def move_to(element, right_by = nil, down_by = nil)
        unless element.kind_of? Element
          raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
        end

        @bridge.mouseMoveTo element.ref, right_by, down_by
      end

      def move_by(right_by, down_by)
        @bridge.mouseMoveTo nil, right_by, down_by
      end

      private

      def move_if_needed(element)
        move_to element if element
      end

    end # Mouse
  end # WebDriver
end  # Selenium

Version data entries

46 entries across 46 versions & 3 rubygems

Version Path
selenium-webdriver-2.35.1 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.35.0 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.34.0 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.33.0 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.32.1 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.32.0 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.31.0 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.30.0 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.29.0 lib/selenium/webdriver/common/mouse.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.27.2 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.27.1 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.27.0 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.27.0.rc1 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.26.0 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.26.0.rc1 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.25.0 lib/selenium/webdriver/common/mouse.rb
selenium-webdriver-2.25.0.rc1 lib/selenium/webdriver/common/mouse.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/common/mouse.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/selenium-webdriver-2.21.2/lib/selenium/webdriver/common/mouse.rb