Class: Selenium::WebDriver::Window
| Relationships & Source Files | |
| Inherits: | Object | 
| Defined in: | rb/lib/selenium/webdriver/common/window.rb | 
Class Method Summary
- .new(bridge) ⇒ Window constructor Internal use only Internal use only
Instance Attribute Summary
- 
    
      #position  ⇒ Selenium::WebDriver::Point 
    
    rw
    Get the position of the current window. 
- 
    
      #position=(point)  
    
    rw
    Move the current window to the given position. 
- 
    
      #rect  ⇒ Selenium::WebDriver::Rectangle 
    
    rw
    Get the rect of the current window. 
- 
    
      #rect=(rectangle)  
    
    rw
    Sets the current window rect to the given point and position. 
- 
    
      #size  ⇒ Selenium::WebDriver::Dimension 
    
    rw
    Get the size of the current window. 
- 
    
      #size=(dimension)  
    
    rw
    Resize the current window to the given dimension. 
Instance Method Summary
- 
    
      #full_screen  
    
    Make current window full screen. 
- 
    
      #maximize  
    
    Maximize the current window. 
- 
    
      #minimize  
    
    Minimize the current window. 
- 
    
      #move_to(x, y)  
    
    Equivalent to #position=, but accepts x and y arguments. 
- 
    
      #resize_to(width, height)  
    
    Equivalent to #size=, but accepts width and height arguments. 
Constructor Details
    .new(bridge)  ⇒ Window 
  
  # File 'rb/lib/selenium/webdriver/common/window.rb', line 27
def initialize(bridge) @bridge = bridge end
Instance Attribute Details
#position ⇒ Selenium::WebDriver::Point (rw)
Get the position of the current window.
# 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.
# 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
#rect ⇒ Selenium::WebDriver::Rectangle (rw)
Get the rect of the current window.
# 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.
# 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
#size ⇒ Selenium::WebDriver::Dimension (rw)
Get the size of the current window.
# 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.
# 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
# File 'rb/lib/selenium/webdriver/common/window.rb', line 154
def full_screen @bridge.full_screen_window end
#maximize
Maximize the current window
# File 'rb/lib/selenium/webdriver/common/window.rb', line 138
def maximize @bridge.maximize_window end
#minimize
Minimize the current window
# 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.
# 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.
# File 'rb/lib/selenium/webdriver/common/window.rb', line 118
def resize_to(width, height) @bridge.resize_window Integer(width), Integer(height) end