Class: Webdriver::Window

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, connection) ⇒ Window

Returns a new instance of Window.



4
5
6
7
8
# File 'lib/webdriver/window.rb', line 4

def initialize(id, connection)
  @id = id
  @session_connection = connection
  @connection = Webdriver::PrefixConnection.new "window/#{@id}", connection
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/webdriver/window.rb', line 3

def id
  @id
end

Instance Method Details

#close!Object



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

def close!
  @connection.delete
  self
end

#fullscreen!Object



46
47
48
49
# File 'lib/webdriver/window.rb', line 46

def fullscreen!
  @connection.post "fullscreen"
  self
end

#maximize!Object



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

def maximize!
  @connection.post "maximize"
  self
end

#minimize!Object



27
28
29
30
# File 'lib/webdriver/window.rb', line 27

def minimize!
  @session_connection.post "window/minimize"
  self
end

#positionObject



14
15
16
# File 'lib/webdriver/window.rb', line 14

def position
  @connection.get "position"
end

#position!(opts) ⇒ Object



18
19
20
# File 'lib/webdriver/window.rb', line 18

def position! opts
  @connection.post "position", {}, opts
end

#rectObject



42
43
44
# File 'lib/webdriver/window.rb', line 42

def rect
  @session_connection.get "window/rect"
end

#rect!(width: nil, height: nil, x: nil, y: nil) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/webdriver/window.rb', line 32

def rect! width: nil, height: nil, x: nil, y:nil
  @session_connection.post "window/rect", {}, {
    width: width,
    height: height,
    x: x,
    y: y
  }
  self
end

#sizeObject



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

def size
  @connection.get "size"
end