Sha256: 2e5c056a2096fc95a275744e1f5a88d1043faec74b93c0ab0553ab2014a69530

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

module Selenium
  module WebDriver
    
    #
    # @api beta This API may be changed or removed in a future release.
    # 
    
    class Window

      def initialize(bridge)
        @bridge = bridge
      end

      def size=(dimension)
        unless dimension.respond_to?(:width) && dimension.respond_to?(:height)
          raise ArgumentError, "expected #{dimension.inspect}:#{dimension.class}" +
                                " to respond to #width and #height"
        end

        @bridge.setWindowSize dimension.width, dimension.height
      end

      def size
        @bridge.getWindowSize
      end

      def position=(point)
        unless point.respond_to?(:x) && point.respond_to?(:y)
          raise ArgumentError, "expected #{point.inspect}:#{point.class}" +
                                " to respond to #x and #y"
        end

        @bridge.setWindowPosition point.x, point.y
      end

      def position
        @bridge.getWindowPosition
      end

      #
      # equivalent to #size=, but accepts width and height arguments
      #

      def resize_to(width, height)
        @bridge.setWindowSize Integer(width), Integer(height)
      end

      #
      # equivalent to #position=, but accepts x and y arguments
      #

      def move_to(x, y)
        @bridge.setWindowPosition Integer(x), Integer(y)
      end


    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
selenium-webdriver-2.15.0 lib/selenium/webdriver/common/window.rb
selenium-webdriver-2.14.0 lib/selenium/webdriver/common/window.rb
selenium-webdriver-2.13.0 lib/selenium/webdriver/common/window.rb
selenium-webdriver-2.12.2 lib/selenium/webdriver/common/window.rb
selenium-webdriver-2.12.1 lib/selenium/webdriver/common/window.rb
selenium-webdriver-2.12.0 lib/selenium/webdriver/common/window.rb