Class: Selenium::WebDriver::TargetLocator
- Inherits:
-
Object
- Object
- Selenium::WebDriver::TargetLocator
- Defined in:
- lib/selenium/webdriver/common/target_locator.rb
Instance Method Summary collapse
-
#active_element ⇒ WebDriver::Element
get the active element.
-
#alert ⇒ Object
switches to the currently active modal dialog for this particular driver instance.
-
#default_content ⇒ Object
selects either the first frame on the page, or the main document when a page contains iframes.
-
#frame(id) ⇒ Object
switch to the frame with the given id.
-
#initialize(bridge) ⇒ TargetLocator
constructor
private
A new instance of TargetLocator.
-
#parent_frame ⇒ Object
switch to the parent frame.
-
#window(id) ⇒ Object
switch to the given window handle.
Constructor Details
#initialize(bridge) ⇒ TargetLocator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of TargetLocator.
9 10 11 |
# File 'lib/selenium/webdriver/common/target_locator.rb', line 9 def initialize(bridge) @bridge = bridge end |
Instance Method Details
#active_element ⇒ WebDriver::Element
get the active element
68 69 70 |
# File 'lib/selenium/webdriver/common/target_locator.rb', line 68 def active_element @bridge.switchToActiveElement end |
#alert ⇒ Object
switches to the currently active modal dialog for this particular driver instance
84 85 86 |
# File 'lib/selenium/webdriver/common/target_locator.rb', line 84 def alert Alert.new(@bridge) end |
#default_content ⇒ Object
selects either the first frame on the page, or the main document when a page contains iframes.
76 77 78 |
# File 'lib/selenium/webdriver/common/target_locator.rb', line 76 def default_content @bridge.switchToDefaultContent end |
#frame(id) ⇒ Object
switch to the frame with the given id
17 18 19 |
# File 'lib/selenium/webdriver/common/target_locator.rb', line 17 def frame(id) @bridge.switchToFrame id end |
#parent_frame ⇒ Object
switch to the parent frame
25 26 27 |
# File 'lib/selenium/webdriver/common/target_locator.rb', line 25 def parent_frame @bridge.switchToParentFrame end |
#window(id) ⇒ Object
switch to the given window handle
If given a block, this method will switch back to the original window after block execution.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# 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 |