Class: Watir::FramedDriver Private

Inherits:
Object
  • Object
show all
Includes:
Exception
Defined in:
lib/watir/elements/iframe.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(element, browser) ⇒ FramedDriver

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 FramedDriver.



112
113
114
115
116
# File 'lib/watir/elements/iframe.rb', line 112

def initialize(element, browser)
  @element = element
  @browser = browser
  @driver = browser.wd
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object

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.



143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/watir/elements/iframe.rb', line 143

def method_missing(meth, *args, &blk)
  if %i[find_element find_elements].include?(meth)
    @driver.send(meth, *args, &blk)
  elsif @driver.respond_to?(meth)
    switch!
    @driver.send(meth, *args, &blk)
  elsif @element.respond_to?(meth)
    @element.send(meth, *args, &blk)
  else
    super
  end
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

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.



118
119
120
# File 'lib/watir/elements/iframe.rb', line 118

def ==(other)
  wd == other.wd
end

#respond_to_missing?(meth, _include_private) ⇒ Boolean

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:

  • (Boolean)


139
140
141
# File 'lib/watir/elements/iframe.rb', line 139

def respond_to_missing?(meth, _include_private)
  @driver.respond_to?(meth) || @element.respond_to?(meth) || super(meth, false)
end

#send_keys(*args) ⇒ Object

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.



123
124
125
126
# File 'lib/watir/elements/iframe.rb', line 123

def send_keys(*args)
  switch!
  @driver.switch_to.active_element.send_keys(*args)
end

#switch!Object

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.



128
129
130
131
132
133
# File 'lib/watir/elements/iframe.rb', line 128

def switch!
  @driver.switch_to.frame @element
  @browser.default_context = false
rescue Selenium::WebDriver::Error::NoSuchFrameError => e
  raise UnknownFrameException, e.message
end

#wdObject

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.



135
136
137
# File 'lib/watir/elements/iframe.rb', line 135

def wd
  @element
end