class Selenium::WebDriver::Window
@api beta This API may be changed or removed in a future release.
Public Class Methods
new(bridge)
click to toggle source
@api private
# File lib/selenium/webdriver/common/window.rb, line 14 def initialize(bridge) @bridge = bridge end
Public Instance Methods
maximize()
click to toggle source
Maximize the current window
# File lib/selenium/webdriver/common/window.rb, line 97 def maximize @bridge.maximizeWindow end
move_to(x, y)
click to toggle source
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 89 def move_to(x, y) @bridge.setWindowPosition Integer(x), Integer(y) end
position()
click to toggle source
Get the position of the current window.
@return [Selenium::WebDriver::Point] The position.
# File lib/selenium/webdriver/common/window.rb, line 64 def position @bridge.getWindowPosition end
position=(point)
click to toggle source
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 49 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
resize_to(width, height)
click to toggle source
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 77 def resize_to(width, height) @bridge.setWindowSize Integer(width), Integer(height) end
size()
click to toggle source
Get the size of the current window.
@return [Selenium::WebDriver::Dimension] The size.
# File lib/selenium/webdriver/common/window.rb, line 39 def size @bridge.getWindowSize end
size=(dimension)
click to toggle source
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 24 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