class Selenium::WebDriver::Window
@api beta This API may be changed or removed in a future release.
Public Class Methods
@api private
# File lib/selenium/webdriver/common/window.rb, line 30 def initialize(bridge) @bridge = bridge end
Public Instance Methods
Make current window full screen
# File lib/selenium/webdriver/common/window.rb, line 157 def full_screen @bridge.full_screen_window end
Maximize the current window
# File lib/selenium/webdriver/common/window.rb, line 141 def maximize @bridge.maximize_window end
Minimize the current window
# File lib/selenium/webdriver/common/window.rb, line 149 def minimize @bridge.minimize_window end
Equivalent to position=, but accepts x and y arguments.
@example
driver.manage.window.move_to(300, 400)
# File lib/selenium/webdriver/common/window.rb, line 133 def move_to(x, y) @bridge.reposition_window Integer(x), Integer(y) end
Get the position of the current window.
@return [Selenium::WebDriver::Point] The position.
# File lib/selenium/webdriver/common/window.rb, line 80 def position @bridge.window_position end
Move the current window to the given position.
@param [Selenium::WebDriver::Point, x and y] point The new position.
# File lib/selenium/webdriver/common/window.rb, line 65 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
Get the rect of the current window.
@return [Selenium::WebDriver::Rectangle] The rectangle.
# File lib/selenium/webdriver/common/window.rb, line 108 def rect @bridge.window_rect end
Sets the current window rect to the given point and position.
@param [Selenium::WebDriver::Rectangle, x, y, width, height] rectangle The new rect.
# File lib/selenium/webdriver/common/window.rb, line 90 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
Equivalent to size=, but accepts width and height arguments.
@example 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)
# File lib/selenium/webdriver/common/window.rb, line 121 def resize_to(width, height) @bridge.resize_window Integer(width), Integer(height) end
Get the size of the current window.
@return [Selenium::WebDriver::Dimension] The size.
# File lib/selenium/webdriver/common/window.rb, line 55 def size @bridge.window_size end
Resize the current window to the given dimension.
@param [Selenium::WebDriver::Dimension, width and height] dimension The new size.
# File lib/selenium/webdriver/common/window.rb, line 40 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