Module: CalendarMethods

Defined in:
lib/kuali-sakai-common-lib/calendar.rb

Instance Method Summary collapse

Instance Method Details

#alert_boxObject

This is the alert box object. If you want to get the text contents of the alert box, use alert_box.text. That will get you a string object that is the text contents.



60
61
62
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 60

def alert_box
  frm.div(:class=>"alertMessage")
end

#earlierObject



186
187
188
189
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 186

def earlier
  frm().link(:text=>"Earlier").click
  Calendar.new(@browser)
end

#end_day=(item) ⇒ Object

Selects the specified value in the End Day select list.



106
107
108
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 106

def end_day=(item)
  frm.select(:id=>"customEndDay").select(item)
end

#end_month=(item) ⇒ Object

Selects the specified value in the end month select list.



101
102
103
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 101

def end_month=(item)
  frm.select(:id=>"customEndMonth").select(item)
end

#end_year=(item) ⇒ Object

Selects the specified value in the End Year select list.



111
112
113
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 111

def end_year=(item)
  frm.select(:id=>"customEndYear").select(item)
end

#event_href(title) ⇒ Object

Returns the href value of the target link use for validation when you are testing whether the link will appear again on another screen, since often times validation by title text alone will not work.



76
77
78
79
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 76

def event_href(title)
  truncated = title[0..5]
  return frm.link(:text=>/#{Regexp.escape(truncated)}/).href
end

#event_listObject

Returns an array of the titles of the displayed events.



131
132
133
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 131

def event_list
  events_list
end

#events_listObject

Returns an array for the listed events. This array contains more than simply strings of the event titles, because often the titles are truncated to fit on the screen. In addition, getting the “title” tag of the link is often problematic because titles can contain double-quotes, which will mess up the HTML of the anchor tag (there is probably an XSS vulnerability to exploit, there. This should be extensively tested.).

Because of these issues, the array contains the title tag, the anchor text, and the entire href string for every event listed on the page. Having all three items available should ensure that verification steps don’t give false results–especially when you are doing a negative test (checking that an event is NOT present).



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 146

def events_list
  list = []
  if frm.table(:class=>"calendar").exist?
    events_table = frm.table(:class=>"calendar")
  else
    events_table = frm.table(:class=>"listHier lines nolines")
  end
  events_table.links.each do |link|
    list << link.title
    list << link.text
    list << link.href
    list << link.html[/(?<="location=").+doDescription/]
  end
  list.compact!
  list.uniq!
  return list
end

#filter_eventsObject

Clicks the Filter Events button, then re-instantiates the Calendar class to avoid the possibility of an ObsoleteElement error.



118
119
120
121
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 118

def filter_events
  frm.button(:name=>"eventSubmit_doCustomdate").click
  Calendar.new(@browser)
end

#go_to_todayObject

Clicks the Go to Today button, then reinstantiates the Calendar class.



125
126
127
128
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 125

def go_to_today
  frm.button(:value=>"Go to Today").click
  Calendar.new(@browser)
end

#headerObject

Returns the text of the Calendar’s header.



52
53
54
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 52

def header
  frm.div(:class=>"portletBody").h3.text
end

#laterObject



191
192
193
194
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 191

def later
  frm().link(:text=>"Later").click
  Calendar.new(@browser)
end

#nextObject

Clicks the “Next X” button, where X might be Day, Week, or Month, then reinstantiates the Calendar class to ensure against any obsolete element errors.



175
176
177
178
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 175

def next
  frm.button(:name=>"eventSubmit_doNext").click
  Calendar.new(@browser)
end

#open_event(title) ⇒ Object

Clicks the link to the specified event, then instantiates the EventDetail class.



66
67
68
69
70
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 66

def open_event(title)
  truncated = title[0..5]
  frm.link(:text=>/#{Regexp.escape(truncated)}/).click
  EventDetail.new(@browser)
end

#previousObject

Clicks the “Previous X” button, where X might be Day, Week, or Month, then reinstantiates the Calendar class to ensure against any obsolete element errors.



167
168
169
170
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 167

def previous
  frm.button(:name=>"eventSubmit_doPrev").click
  Calendar.new(@browser)
end

#select_view(item) ⇒ Object

Selects the specified item in the View select list, then reinstantiates the Class.



32
33
34
35
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 32

def select_view(item)
  frm.select(:id=>"view").select(item)
  Calendar.new(@browser)
end

#set_as_default_viewObject

Clicks the “Set as Default View” button



197
198
199
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 197

def set_as_default_view
  frm.link(:text=>"Set as Default View").click
end

#show=(item) ⇒ Object

Selects the specified item in the Show select list.



47
48
49
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 47

def show=(item)
  frm.select(:id=>"timeFilterOption").select(item)
end

#show_events=(item) ⇒ Object



81
82
83
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 81

def show_events=(item)
  frm.select(:id=>"timeFilterOption").select(item)
end

#start_day=(item) ⇒ Object

Selects the specified value in the start day select list.



91
92
93
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 91

def start_day=(item)
  frm.select(:id=>"customStartDay").select(item)
end

#start_month=(item) ⇒ Object

Selects the specified value in the start month select list.



86
87
88
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 86

def start_month=(item)
  frm.select(:id=>"customStartMonth").select(item)
end

#start_year=(item) ⇒ Object

Selects the specified value in the start year select list.



96
97
98
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 96

def start_year=(item)
  frm.select(:id=>"customStartYear").select(item)
end

#todayObject

Clicks the “Today” button and reinstantiates the class.



181
182
183
184
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 181

def today
  frm.button(:value=>"Today").click
  Calendar.new(@browser)
end

#view=(item) ⇒ Object

Selects the specified item in the View select list. This is the same method as the select_view method, except that it does not reinstantiate the class. Use this if you’re not concerned about throwing obsolete element errors when the page updates.



42
43
44
# File 'lib/kuali-sakai-common-lib/calendar.rb', line 42

def view=(item)
  frm.select(:id=>"view").select(item)
end