123456789_123456789_123456789_123456789_123456789_

Class: Selenium::WebDriver::Window

Relationships & Source Files
Inherits: Object
Defined in: rb/lib/selenium/webdriver/common/window.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(bridge) ⇒ Window

This method is for internal use only.
[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 27

def initialize(bridge)
  @bridge = bridge
end

Instance Attribute Details

#positionSelenium::WebDriver::Point (rw)

Get the position of the current window.

Returns:

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 77

def position
  @bridge.window_position
end

#position=(point) (rw)

Move the current window to the given position.

Parameters:

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 62

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.reposition_window point.x, point.y
end

#rectSelenium::WebDriver::Rectangle (rw)

Get the rect of the current window.

Returns:

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 105

def rect
  @bridge.window_rect
end

#rect=(rectangle) (rw)

Sets the current window rect to the given point and position.

Parameters:

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 87

def rect=(rectangle)
  unless %w[x y width height].all? { |val| rectangle.respond_to? val }
    raise ArgumentError, "expected #{rectangle.inspect}:#{rectangle.class} " \
                         'to respond to #x, #y, #width, and #height'
  end

  @bridge.set_window_rect(x: rectangle.x,
                          y: rectangle.y,
                          width: rectangle.width,
                          height: rectangle.height)
end

#sizeSelenium::WebDriver::Dimension (rw)

Get the size of the current window.

Returns:

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 52

def size
  @bridge.window_size
end

#size=(dimension) (rw)

Resize the current window to the given dimension.

Parameters:

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 37

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.resize_window dimension.width, dimension.height
end

Instance Method Details

#full_screen

Make current window full screen

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 154

def full_screen
  @bridge.full_screen_window
end

#maximize

Maximize the current window

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 138

def maximize
  @bridge.maximize_window
end

#minimize

Minimize the current window

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 146

def minimize
  @bridge.minimize_window
end

#move_to(x, y)

Equivalent to #position=, but accepts x and y arguments.

Examples:

driver.manage.window.move_to(300, 400)
[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 130

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

#resize_to(width, height)

Equivalent to #size=, but accepts width and height arguments.

Examples:

Maximize the window.

max_width, max_height = driver.execute_script("return [window.screen.availWidth, window.screen.availHeight];")
driver.manage.window.resize_to(max_width, max_height)
[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/common/window.rb', line 118

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