Module: OperaWatir::Compat::Window

Includes:
Deprecated
Defined in:
lib/operawatir/compat/window.rb

Instance Method Summary collapse

Instance Method Details

#contains_text(str) ⇒ Boolean

Checks whether the body has the given text in it.

Parameters:

  • str (String)

    Text to search for.

Returns:

  • (Boolean)

    true if the body contains the given text, false otherwise



14
15
16
# File 'lib/operawatir/compat/window.rb', line 14

def contains_text(str)
  text.index(str)
end

#elements_by_xpath(value) ⇒ OperaWatir::Collection Also known as: element_by_xpath

Find elements that match the given XPath.

Parameters:

  • value (String)

    The XPath expression to search for.

Returns:



27
28
29
# File 'lib/operawatir/compat/window.rb', line 27

def elements_by_xpath(value)
  find_by_xpath(value)
end

#frame(selector, argument) ⇒ Object

TODO This is a relic from the old OperaWatir implementation, tests should be updated.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/operawatir/compat/window.rb', line 50

def frame(selector, argument)
  case selector
  when :name
    driver.switch_to.frame(argument)
  when :index
    driver.switch_to.frame(argument.to_i - 1)  # index starts from 1 in Watir
  else
    raise OperaWatir::Exceptions::NotImplementedException,
      "We do not support the `#{selector}' selector yet"
  end
end

#get_hashObject

Opera specific



38
39
40
# File 'lib/operawatir/compat/window.rb', line 38

def get_hash
  visual_hash
end

#show_framesObject



68
69
70
71
72
73
# File 'lib/operawatir/compat/window.rb', line 68

def show_frames
  frames = driver.list_frames
  text = "There are #{frames.length.to_s} frames\n"
  frames.each_with_index { |frame, i| text << "frame index: #{(i.to_i + 1).to_s} name: #{frame.to_s}\n" }
  text
end

#switch_to_defaultObject



63
64
65
# File 'lib/operawatir/compat/window.rb', line 63

def switch_to_default
  driver.switch_to.default_content
end