Class: Calendar

Inherits:
CalendarBase show all
Defined in:
lib/sakai-cle-test-api/page_objects/calendar.rb

Overview

Top page of the Calendar For now it includes all views, though that probably means it will have to be re-instantiated every time a new view is selected.

Instance Method Summary collapse

Methods inherited from CalendarBase

menu_elements

Methods inherited from BasePage

basic_page_elements, frame_element

Methods inherited from PageMaker

element, expected_element, expected_title, #initialize, #method_missing, page_url

Constructor Details

This class inherits a constructor from PageMaker

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PageMaker

Instance Method Details

#earlierObject



171
172
173
174
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 171

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.



91
92
93
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 91

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.



86
87
88
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 86

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.



96
97
98
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 96

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.



61
62
63
64
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 61

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.



116
117
118
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 116

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).



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 131

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.



103
104
105
106
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 103

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.



110
111
112
113
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 110

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

#laterObject



176
177
178
179
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 176

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.



160
161
162
163
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 160

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.



51
52
53
54
55
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 51

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.



152
153
154
155
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 152

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.



31
32
33
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 31

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

#set_as_default_viewObject

Clicks the “Set as Default View” button



182
183
184
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 182

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.



45
46
47
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 45

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

#show_events=(item) ⇒ Object



66
67
68
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 66

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.



76
77
78
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 76

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.



71
72
73
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 71

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.



81
82
83
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 81

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

#todayObject

Clicks the “Today” button and reinstantiates the class.



166
167
168
169
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 166

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.



40
41
42
# File 'lib/sakai-cle-test-api/page_objects/calendar.rb', line 40

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