Class: Selenium::WebDriver::Window
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Window
- Defined in:
- lib/selenium/webdriver/common/window.rb
Instance Method Summary collapse
-
#full_screen ⇒ Object
Make current window full screen.
-
#initialize(bridge) ⇒ Window
constructor
private
A new instance of Window.
-
#maximize ⇒ Object
Maximize the current window.
-
#minimize ⇒ Object
Minimize the current window.
-
#move_to(x, y) ⇒ Object
Equivalent to #position=, but accepts x and y arguments.
-
#position ⇒ Selenium::WebDriver::Point
Get the position of the current window.
-
#position=(point) ⇒ Object
Move the current window to the given position.
-
#rect ⇒ Selenium::WebDriver::Rectangle
Get the rect of the current window.
-
#rect=(rectangle) ⇒ Object
Sets the current window rect to the given point and position.
-
#resize_to(width, height) ⇒ Object
Equivalent to #size=, but accepts width and height arguments.
-
#size ⇒ Selenium::WebDriver::Dimension
Get the size of the current window.
-
#size=(dimension) ⇒ Object
Resize the current window to the given dimension.
Constructor Details
#initialize(bridge) ⇒ Window
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Window.
29 30 31 |
# File 'lib/selenium/webdriver/common/window.rb', line 29 def initialize(bridge) @bridge = bridge end |
Instance Method Details
#full_screen ⇒ Object
Make current window full screen
156 157 158 |
# File 'lib/selenium/webdriver/common/window.rb', line 156 def full_screen @bridge.full_screen_window end |
#maximize ⇒ Object
Maximize the current window
140 141 142 |
# File 'lib/selenium/webdriver/common/window.rb', line 140 def maximize @bridge.maximize_window end |
#minimize ⇒ Object
Minimize the current window
148 149 150 |
# File 'lib/selenium/webdriver/common/window.rb', line 148 def minimize @bridge.minimize_window end |
#move_to(x, y) ⇒ Object
Equivalent to #position=, but accepts x and y arguments.
132 133 134 |
# File 'lib/selenium/webdriver/common/window.rb', line 132 def move_to(x, y) @bridge.reposition_window Integer(x), Integer(y) end |
#position ⇒ Selenium::WebDriver::Point
Get the position of the current window.
79 80 81 |
# File 'lib/selenium/webdriver/common/window.rb', line 79 def position @bridge.window_position end |
#position=(point) ⇒ Object
Move the current window to the given position.
64 65 66 67 68 69 70 71 |
# File 'lib/selenium/webdriver/common/window.rb', line 64 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 |
#rect ⇒ Selenium::WebDriver::Rectangle
Get the rect of the current window.
107 108 109 |
# File 'lib/selenium/webdriver/common/window.rb', line 107 def rect @bridge.window_rect end |
#rect=(rectangle) ⇒ Object
Sets the current window rect to the given point and position.
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/selenium/webdriver/common/window.rb', line 89 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 |
#resize_to(width, height) ⇒ Object
Equivalent to #size=, but accepts width and height arguments.
120 121 122 |
# File 'lib/selenium/webdriver/common/window.rb', line 120 def resize_to(width, height) @bridge.resize_window Integer(width), Integer(height) end |
#size ⇒ Selenium::WebDriver::Dimension
Get the size of the current window.
54 55 56 |
# File 'lib/selenium/webdriver/common/window.rb', line 54 def size @bridge.window_size end |
#size=(dimension) ⇒ Object
Resize the current window to the given dimension.
39 40 41 42 43 44 45 46 |
# File 'lib/selenium/webdriver/common/window.rb', line 39 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 |