Class: RubyApp::Element::Event
Direct Known Subclasses
AssertedEvent, ExceptionEvent, TriggeredEvent, RubyApp::Elements::Mobile::Calendars::Month::ChangedEvent, RubyApp::Elements::Mobile::Click::ClickedEvent, RubyApp::Elements::Mobile::Document::LoadedEvent, RubyApp::Elements::Mobile::Input::ChangedEvent, RubyApp::Elements::Mobile::List::ClickedEvent, RubyApp::Elements::Mobile::Page::BeforeHiddenEvent, RubyApp::Elements::Mobile::Page::HiddenEvent, RubyApp::Elements::Mobile::Page::LoadedEvent, RubyApp::Elements::Mobile::Page::ShownEvent, RubyApp::Elements::Mobile::Page::SwipedEvent
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#add_class(selector, _class) ⇒ Object
-
#assert_exists_input(text, value = nil) ⇒ Object
-
#assert_exists_link(text) ⇒ Object
-
#assert_exists_selector(selector) ⇒ Object
-
#assert_exists_selector_for(selector) ⇒ Object
-
#assert_exists_selector_value_for(selector, value) ⇒ Object
-
#assert_exists_text(text) ⇒ Object
-
#confirm_refresh_browser(message) ⇒ Object
-
#create_trigger(element, interval) ⇒ Object
-
#destroy_trigger(element) ⇒ Object
-
#execute(statement) ⇒ Object
-
#go(url) ⇒ Object
-
#initialize(data = nil) ⇒ Event
constructor
-
#log(message) ⇒ Object
-
#process! ⇒ Object
-
#quit! ⇒ Object
-
#refresh_browser ⇒ Object
-
#remove_class(selector, _class) ⇒ Object
-
#remove_page(page) ⇒ Object
-
#set_cookie(name, value, expires = Time.now + 365*24*60*60) ⇒ Object
-
#show_page(page, options = {}) ⇒ Object
-
#swipe(direction) ⇒ Object
-
#tap_link(text) ⇒ Object
-
#tap_list_item(text) ⇒ Object
-
#tap_list_link(text) ⇒ Object
-
#tap_selector(selector) ⇒ Object
-
#to_hash ⇒ Object
-
#today ⇒ Object
-
#update_element(element) ⇒ Object
-
#update_input(text, value) ⇒ Object
-
#update_style(selector, property, value) ⇒ Object
-
#update_text(selector, value) ⇒ Object
-
#update_value(selector, value) ⇒ Object
-
#update_value_for(selector, value) ⇒ Object
localize, translate
Constructor Details
#initialize(data = nil) ⇒ Event
Returns a new instance of Event.
Instance Attribute Details
#now ⇒ Object
Returns the value of attribute now.
26
27
28
|
# File 'lib/ruby_app/element.rb', line 26
def now
@now
end
|
#session ⇒ Object
Returns the value of attribute session.
26
27
28
|
# File 'lib/ruby_app/element.rb', line 26
def session
@session
end
|
#source ⇒ Object
Returns the value of attribute source.
26
27
28
|
# File 'lib/ruby_app/element.rb', line 26
def source
@source
end
|
Class Method Details
.from_hash(data) ⇒ Object
197
198
199
|
# File 'lib/ruby_app/element.rb', line 197
def self.from_hash(data)
Kernel.eval(data['_class']).new(data)
end
|
Instance Method Details
#add_class(selector, _class) ⇒ Object
98
99
100
101
|
# File 'lib/ruby_app/element.rb', line 98
def add_class(selector, _class)
_selector = ".ui-page-active #{selector}"
self.execute("RubyApp.addClass(#{_selector.to_json}, #{_class.to_json});")
end
|
165
166
167
168
|
# File 'lib/ruby_app/element.rb', line 165
def assert_exists_input(text, value = nil)
self.assert_exists_selector_for("label:contains('#{text}')") unless value
self.assert_exists_selector_value_for("label:contains('#{text}')", value) if value
end
|
#assert_exists_link(text) ⇒ Object
156
157
158
|
# File 'lib/ruby_app/element.rb', line 156
def assert_exists_link(text)
self.assert_exists_selector("a:contains('#{text}')")
end
|
#assert_exists_selector(selector) ⇒ Object
160
161
162
163
|
# File 'lib/ruby_app/element.rb', line 160
def assert_exists_selector(selector)
_selector = ".ui-page-active #{selector}"
self.execute("RubyApp.assertExists(#{_selector.to_json});")
end
|
#assert_exists_selector_for(selector) ⇒ Object
170
171
172
173
|
# File 'lib/ruby_app/element.rb', line 170
def assert_exists_selector_for(selector)
_selector = ".ui-page-active #{selector}"
self.execute("RubyApp.assertExistsFor(#{_selector.to_json});")
end
|
#assert_exists_selector_value_for(selector, value) ⇒ Object
175
176
177
178
|
# File 'lib/ruby_app/element.rb', line 175
def assert_exists_selector_value_for(selector, value)
_selector = ".ui-page-active #{selector}"
self.execute("RubyApp.assertExistsValueFor(#{_selector.to_json}, #{value.to_json});")
end
|
#assert_exists_text(text) ⇒ Object
152
153
154
|
# File 'lib/ruby_app/element.rb', line 152
def assert_exists_text(text)
self.assert_exists_selector("*:contains('#{text}')")
end
|
#confirm_refresh_browser(message) ⇒ Object
60
61
62
|
# File 'lib/ruby_app/element.rb', line 60
def confirm_refresh_browser(message)
self.execute("RubyApp.confirmRefreshBrowser(#{message.to_json});")
end
|
#create_trigger(element, interval) ⇒ Object
77
78
79
|
# File 'lib/ruby_app/element.rb', line 77
def create_trigger(element, interval)
self.execute("RubyApp.createTrigger(#{element.element_id.to_json}, #{(interval * 1000).to_json});")
end
|
#destroy_trigger(element) ⇒ Object
81
82
83
|
# File 'lib/ruby_app/element.rb', line 81
def destroy_trigger(element)
self.execute("RubyApp.destroyTrigger(#{element.element_id.to_json});")
end
|
#execute(statement) ⇒ Object
184
185
186
|
# File 'lib/ruby_app/element.rb', line 184
def execute(statement)
@statements << statement
end
|
#go(url) ⇒ Object
89
90
91
|
# File 'lib/ruby_app/element.rb', line 89
def go(url)
self.execute("RubyApp.go(#{url.to_json});")
end
|
#log(message) ⇒ Object
180
181
182
|
# File 'lib/ruby_app/element.rb', line 180
def log(message)
self.execute("RubyApp.log(#{message.to_json});")
end
|
#process! ⇒ Object
52
53
54
|
# File 'lib/ruby_app/element.rb', line 52
def process!
self.source.send(:on_event, self)
end
|
#quit! ⇒ Object
85
86
87
|
# File 'lib/ruby_app/element.rb', line 85
def quit!
self.go('/quit')
end
|
#refresh_browser ⇒ Object
56
57
58
|
# File 'lib/ruby_app/element.rb', line 56
def refresh_browser
self.execute("RubyApp.refreshBrowser();")
end
|
#remove_class(selector, _class) ⇒ Object
103
104
105
106
|
# File 'lib/ruby_app/element.rb', line 103
def remove_class(selector, _class)
_selector = ".ui-page-active #{selector}"
self.execute("RubyApp.removeClass(#{_selector.to_json}, #{_class.to_json});")
end
|
#remove_page(page) ⇒ Object
69
70
71
|
# File 'lib/ruby_app/element.rb', line 69
def remove_page(page)
self.execute("RubyApp.removePage(#{page.element_id.to_json});")
end
|
#set_cookie(name, value, expires = Time.now + 365*24*60*60) ⇒ Object
127
128
129
|
# File 'lib/ruby_app/element.rb', line 127
def set_cookie(name, value, expires = Time.now + 365*24*60*60)
self.execute("RubyApp.setCookie(#{name.to_json}, #{value.to_json}, new Date(#{expires.year}, #{expires.month - 1}, #{expires.day}, #{expires.hour}, #{expires.min}, #{expires.sec}));")
end
|
#show_page(page, options = {}) ⇒ Object
64
65
66
67
|
# File 'lib/ruby_app/element.rb', line 64
def show_page(page, options = {})
options.merge!(:changeHash => false)
self.execute("RubyApp.showPage(#{page.element_id.to_json}, #{options.to_json});")
end
|
#swipe(direction) ⇒ Object
148
149
150
|
# File 'lib/ruby_app/element.rb', line 148
def swipe(direction)
self.execute("RubyApp.swipe#{direction == :left ? 'Left' : 'Right'}();")
end
|
#tap_link(text) ⇒ Object
131
132
133
|
# File 'lib/ruby_app/element.rb', line 131
def tap_link(text)
self.tap_selector("a:contains('#{text}')")
end
|
#tap_list_item(text) ⇒ Object
135
136
137
|
# File 'lib/ruby_app/element.rb', line 135
def tap_list_item(text)
self.tap_selector("a.item:contains('#{text}')")
end
|
#tap_list_link(text) ⇒ Object
139
140
141
|
# File 'lib/ruby_app/element.rb', line 139
def tap_list_link(text)
self.tap_selector("a.link[title*='#{text}']")
end
|
#tap_selector(selector) ⇒ Object
143
144
145
146
|
# File 'lib/ruby_app/element.rb', line 143
def tap_selector(selector)
_selector = ".ui-page-active #{selector}"
self.execute("RubyApp.tap(#{_selector.to_json});")
end
|
#to_hash ⇒ Object
188
189
190
191
192
193
194
195
|
# File 'lib/ruby_app/element.rb', line 188
def to_hash
{
'_class' => self.class.to_s,
'now' => @now,
'source' => @source ? @source.element_id : nil,
'statements' => @statements
}
end
|
#today ⇒ Object
48
49
50
|
# File 'lib/ruby_app/element.rb', line 48
def today
@now.send(:to_date)
end
|
#update_element(element) ⇒ Object
73
74
75
|
# File 'lib/ruby_app/element.rb', line 73
def update_element(element)
self.execute("RubyApp.updateElement(#{element.element_id.to_json});")
end
|
118
119
120
|
# File 'lib/ruby_app/element.rb', line 118
def update_input(text, value)
self.update_value_for("label:contains('#{text}')", value)
end
|
#update_style(selector, property, value) ⇒ Object
93
94
95
96
|
# File 'lib/ruby_app/element.rb', line 93
def update_style(selector, property, value)
_selector = ".ui-page-active #{selector}"
self.execute("RubyApp.updateStyle(#{_selector.to_json}, #{property.to_json}, #{value.to_json});")
end
|
#update_text(selector, value) ⇒ Object
108
109
110
111
|
# File 'lib/ruby_app/element.rb', line 108
def update_text(selector, value)
_selector = ".ui-page-active #{selector}"
self.execute("RubyApp.updateText(#{_selector.to_json}, #{value.to_json});")
end
|
#update_value(selector, value) ⇒ Object
113
114
115
116
|
# File 'lib/ruby_app/element.rb', line 113
def update_value(selector, value)
_selector = ".ui-page-active #{selector}"
self.execute("RubyApp.updateValue(#{_selector.to_json}, #{value.to_json});")
end
|
#update_value_for(selector, value) ⇒ Object
122
123
124
125
|
# File 'lib/ruby_app/element.rb', line 122
def update_value_for(selector, value)
_selector = ".ui-page-active #{selector}"
self.execute("RubyApp.updateValueFor(#{_selector.to_json}, #{value.to_json});")
end
|