Parent

Class/Module Index [+]

Quicksearch

Selenium::WebDriver::TargetLocator

Public Class Methods

new(driver) click to toggle source

@api private

# File common/src/rb/lib/selenium/webdriver/target_locator.rb, line 9
def initialize(driver)
  @bridge = driver.bridge
end

Public Instance Methods

active_element() click to toggle source

get the active element

@return [WebDriver::Element]

# File common/src/rb/lib/selenium/webdriver/target_locator.rb, line 56
def active_element
  @bridge.switchToActiveElement
end
default_content() click to toggle source

selects either the first frame on the page, or the main document when a page contains iframes.

# File common/src/rb/lib/selenium/webdriver/target_locator.rb, line 64
def default_content
  @bridge.switchToDefaultContent
end
frame(id) click to toggle source

switch to the frame with the given id

# File common/src/rb/lib/selenium/webdriver/target_locator.rb, line 17
def frame(id)
  @bridge.switchToFrame id
end
window(id) click to toggle source

switch to the frame with the given id

If given a block, this method will return to the original window after block execution.

@param id

A window handle
# File common/src/rb/lib/selenium/webdriver/target_locator.rb, line 31
def window(id)
  if block_given?
    original = @bridge.getCurrentWindowHandle
    @bridge.switchToWindow id

    yield

    current_handles = @bridge.getWindowHandles

    if current_handles.size == 1
      original = current_handles.shift
    end

    @bridge.switchToWindow original
  else
    @bridge.switchToWindow id
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.