Class: Selenium::WebDriver::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/common/window.rb

Instance Method Summary collapse

Constructor Details

#initialize(bridge) ⇒ Window

Returns a new instance of Window.



10
11
12
# File 'lib/selenium/webdriver/common/window.rb', line 10

def initialize(bridge)
  @bridge = bridge
end

Instance Method Details

#move_to(x, y) ⇒ Object

equivalent to #position=, but accepts x and y arguments



52
53
54
# File 'lib/selenium/webdriver/common/window.rb', line 52

def move_to(x, y)
  @bridge.setWindowPosition Integer(x), Integer(y)
end

#positionObject



36
37
38
# File 'lib/selenium/webdriver/common/window.rb', line 36

def position
  @bridge.getWindowPosition
end

#position=(point) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/selenium/webdriver/common/window.rb', line 27

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) ⇒ Object

equivalent to #size=, but accepts width and height arguments



44
45
46
# File 'lib/selenium/webdriver/common/window.rb', line 44

def resize_to(width, height)
  @bridge.setWindowSize Integer(width), Integer(height)
end

#sizeObject



23
24
25
# File 'lib/selenium/webdriver/common/window.rb', line 23

def size
  @bridge.getWindowSize
end

#size=(dimension) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/selenium/webdriver/common/window.rb', line 14

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