module Window
Helpers for managing the browser window size and position.
Definitions
def window_rect
Get the current window rect (position and size).
Signature
-
returns
Hash The window rect with keys
"x","y","width","height".
Implementation
def window_rect
session.get("window/rect")
end
def set_window_rect(x: nil, y: nil, width: nil, height: nil)
Set the window rect (position and/or size).
Signature
-
parameter
xInteger | Nil The x position of the window.
-
parameter
yInteger | Nil The y position of the window.
-
parameter
widthInteger | Nil The width of the window in CSS pixels.
-
parameter
heightInteger | Nil The height of the window in CSS pixels.
Implementation
def set_window_rect(x: nil, y: nil, width: nil, height: nil)
session.post("window/rect", {x: x, y: y, width: width, height: height}.compact)
end
def resize_window(width, height)
Resize the browser window to the given dimensions.
Signature
-
parameter
widthInteger The new width in CSS pixels.
-
parameter
heightInteger The new height in CSS pixels.
Implementation
def resize_window(width, height)
set_window_rect(width: width, height: height)
end
def maximize_window
Maximize the browser window.
Implementation
def maximize_window
session.post("window/maximize")
end
def minimize_window
Minimize the browser window.
Implementation
def minimize_window
session.post("window/minimize")
end
def fullscreen_window
Make the browser window fullscreen.
Implementation
def fullscreen_window
session.post("window/fullscreen")
end