A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.rubydoc.info/github/teamcapybara/capybara/Capybara/Window below:

Window – Documentation for teamcapybara/capybara (master) – RubyDoc.info

Class: Capybara::Window
Inherits:
Object show all
Defined in:
lib/capybara/window.rb
Overview

The Window class represents a browser window.

You can get an instance of the class by calling any of:

Note that some drivers (e.g. Selenium) support getting size of/resizing/closing only current window. So if you invoke such method for:

Instance Attribute Summary collapse Instance Method Summary collapse Constructor Details #initialize(session, handle) ⇒ 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.

30
31
32
33
34
# File 'lib/capybara/window.rb', line 30

def initialize(session, handle)
  @session = session
  @driver = session.driver
  @handle = handle
end
Instance Attribute Details #handle ⇒ String

Returns a string that uniquely identifies window within session.

24
25
26
# File 'lib/capybara/window.rb', line 24

def handle
  @handle
end
#sessionCapybara::Session

Returns session that this window belongs to.

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

def session
  @session
end
Instance Method Details #close ⇒ Object

Close window.

If this method was called for window that is current, then after calling this method future invocations of other Capybara methods should raise session.driver.no_such_window_error until another window will be switched to.

If this method was called for window that is not current, then after calling this method current window should remain the same as it was before calling this method.

67
68
69
# File 'lib/capybara/window.rb', line 67

def close
  @driver.close_window(handle)
end
#closed? ⇒ Boolean

Returns whether the window is closed.

44
45
46
# File 'lib/capybara/window.rb', line 44

def closed?
  !exists?
end
#current? ⇒ Boolean

Returns whether this window is the window in which commands are being executed.

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

def current?
  @driver.current_window_handle == @handle
rescue @driver.no_such_window_error
  false
end
#eql?(other) ⇒ Boolean Also known as: ==
115
116
117
# File 'lib/capybara/window.rb', line 115

def eql?(other)
  other.is_a?(self.class) && @session == other.session && @handle == other.handle
end
#exists? ⇒ Boolean

Returns whether the window is not closed.

38
39
40
# File 'lib/capybara/window.rb', line 38

def exists?
  @driver.window_handles.include?(@handle)
end
#fullscreen ⇒ Object

Fullscreen window.

If a particular driver doesn't have concept of fullscreen it may not support this method.

If this method was called for window that is not current, then after calling this method current window should remain the same as it was before calling this method.

111
112
113
# File 'lib/capybara/window.rb', line 111

def fullscreen
  @driver.fullscreen_window(handle)
end
#hash ⇒ Object
120
121
122
# File 'lib/capybara/window.rb', line 120

def hash
  [@session, @handle].hash
end
#inspect ⇒ Object
124
125
126
# File 'lib/capybara/window.rb', line 124

def inspect
  "#<Window @handle=#{@handle.inspect}>"
end
#maximize ⇒ Object

Maximize window.

If a particular driver (e.g. headless driver) doesn't have concept of maximizing it may not support this method.

If this method was called for window that is not current, then after calling this method current window should remain the same as it was before calling this method.

100
101
102
# File 'lib/capybara/window.rb', line 100

def maximize
  wait_for_stable_size { @driver.maximize_window(handle) }
end
#resize_to(width, height) ⇒ Object

Resize window.

If this method was called for window that is not current, then after calling this method current window should remain the same as it was before calling this method.

88
89
90
# File 'lib/capybara/window.rb', line 88

def resize_to(width, height)
  wait_for_stable_size { @driver.resize_window_to(handle, width, height) }
end
#size ⇒ Array<(Integer, Integer)>

Get window size.

If this method was called for window that is not current, then after calling this method current window should remain the same as it was before calling this method.

77
78
79
# File 'lib/capybara/window.rb', line 77

def size
  @driver.window_size(handle)
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4