sakai-cle-test-api 0.0.7 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/lib/sakai-cle-test-api.rb +7 -2
  2. data/lib/sakai-cle-test-api/add_files.rb +198 -0
  3. data/lib/sakai-cle-test-api/admin_page_elements.rb +7 -3
  4. data/lib/sakai-cle-test-api/announcements.rb +274 -7
  5. data/lib/sakai-cle-test-api/assessments.rb +930 -27
  6. data/lib/sakai-cle-test-api/assignments.rb +769 -13
  7. data/lib/sakai-cle-test-api/basic_lti.rb +5 -1
  8. data/lib/sakai-cle-test-api/blogs.rb +54 -2
  9. data/lib/sakai-cle-test-api/calendar.rb +423 -8
  10. data/lib/sakai-cle-test-api/chat_room.rb +0 -0
  11. data/lib/sakai-cle-test-api/common_page_elements.rb +69 -172
  12. data/lib/sakai-cle-test-api/core-ext.rb +90 -0
  13. data/lib/sakai-cle-test-api/data_objects/announcement.rb +38 -0
  14. data/lib/sakai-cle-test-api/data_objects/assessment.rb +32 -0
  15. data/lib/sakai-cle-test-api/data_objects/assignment.rb +62 -0
  16. data/lib/sakai-cle-test-api/data_objects/event.rb +86 -0
  17. data/lib/sakai-cle-test-api/data_objects/lesson.rb +137 -0
  18. data/lib/sakai-cle-test-api/data_objects/resource.rb +174 -0
  19. data/lib/sakai-cle-test-api/data_objects/site.rb +213 -0
  20. data/lib/sakai-cle-test-api/data_objects/syllabus.rb +7 -0
  21. data/lib/sakai-cle-test-api/data_objects/topic.rb +0 -0
  22. data/lib/sakai-cle-test-api/data_objects/web_content_tool.rb +52 -0
  23. data/lib/sakai-cle-test-api/data_objects/wiki.rb +7 -0
  24. data/lib/sakai-cle-test-api/drop_box.rb +21 -0
  25. data/lib/sakai-cle-test-api/email_archive.rb +15 -1
  26. data/lib/sakai-cle-test-api/forums.rb +282 -8
  27. data/lib/sakai-cle-test-api/gem_ext.rb +45 -0
  28. data/lib/sakai-cle-test-api/gradebook.rb +19 -1
  29. data/lib/sakai-cle-test-api/gradebook2.rb +15 -1
  30. data/lib/sakai-cle-test-api/lessons.rb +440 -0
  31. data/lib/sakai-cle-test-api/messages.rb +551 -15
  32. data/lib/sakai-cle-test-api/news.rb +3 -1
  33. data/lib/sakai-cle-test-api/polls.rb +65 -3
  34. data/lib/sakai-cle-test-api/profile.rb +36 -2
  35. data/lib/sakai-cle-test-api/profile2.rb +315 -6
  36. data/lib/sakai-cle-test-api/resources.rb +138 -0
  37. data/lib/sakai-cle-test-api/rich_text.rb +13 -0
  38. data/lib/sakai-cle-test-api/sections.rb +198 -8
  39. data/lib/sakai-cle-test-api/site_page_elements.rb +4 -441
  40. data/lib/sakai-cle-test-api/syllabus.rb +149 -7
  41. data/lib/sakai-cle-test-api/tools_menu.rb +3 -20
  42. data/lib/sakai-cle-test-api/utilities.rb +260 -0
  43. data/sakai-cle-test-api.gemspec +2 -3
  44. metadata +21 -19
@@ -1,5 +1,9 @@
1
1
  #
2
2
  class BasicLTI
3
3
  include ToolsMenu
4
- include BasicLTIMethods
4
+ include PageObject
5
+ in_frame(:class=>"portletMainIframe") do |frame|
6
+
7
+
8
+ end
5
9
  end
@@ -1,5 +1,57 @@
1
- #
1
+ module BlogsMenuButtons
2
+ include PageObject
3
+
4
+ def add_blog_entry
5
+ frm.link(:text=>"Add blog entry").click
6
+ AddBlogEntry.new @browser
7
+ end
8
+
9
+ end
10
+
2
11
  class Blogs
3
12
  include ToolsMenu
4
- include BlogsMethods
13
+ include BlogsMenuButtons
14
+ # Returns an array containing the list of Bloggers
15
+ # in the "All the blogs" table.
16
+ def blogger_list
17
+ bloggers = []
18
+ frm.table(:class=>"listHier lines").rows.each do |row|
19
+ bloggers << row[1].text
20
+ end
21
+ bloggers.delete_at(0)
22
+ return bloggers
23
+ end
24
+ end
25
+
26
+ class AddBlogEntry
27
+ include ToolsMenu
28
+ include BlogsMenuButtons
29
+ include PageObject
30
+ def blog_text=(text)
31
+ frm.frame(:id, "blog-text-input:1:input___Frame").td(:id, "xEditingArea").frame(:index=>0).wait_until_present
32
+ frm.frame(:id, "blog-text-input:1:input___Frame").td(:id, "xEditingArea").frame(:index=>0).send_keys(text)
33
+ end
34
+
35
+ def publish_entry
36
+ frm.button(:value=>"Publish entry").click
37
+ BlogsList.new @browser
38
+ end
39
+
40
+ def save_draft
41
+ frm.button(:value=>"Save Draft").click
42
+ BlogsList.new @browser
43
+ end
44
+
45
+ in_frame(:class=>"PortletMainIframe") do |frame|
46
+ text_field(:title, :name=>"title-input", :frame=>frame)
47
+ radio_button(:only_site_admins, :id=>"instructors-only-radio", :frame=>frame)
48
+ radio_button(:all_members, :id=>"all-members-radio", :frame=>frame)
49
+ radio_button(:publicly_viewable, :id=>"public-viewable-radio", :frame=>frame)
50
+ end
51
+ end
52
+
53
+ class BlogsList
54
+ include ToolsMenu
55
+
56
+ include BlogsMenuButtons
5
57
  end
@@ -1,3 +1,26 @@
1
+ module CalendarTools
2
+
3
+ #
4
+ def add_event
5
+ frm.link(:text=>"Add").click
6
+ frm.frame(:id, "description___Frame").td(:id, "xEditingArea").frame(:index=>0).wait_until_present
7
+ AddEditEvent.new(@browser)
8
+ end
9
+
10
+ #
11
+ def fields
12
+ frm.link(:text=>"Fields").click
13
+ AddEditFields.new(@browser)
14
+ end
15
+
16
+ #
17
+ def import
18
+ frm.link(:text=>"Import").click
19
+ ImportStepOne.new(@browser)
20
+ end
21
+
22
+ end
23
+
1
24
  # Top page of the Calendar
2
25
  # For now it includes all views, though that probably
3
26
  # means it will have to be re-instantiated every time
@@ -5,47 +28,439 @@
5
28
  class Calendar
6
29
  include ToolsMenu
7
30
  include CalendarTools
8
- include CalendarMethods
31
+ # Selects the specified item in the View select list,
32
+ # then reinstantiates the Class.
33
+ def select_view(item)
34
+ frm.select(:id=>"view").select(item)
35
+ Calendar.new(@browser)
36
+ end
37
+
38
+ # Selects the specified item in the View select list.
39
+ # This is the same method as the select_view method, except
40
+ # that it does not reinstantiate the class. Use this if you're
41
+ # not concerned about throwing obsolete element errors when
42
+ # the page updates.
43
+ def view=(item)
44
+ frm.select(:id=>"view").select(item)
45
+ end
46
+
47
+ # Selects the specified item in the Show select list.
48
+ def show=(item)
49
+ frm.select(:id=>"timeFilterOption").select(item)
50
+ end
51
+
52
+ # Returns the text of the Calendar's header.
53
+ def header
54
+ frm.div(:class=>"portletBody").h3.text
55
+ end
56
+
57
+ # This is the alert box object. If you want to
58
+ # get the text contents of the alert box, use
59
+ # alert_box.text. That will get you a string object
60
+ # that is the text contents.
61
+ def alert_box
62
+ frm.div(:class=>"alertMessage")
63
+ end
64
+
65
+ # Clicks the link to the specified event, then
66
+ # instantiates the EventDetail class.
67
+ def open_event(title)
68
+ truncated = title[0..5]
69
+ frm.link(:text=>/#{Regexp.escape(truncated)}/).click
70
+ EventDetail.new(@browser)
71
+ end
72
+
73
+ # Returns the href value of the target link
74
+ # use for validation when you are testing whether the link
75
+ # will appear again on another screen, since often times
76
+ # validation by title text alone will not work.
77
+ def event_href(title)
78
+ truncated = title[0..5]
79
+ return frm.link(:text=>/#{Regexp.escape(truncated)}/).href
80
+ end
81
+
82
+ def show_events=(item)
83
+ frm.select(:id=>"timeFilterOption").select(item)
84
+ end
85
+
86
+ # Selects the specified value in the start month select list.
87
+ def start_month=(item)
88
+ frm.select(:id=>"customStartMonth").select(item)
89
+ end
90
+
91
+ # Selects the specified value in the start day select list.
92
+ def start_day=(item)
93
+ frm.select(:id=>"customStartDay").select(item)
94
+ end
95
+
96
+ # Selects the specified value in the start year select list.
97
+ def start_year=(item)
98
+ frm.select(:id=>"customStartYear").select(item)
99
+ end
100
+
101
+ # Selects the specified value in the end month select list.
102
+ def end_month=(item)
103
+ frm.select(:id=>"customEndMonth").select(item)
104
+ end
105
+
106
+ # Selects the specified value in the End Day select list.
107
+ def end_day=(item)
108
+ frm.select(:id=>"customEndDay").select(item)
109
+ end
110
+
111
+ # Selects the specified value in the End Year select list.
112
+ def end_year=(item)
113
+ frm.select(:id=>"customEndYear").select(item)
114
+ end
115
+
116
+ # Clicks the Filter Events button, then re-instantiates
117
+ # the Calendar class to avoid the possibility of an
118
+ # ObsoleteElement error.
119
+ def filter_events
120
+ frm.button(:name=>"eventSubmit_doCustomdate").click
121
+ Calendar.new(@browser)
122
+ end
123
+
124
+ # Clicks the Go to Today button, then reinstantiates
125
+ # the Calendar class.
126
+ def go_to_today
127
+ frm.button(:value=>"Go to Today").click
128
+ Calendar.new(@browser)
129
+ end
130
+
131
+ # Returns an array of the titles of the displayed events.
132
+ def event_list
133
+ events_list
134
+ end
135
+
136
+ # Returns an array for the listed events.
137
+ # This array contains more than simply strings of the event titles, because
138
+ # often the titles are truncated to fit on the screen. In addition, getting the "title"
139
+ # tag of the link is often problematic because titles can contain double-quotes, which
140
+ # will mess up the HTML of the anchor tag (there is probably an XSS vulnerability to
141
+ # exploit, there. This should be extensively tested.).
142
+ #
143
+ # Because of these issues, the array contains the title tag, the anchor text, and
144
+ # the entire href string for every event listed on the page. Having all three items
145
+ # available should ensure that verification steps don't give false results--especially
146
+ # when you are doing a negative test (checking that an event is NOT present).
147
+ def events_list
148
+ list = []
149
+ if frm.table(:class=>"calendar").exist?
150
+ events_table = frm.table(:class=>"calendar")
151
+ else
152
+ events_table = frm.table(:class=>"listHier lines nolines")
153
+ end
154
+ events_table.links.each do |link|
155
+ list << link.title
156
+ list << link.text
157
+ list << link.href
158
+ list << link.html[/(?<="location=").+doDescription/]
159
+ end
160
+ list.compact!
161
+ list.uniq!
162
+ return list
163
+ end
164
+
165
+ # Clicks the "Previous X" button, where X might be Day, Week, or Month,
166
+ # then reinstantiates the Calendar class to ensure against any obsolete element
167
+ # errors.
168
+ def previous
169
+ frm.button(:name=>"eventSubmit_doPrev").click
170
+ Calendar.new(@browser)
171
+ end
172
+
173
+ # Clicks the "Next X" button, where X might be Day, Week, or Month,
174
+ # then reinstantiates the Calendar class to ensure against any obsolete element
175
+ # errors.
176
+ def next
177
+ frm.button(:name=>"eventSubmit_doNext").click
178
+ Calendar.new(@browser)
179
+ end
180
+
181
+ # Clicks the "Today" button and reinstantiates the class.
182
+ def today
183
+ frm.button(:value=>"Today").click
184
+ Calendar.new(@browser)
185
+ end
186
+
187
+ def earlier
188
+ frm().link(:text=>"Earlier").click
189
+ Calendar.new(@browser)
190
+ end
191
+
192
+ def later
193
+ frm().link(:text=>"Later").click
194
+ Calendar.new(@browser)
195
+ end
196
+
197
+ # Clicks the "Set as Default View" button
198
+ def set_as_default_view
199
+ frm.link(:text=>"Set as Default View").click
200
+ end
9
201
  end
10
202
 
11
203
  # The page that appears when you click on an event in the Calendar
12
204
  class EventDetail
13
205
  include ToolsMenu
14
206
  include CalendarTools
15
- include EventDetailMethods
207
+ # Clicks the Go to Today button, then instantiates
208
+ # the Calendar class.
209
+ def go_to_today
210
+ frm.button(:value=>"Go to Today").click
211
+ Calendar.new(@browser)
212
+ end
213
+
214
+ def back_to_calendar
215
+ frm.button(:value=>"Back to Calendar").click
216
+ Calendar.new(@browser)
217
+ end
218
+
219
+ def last_event
220
+ frm().button(:value=>"< Last Event").click
221
+ EventDetail.new(@browser)
222
+ end
223
+
224
+ def next_event
225
+ frm().button(:value=>"Next Event >").click
226
+ EventDetail.new(@browser)
227
+ end
228
+
229
+ def event_title
230
+ frm.div(:class=>"portletBody").h3.text
231
+ end
232
+
233
+ def edit
234
+ frm.button(:value=>"Edit").click
235
+ AddEditEvent.new(@browser)
236
+ end
237
+
238
+ def remove_event
239
+ frm.button(:value=>"Remove event").click
240
+ DeleteConfirm.new(@browser)
241
+ end
242
+
243
+ # Returns a hash object containing the contents of the event details
244
+ # table on the page, with each of the header column items as a Key
245
+ # and the associated data column as the corresponding Value.
246
+ def details
247
+ details = {}
248
+ frm.table(:class=>"itemSummary").rows.each do |row|
249
+ details.store(row.th.text, row.td.text)
250
+ end
251
+ return details
252
+ end
253
+
16
254
  end
17
255
 
18
256
  #
19
257
  class AddEditEvent
20
258
  include ToolsMenu
21
- include AddEditEventMethods
259
+ include PageObject
260
+ #
261
+ def save_event
262
+ frm.button(:value=>"Save Event").click
263
+ Calendar.new(@browser)
264
+ end
265
+ #
266
+ def message=(text)
267
+ frm.frame(:id, "description___Frame").td(:id, "xEditingArea").frame(:index=>0).send_keys(text)
268
+ end
269
+
270
+ # The FCKEditor object. Use this method to set up a "wait_until_present"
271
+ # step, since sometimes it takes a long time for this object to load.
272
+ def message_editor
273
+ frm.frame(:id, "description___Frame").td(:id, "xEditingArea").frame(:index=>0)
274
+ end
275
+
276
+ def frequency
277
+ frm.button(:name=>"eventSubmit_doEditfrequency").click
278
+ EventFrequency.new(@browser)
279
+ end
280
+
281
+ def add_attachments
282
+ frm.button(:value=>"Add Attachments").click
283
+ EventAttach.new(@browser)
284
+ end
285
+
286
+ def add_remove_attachments
287
+ frm.button(:value=>"Add/remove attachments").click
288
+ EventAttach.new(@browser)
289
+ end
290
+
291
+ # Returns true if the page has a link with the
292
+ # specified file name. Use for test case asserts.
293
+ def attachment?(file_name)
294
+ frm.link(:text=>file_name).exist?
295
+ end
296
+
297
+ # Use this method to enter text into custom fields
298
+ # on the page. The "field" variable is the name of the
299
+ # field, while the "text" is the string you want to put into
300
+ # it.
301
+ def custom_field_text(field, text)
302
+ frm.text_field(:name=>field).set(text)
303
+ end
304
+
305
+ in_frame(:class=>"portletMainIframe") do |frame|
306
+ text_field(:title, :id=>"activitytitle", :frame=>frame)
307
+ select_list(:month, :id=>"month", :frame=>frame)
308
+ select_list(:day, :id=>"day", :frame=>frame)
309
+ select_list(:year, :id=>"yearSelect", :frame=>frame)
310
+ select_list(:start_hour, :id=>"startHour", :frame=>frame)
311
+ select_list(:start_minute, :id=>"startMinute", :frame=>frame)
312
+ select_list(:start_meridian, :id=>"startAmpm", :frame=>frame)
313
+ select_list(:hours, :id=>"duHour", :frame=>frame)
314
+ select_list(:minutes, :id=>"duMinute", :frame=>frame)
315
+ select_list(:end_hour, :id=>"endHour", :frame=>frame)
316
+ select_list(:end_minute, :id=>"endMinute", :frame=>frame)
317
+ select_list(:end_meridian, :id=>"endAmpm", :frame=>frame)
318
+ radio_button(:display_to_site, :id=>"site", :frame=>frame)
319
+ select_list(:event_type, :id=>"eventType", :frame=>frame)
320
+ text_area(:location, :name=>"location", :frame=>frame)
321
+
322
+ end
22
323
  end
23
324
 
24
325
  # The page that appears when the Frequency button is clicked on the Add/Edit
25
326
  # Event page.
26
327
  class EventFrequency
27
328
  include ToolsMenu
28
- include EventFrequencyMethods
329
+ include PageObject
330
+ def save_frequency
331
+ frm.button(:value=>"Save Frequency").click
332
+ AddEditEvent.new(@browser)
333
+ end
334
+
335
+ def cancel
336
+ frm.button(:value=>"Cancel").click
337
+ AddEditEvent.new(@browser)
338
+ end
339
+
340
+ in_frame(:class=>"portletMainIframe") do |frame|
341
+ select_list(:event_frequency, :id=>"frequencySelect", :frame=>frame)
342
+ select_list(:interval, :id=>"interval", :frame=>frame)
343
+ select_list(:ends_after, :name=>"count", :frame=>frame)
344
+ select_list(:ends_month, :id=>"endMonth", :frame=>frame)
345
+ select_list(:ends_day, :id=>"endDay", :frame=>frame)
346
+ select_list(:ends_year, :id=>"endYear", :frame=>frame)
347
+ radio_button(:after, :id=>"count", :frame=>frame)
348
+ radio_button(:on, :id=>"till", :frame=>frame)
349
+ radio_button(:never, :id=>"never", :frame=>frame)
350
+
351
+ end
29
352
  end
30
353
 
31
354
  class AddEditFields
32
355
  include ToolsMenu
33
- include AddEditFieldsMethods
356
+ include PageObject
357
+ # Clicks the Save Field Changes buton and instantiates
358
+ # The Calendar or EventDetail class--unless the Alert Message box appears,
359
+ # in which case it re-instantiates the class.
360
+ def save_field_changes
361
+ frm.button(:value=>"Save Field Changes").click
362
+ if frm.div(:class=>"alertMessage").exist?
363
+ AddEditFields.new(@browser)
364
+ elsif frm.button(:value=>"Back to Calendar").exist?
365
+ EventDetail.new(@browser)
366
+ else
367
+ Calendar.new(@browser)
368
+ end
369
+ end
370
+
371
+ # Returns a string of the contents of the Alert box.
372
+ def alert_box
373
+ frm.div(:class=>"alertMessage").text
374
+ end
375
+
376
+ def create_field
377
+ frm.button(:value=>"Create Field").click
378
+ AddEditFields.new(@browser)
379
+ end
380
+
381
+ # Checks the checkbox for the specified field
382
+ def check_remove(field_name)
383
+ frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(field_name)}/).checkbox.set
384
+ end
385
+
386
+ in_frame(:class=>"portletMainIframe") do |frame|
387
+ text_field(:field_name, :id=>"textfield", :frame=>frame)
388
+
389
+ end
34
390
  end
35
391
 
36
392
  class ImportStepOne
37
393
  include ToolsMenu
38
- include ImportStepOneMethods
394
+ include PageObject
395
+ def continue
396
+ frm.button(:value=>"Continue").click
397
+ ImportStepTwo.new(@browser)
398
+ end
399
+
400
+ in_frame(:class=>"portletMainIframe") do |frame|
401
+ radio_button(:microsoft_outlook, :id=>"importType_Outlook", :frame=>frame)
402
+ radio_button(:meeting_maker, :id=>"importType_MeetingMaker", :frame=>frame)
403
+ radio_button(:generic_calendar_import, :id=>"importType_Generic", :frame=>frame)
404
+
405
+ end
39
406
  end
40
407
 
41
408
  class ImportStepTwo
42
409
  include ToolsMenu
43
- include ImportStepTwoMethods
410
+ def continue
411
+ frm.button(:value=>"Continue").click
412
+ ImportStepThree.new(@browser)
413
+ end
414
+
415
+ # Enters the specified filename in the file field.
416
+ #
417
+ # Note that the file path is an optional second parameter, if you do not want to
418
+ # include the full path in the filename.
419
+ def import_file(filename, filepath="")
420
+ frm.file_field(:name=>"importFile").set(filepath + filename)
421
+ end
44
422
  end
45
423
 
46
424
  class ImportStepThree
47
425
  include ToolsMenu
48
- include ImportStepThreeMethods
426
+ include PageObject
427
+ def import_events
428
+ frm.button(:value=>"Import Events").click
429
+ Calendar.new(@browser)
430
+ end
431
+
432
+ # Returns an array containing the list of Activity names on the page.
433
+ def events
434
+ list = []
435
+ frm.table(:class=>/listHier lines/).rows.each do |row|
436
+ if row.label(:for=>/eventSelected/).exist?
437
+ list << row.label.text
438
+ end
439
+ end
440
+ names = []
441
+ list.uniq!
442
+ list.each do | item |
443
+ name = item[/(?<=\s).+(?=\s\s\()/]
444
+ names << name
445
+ end
446
+ return names
447
+ end
448
+
449
+ # Returns the date of the specified event
450
+ def event_date(event_name)
451
+ frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(event_name)}/)[0].text
452
+ end
453
+
454
+ # Unchecks the checkbox for the specified event
455
+ def uncheck_event(event_name)
456
+ frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(event_name)}/)
457
+ end
458
+
459
+ in_frame(:class=>"portletMainIframe") do |frame|
460
+ radio_button(:import_events_for_site, :id=>"site", :frame=>frame)
461
+ radio_button(:import_events_for_selected_groups, :id=>"groups", :frame=>frame)
462
+
463
+ end
49
464
  end
50
465
 
51
466
  # TODO: Rethink this!!!