@api private
# File lib/selenium/webdriver/common/target_locator.rb, line 9 def initialize(bridge) @bridge = bridge end
get the active element
@return [WebDriver::Element]
# File lib/selenium/webdriver/common/target_locator.rb, line 59 def active_element @bridge.switchToActiveElement end
switches to the currently active modal dialog for this particular driver instance
# File lib/selenium/webdriver/common/target_locator.rb, line 75 def alert Alert.new(@bridge) end
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 67 def default_content @bridge.switchToDefaultContent end
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
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 31 def window(id) if block_given? original = @bridge.getCurrentWindowHandle @bridge.switchToWindow id begin returned = yield ensure current_handles = @bridge.getWindowHandles if current_handles.size == 1 original = current_handles.shift end @bridge.switchToWindow original returned end else @bridge.switchToWindow id end end