Class: Symbiont::WebObjects::WebObject
- Inherits:
-
Object
- Object
- Symbiont::WebObjects::WebObject
show all
- Defined in:
- lib/symbiont/web_objects/_common.rb
Overview
This class is designed to provide methods for functionality that is common to all web objects and that may need to be called directly on a web object (as opposed to a web object wrapped up by the platform).
Direct Known Subclasses
Button, CheckBox, Div, Heading, HiddenField, Label, Link, ListItem, Option, OrderedList, Paragraph, Radio, SelectList, Span, Table, TableCell, TableRow, TextArea, TextField, UnorderedList
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(web_object) ⇒ WebObject
Returns a new instance of WebObject.
12
13
14
|
# File 'lib/symbiont/web_objects/_common.rb', line 12
def initialize(web_object)
@web_object = web_object
end
|
Instance Attribute Details
#web_object ⇒ Object
Returns the value of attribute web_object.
10
11
12
|
# File 'lib/symbiont/web_objects/_common.rb', line 10
def web_object
@web_object
end
|
Class Method Details
.provide_locator_for(locator) ⇒ Object
def self.locator_for(locator)
how, what = locator.keys.first, locator.values.first
return how => what if usable_selectors.include? how
return selector_mapping[how] => what if selector_mapping[how]
return nil => what
end
162
163
164
165
166
167
168
169
|
# File 'lib/symbiont/web_objects/_common.rb', line 162
def self.provide_locator_for(locator)
locator.each do |key, value|
how, what = locator.keys.first, locator.values.first
return how => what if usable_selectors.include? how
return selector_mapping[how] => what if selector_mapping[how]
return nil => what
end
end
|
.selector_mapping ⇒ Object
151
152
153
|
# File 'lib/symbiont/web_objects/_common.rb', line 151
def self.selector_mapping
{}
end
|
.usable_selectors ⇒ Object
147
148
149
|
# File 'lib/symbiont/web_objects/_common.rb', line 147
def self.usable_selectors
[:id, :name, :xpath, :class, :index]
end
|
Instance Method Details
#==(other) ⇒ Object
96
97
98
|
# File 'lib/symbiont/web_objects/_common.rb', line 96
def ==(other)
web_object == other.web_object
end
|
#attribute(name) ⇒ Object
44
45
46
|
# File 'lib/symbiont/web_objects/_common.rb', line 44
def attribute(name)
web_object.attribute_value(name)
end
|
#clear ⇒ Object
72
73
74
|
# File 'lib/symbiont/web_objects/_common.rb', line 72
def clear
web_object.clear
end
|
#click ⇒ Object
60
61
62
|
# File 'lib/symbiont/web_objects/_common.rb', line 60
def click
web_object.click
end
|
#disabled? ⇒ Boolean
20
21
22
|
# File 'lib/symbiont/web_objects/_common.rb', line 20
def disabled?
not enabled?
end
|
#double_click ⇒ Object
64
65
66
|
# File 'lib/symbiont/web_objects/_common.rb', line 64
def double_click
web_object.double_click
end
|
#enabled? ⇒ Boolean
16
17
18
|
# File 'lib/symbiont/web_objects/_common.rb', line 16
def enabled?
web_object.enabled?
end
|
#exists? ⇒ Boolean
28
29
30
|
# File 'lib/symbiont/web_objects/_common.rb', line 28
def exists?
web_object.exists?
end
|
#fire_event(event) ⇒ Object
88
89
90
|
# File 'lib/symbiont/web_objects/_common.rb', line 88
def fire_event(event)
web_object.fire_event(event)
end
|
#flash ⇒ Object
40
41
42
|
# File 'lib/symbiont/web_objects/_common.rb', line 40
def flash
web_object.flash
end
|
#focus ⇒ Object
48
49
50
|
# File 'lib/symbiont/web_objects/_common.rb', line 48
def focus
web_object.focus
end
|
#hover ⇒ Object
84
85
86
|
# File 'lib/symbiont/web_objects/_common.rb', line 84
def hover
web_object.hover
end
|
#html ⇒ Object
56
57
58
|
# File 'lib/symbiont/web_objects/_common.rb', line 56
def html
web_object.html
end
|
#id ⇒ Object
32
33
34
|
# File 'lib/symbiont/web_objects/_common.rb', line 32
def id
web_object.id
end
|
#inspect ⇒ Object
80
81
82
|
# File 'lib/symbiont/web_objects/_common.rb', line 80
def inspect
web_object.inspect
end
|
#parent ⇒ Object
100
101
102
103
104
105
|
# File 'lib/symbiont/web_objects/_common.rb', line 100
def parent
parent = web_object.parent
type = web_object.type if parent.tag_name.to_sym == :input
object_class = ::Symbiont::WebObjects.get_class_for(parent.tag_name, type)
object_class.new(parent)
end
|
142
143
144
145
|
# File 'lib/symbiont/web_objects/_common.rb', line 142
def scroll_into_view(wait=2)
sleep wait
web_object.wd.location_once_scrolled_into_view
end
|
#send_keys(*args) ⇒ Object
92
93
94
|
# File 'lib/symbiont/web_objects/_common.rb', line 92
def send_keys(*args)
web_object.send_keys(*args)
end
|
#style(property) ⇒ Object
76
77
78
|
# File 'lib/symbiont/web_objects/_common.rb', line 76
def style(property)
web_object.style(property)
end
|
#tag_name ⇒ Object
68
69
70
|
# File 'lib/symbiont/web_objects/_common.rb', line 68
def tag_name
web_object.tag_name
end
|
#text ⇒ Object
52
53
54
|
# File 'lib/symbiont/web_objects/_common.rb', line 52
def text
web_object.text
end
|
#value ⇒ Object
36
37
38
|
# File 'lib/symbiont/web_objects/_common.rb', line 36
def value
web_object.value
end
|
#visible? ⇒ Boolean
24
25
26
|
# File 'lib/symbiont/web_objects/_common.rb', line 24
def visible?
web_object.present?
end
|
#wait_until(timeout = ::Symbiont.element_level_wait, message = nil, &block) ⇒ Object
107
108
109
|
# File 'lib/symbiont/web_objects/_common.rb', line 107
def wait_until(timeout=::Symbiont.element_level_wait, message=nil, &block)
Object::Watir::Wait.until(timeout, message, &block)
end
|
#when_actionable(timeout = ::Symbiont.element_level_wait) ⇒ Object
Also known as:
when_present
111
112
113
114
|
# File 'lib/symbiont/web_objects/_common.rb', line 111
def when_actionable(timeout=::Symbiont.element_level_wait)
web_object.wait_until_present(timeout)
self
end
|
#when_not_actionable(timeout = ::Symbiont.element_level_wait) ⇒ Object
Also known as:
when_not_present
118
119
120
121
|
# File 'lib/symbiont/web_objects/_common.rb', line 118
def when_not_actionable(timeout=::Symbiont.element_level_wait)
web_object.wait_while_present(timeout)
self
end
|
#when_not_visible(timeout = ::Symbiont.element_level_wait) ⇒ Object
Also known as:
must_not_be_visible
132
133
134
135
136
137
|
# File 'lib/symbiont/web_objects/_common.rb', line 132
def when_not_visible(timeout=::Symbiont.element_level_wait)
Object::Watir::Wait.while(timeout, "Object still visible after #{timeout} seconds.") do
visible?
end
self
end
|
#when_visible(timeout = ::Symbiont.element_level_wait) ⇒ Object
Also known as:
must_be_visible
125
126
127
128
129
130
|
# File 'lib/symbiont/web_objects/_common.rb', line 125
def when_visible(timeout=::Symbiont.element_level_wait)
Object::Watir::Wait.until(timeout, "Object not visible within #{timeout} seconds.") do
visible?
end
self
end
|