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.


109
110
111
112
113
# File 'lib/watir/elements/iframe.rb', line 109

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.


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

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.


115
116
117
# File 'lib/watir/elements/iframe.rb', line 115

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

#respond_to_missing?(meth, _include_private = false) ⇒ 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)

137
138
139
# File 'lib/watir/elements/iframe.rb', line 137

def respond_to_missing?(meth, _include_private = false)
  @driver.respond_to?(meth) || @element.respond_to?(meth) || super
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.


120
121
122
123
# File 'lib/watir/elements/iframe.rb', line 120

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.


125
126
127
128
129
130
131
# File 'lib/watir/elements/iframe.rb', line 125

def switch!
  @driver.switch_to.frame @element
  @browser.default_context = false
  @browser.after_hooks.run
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.


133
134
135
# File 'lib/watir/elements/iframe.rb', line 133

def wd
  @element
end