class Selenium::WebDriver::TargetLocator
Public Class Methods
new(bridge)
click to toggle source
@api private
# File lib/selenium/webdriver/common/target_locator.rb, line 26 def initialize(bridge) @bridge = bridge end
Public Instance Methods
active_element()
click to toggle source
get the active element
@return [WebDriver::Element]
# File lib/selenium/webdriver/common/target_locator.rb, line 89 def active_element @bridge.switch_to_active_element end
alert()
click to toggle source
switches to the currently active modal dialog for this particular driver instance
# File lib/selenium/webdriver/common/target_locator.rb, line 105 def alert Alert.new(@bridge) 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 lib/selenium/webdriver/common/target_locator.rb, line 97 def default_content @bridge.switch_to_default_content end
frame(id)
click to toggle source
switch to the frame with the given id
# File lib/selenium/webdriver/common/target_locator.rb, line 34 def frame(id) @bridge.switch_to_frame id end
parent_frame()
click to toggle source
switch to the parent frame
# File lib/selenium/webdriver/common/target_locator.rb, line 42 def parent_frame @bridge.switch_to_parent_frame end
window(id) { || ... }
click to toggle source
switch to the given window handle
If given a block, this method will switch back to the original window after block execution.
@param id
A window handle, obtained through Driver#window_handles
# File lib/selenium/webdriver/common/target_locator.rb, line 56 def window(id) if block_given? original = begin @bridge.window_handle rescue Error::NoSuchWindowError nil end unless @bridge.window_handles.include? id raise Error::NoSuchWindowError, "The specified identifier '#{id}' is not found in the window handle list" end @bridge.switch_to_window id begin returned = yield ensure current_handles = @bridge.window_handles original = current_handles.first unless current_handles.include? original @bridge.switch_to_window original returned end else @bridge.switch_to_window id end end