Class: OperaWatir::Actions

Inherits:
Object show all
Defined in:
lib/operawatir/actions.rb

Overview

include_class java.util.lang.CharSequence

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(browser) ⇒ Actions

Returns a new instance of Actions.



10
11
12
13
14
15
# File 'lib/operawatir/actions.rb', line 10

def initialize(browser)
  self.browser, self.driver = browser, browser.driver
  self.actions = Java::OrgOpenqaSeleniumInteractions::Actions.new(@driver)

  @sym_key_map = {}
end

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



8
9
10
# File 'lib/operawatir/actions.rb', line 8

def actions
  @actions
end

#browserObject

Returns the value of attribute browser.



6
7
8
# File 'lib/operawatir/actions.rb', line 6

def browser
  @browser
end

#driverObject

Returns the value of attribute driver.



7
8
9
# File 'lib/operawatir/actions.rb', line 7

def driver
  @driver
end

Instance Method Details

#click(element = nil) ⇒ Object



60
61
62
63
# File 'lib/operawatir/actions.rb', line 60

def click(element = nil)
  element ? @actions.click(element.node) : @actions.click()
  self
end

#click_and_hold(element) ⇒ Object



50
51
52
53
# File 'lib/operawatir/actions.rb', line 50

def click_and_hold(element)
  @actions.clickAndHold(element.node)
  self
end

#context_click(element) ⇒ Object



80
81
82
83
# File 'lib/operawatir/actions.rb', line 80

def context_click(element)
  @actions.contextClick(element.node)
  self
end

#double_click(element = nil) ⇒ Object



65
66
67
68
# File 'lib/operawatir/actions.rb', line 65

def double_click(element = nil)
  element ? @actions.double_click(element.node) : @actions.double_click()
  self
end

#drag_and_drop(source, target) ⇒ Object



85
86
87
88
# File 'lib/operawatir/actions.rb', line 85

def drag_and_drop(source, target)
  @actions.dragAndDrop(source.node, target.node)
  self
end

#drag_and_drop_by(source, x_offset, y_offset) ⇒ Object



90
91
92
93
# File 'lib/operawatir/actions.rb', line 90

def drag_and_drop_by(source, x_offset, y_offset)
  @actions.dragAndDrop(source, x_offset, y_offset)
  self
end

#key_down(element, key = nil) ⇒ Object

If only one argument is given then it is the key, and so we call the method that accepts only the key



19
20
21
22
23
24
25
26
# File 'lib/operawatir/actions.rb', line 19

def key_down(element, key = nil)
  if not key
    @actions.keyDown(sym_to_key(element))
  else
    @actions.keyDown(element.node, sym_to_key(key))
  end
  self
end

#key_up(element, key = nil) ⇒ Object

If only one argument is given then it is the key, and so we call the method that accepts only the key



30
31
32
33
34
35
36
37
# File 'lib/operawatir/actions.rb', line 30

def key_up(element, key = nil)
  if not key
    @actions.keyUp(sym_to_key(element))
  else
    @actions.keyUp(element.node, sym_to_key(key))
  end
  self
end

#move_by_offset(x_offset, y_offset) ⇒ Object



75
76
77
78
# File 'lib/operawatir/actions.rb', line 75

def move_by_offset(x_offset, y_offset)
  @actions.moveByOffset(x_offset, y_offset)
  self
end

#move_to_element(element, x_offset = 0, y_offset = 0) ⇒ Object



70
71
72
73
# File 'lib/operawatir/actions.rb', line 70

def move_to_element(element, x_offset = 0, y_offset = 0)
  @actions.moveToElement(element.node, x_offset, y_offset)
  self
end

#performObject



95
96
97
# File 'lib/operawatir/actions.rb', line 95

def perform()
  @actions.perform()
end

#release(element) ⇒ Object



55
56
57
58
# File 'lib/operawatir/actions.rb', line 55

def release(element)
  @actions.release(element.node)
  self
end

#send_keys(element, keys_to_send = nil) ⇒ Object

If only one argument is given then it is the key, and so we call the method that accepts only the key



41
42
43
44
45
46
47
48
# File 'lib/operawatir/actions.rb', line 41

def send_keys(element, keys_to_send = nil)
  if not keys_to_send
    @actions.sendKeys(element)
  else
    @actions.sendKeys(element.node, keys_to_send)
  end
  self
end