[フレーム]

Class: Selenium::WebDriver::TargetLocator

Inherits:
Object
  • Object
  • Selenium::WebDriver::TargetLocator
show all
Defined in:
lib/selenium/webdriver/target_locator.rb

Instance Method Summary collapse

Constructor Details

#initialize(driver) ⇒ 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/target_locator.rb', line 9
def initialize(driver)
 @bridge = driver.bridge
end

Instance Method Details

#active_elementWebDriver::Element

get the active element

Returns:

56
57
58
# File 'lib/selenium/webdriver/target_locator.rb', line 56
def active_element
 @bridge.switchToActiveElement
end

#default_contentObject

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

64
65
66
# File 'lib/selenium/webdriver/target_locator.rb', line 64
def default_content
 @bridge.switchToDefaultContent
end

#frame(id) ⇒ Object

switch to the frame with the given id

17
18
19
# File 'lib/selenium/webdriver/target_locator.rb', line 17
def frame(id)
 @bridge.switchToFrame id
end

#window(id) ⇒ Object

switch to the frame with the given id

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

Parameters:

  • id

    A window handle

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File '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

AltStyle によって変換されたページ (->オリジナル) /