Class: Watir::Window

Inherits:
Object show all
Defined in:
lib/watir-webdriver/window_switching.rb

Overview

WindowSwitching

Instance Method Summary collapse

Constructor Details

#initialize(driver, id) ⇒ Window

Returns a new instance of Window



42
43
44
# File 'lib/watir-webdriver/window_switching.rb', line 42

def initialize(driver, id)
  @driver, @id = driver, id
end

Instance Method Details

#closeObject



55
56
57
# File 'lib/watir-webdriver/window_switching.rb', line 55

def close
  use { @driver.close }
end

#current?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/watir-webdriver/window_switching.rb', line 51

def current?
  @driver.window_handle == @id
end

#inspectObject



47
48
49
# File 'lib/watir-webdriver/window_switching.rb', line 47

def inspect
  '#<%s:0x%x id=%s>' % [self.class, hash*2, @id.to_s]
end

#titleObject



59
60
61
62
63
64
# File 'lib/watir-webdriver/window_switching.rb', line 59

def title
  title = nil
  use { title = @driver.title }

  title
end

#urlObject



66
67
68
69
70
71
# File 'lib/watir-webdriver/window_switching.rb', line 66

def url
  url = nil
  use { url = @driver.current_url }

  url
end

#use(&blk) ⇒ Object



73
74
75
76
# File 'lib/watir-webdriver/window_switching.rb', line 73

def use(&blk)
  @driver.switch_to.window(@id, &blk)
  self
end