Class: Akephalos::Node
- Inherits:
-
Object
- Object
- Akephalos::Node
- Defined in:
- lib/akephalos/node.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #checked? ⇒ Boolean
- #click ⇒ Object
- #find(selector) ⇒ Object
- #fire_event(name) ⇒ Object
-
#initialize(node) ⇒ Node
constructor
A new instance of Node.
- #options ⇒ Object
- #select_option(option) ⇒ Object
- #selected_options ⇒ Object
- #tag_name ⇒ Object
- #text ⇒ Object
- #unselect_option(option) ⇒ Object
- #value ⇒ Object
- #value=(value) ⇒ Object
- #visible? ⇒ Boolean
Constructor Details
#initialize(node) ⇒ Node
Returns a new instance of Node.
3 4 5 6 |
# File 'lib/akephalos/node.rb', line 3 def initialize(node) @nodes = [] @_node = node end |
Instance Method Details
#[](name) ⇒ Object
16 17 18 |
# File 'lib/akephalos/node.rb', line 16 def [](name) @_node.hasAttribute(name.to_s) ? @_node.getAttribute(name.to_s) : nil end |
#checked? ⇒ Boolean
8 9 10 |
# File 'lib/akephalos/node.rb', line 8 def checked? @_node.isChecked end |
#click ⇒ Object
77 78 79 80 81 |
# File 'lib/akephalos/node.rb', line 77 def click @_node.click @_node.getPage.getEnclosingWindow.getJobManager.waitForJobs(1000) @_node.getPage.getEnclosingWindow.getJobManager.waitForJobsStartingBefore(1000) end |
#find(selector) ⇒ Object
83 84 85 86 87 |
# File 'lib/akephalos/node.rb', line 83 def find(selector) nodes = @_node.getByXPath(selector).map { |node| Node.new(node) } @nodes << nodes nodes end |
#fire_event(name) ⇒ Object
65 66 67 |
# File 'lib/akephalos/node.rb', line 65 def fire_event(name) @_node.fireEvent(name) end |
#options ⇒ Object
57 58 59 |
# File 'lib/akephalos/node.rb', line 57 def @_node.getOptions.map { |node| Node.new(node) } end |
#select_option(option) ⇒ Object
45 46 47 48 49 |
# File 'lib/akephalos/node.rb', line 45 def select_option(option) opt = @_node.getOptions.detect { |o| o.asText == option } opt && opt.setSelected(true) end |
#selected_options ⇒ Object
61 62 63 |
# File 'lib/akephalos/node.rb', line 61 def @_node.getSelectedOptions.map { |node| Node.new(node) } end |
#tag_name ⇒ Object
69 70 71 |
# File 'lib/akephalos/node.rb', line 69 def tag_name @_node.getNodeName end |
#text ⇒ Object
12 13 14 |
# File 'lib/akephalos/node.rb', line 12 def text @_node.asText end |
#unselect_option(option) ⇒ Object
51 52 53 54 55 |
# File 'lib/akephalos/node.rb', line 51 def unselect_option(option) opt = @_node.getOptions.detect { |o| o.asText == option } opt && opt.setSelected(false) end |
#value ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/akephalos/node.rb', line 20 def value case tag_name when "select" if self[:multiple] @_node..map { |option| option.text } else selected_option = @_node..first selected_option ? selected_option.text : nil end when "textarea" @_node.getText else self[:value] end end |
#value=(value) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/akephalos/node.rb', line 36 def value=(value) case tag_name when "textarea" @_node.setText(value) when "input" @_node.setValueAttribute(value) end end |
#visible? ⇒ Boolean
73 74 75 |
# File 'lib/akephalos/node.rb', line 73 def visible? @_node.isDisplayed end |