class Selenium::WebDriver::TargetLocator
Public Class Methods
new(bridge)
click to toggle source
@api private
# File lib/selenium/webdriver/common/target_locator.rb, line 9 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 68 def active_element @bridge.switchToActiveElement 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 84 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 76 def default_content @bridge.switchToDefaultContent end
frame(id)
click to toggle source
switch to the frame with the given id
# File lib/selenium/webdriver/common/target_locator.rb, line 17 def frame(id) @bridge.switchToFrame id end
parent_frame()
click to toggle source
switch to the parent frame
# File lib/selenium/webdriver/common/target_locator.rb, line 25 def parent_frame @bridge.switchToParentFrame 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 39 def window(id) if block_given? original = begin @bridge.getCurrentWindowHandle rescue Error::NoSuchWindowError nil end @bridge.switchToWindow id begin returned = yield ensure current_handles = @bridge.getWindowHandles original = current_handles.first unless current_handles.include? original @bridge.switchToWindow original returned end else @bridge.switchToWindow id end end