sakai-cle-test-api 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,45 @@
1
+ # Methods to extend the page-object gem...
2
+ module PageObject
3
+ module Elements
4
+ class Element
5
+ def disabled?
6
+ @element.disabled?
7
+ end
8
+ end
9
+ end
10
+ module Accessors
11
+ def thing element_name
12
+ raise "#{element_name} is being defined twice in #{self}!" if self.instance_methods.include?(element_name.to_sym)
13
+ define_method element_name.to_s do
14
+ yield self
15
+ end
16
+ end
17
+ alias item thing
18
+ alias value thing
19
+ alias action thing
20
+ end
21
+ end
22
+
23
+ # Need this to extend Watir to be able to attach to Sakai's non-standard tags...
24
+ module Watir
25
+ class Element
26
+ # attaches to the "headers" tags inside of the assignments table.
27
+ def headers
28
+ @how = :ole_object
29
+ return @o.headers
30
+ end
31
+
32
+ # attaches to the "for" tags in "label" tags.
33
+ def for
34
+ @how = :ole_object
35
+ return @o.for
36
+ end
37
+
38
+ # attaches to the "summary" tag
39
+ def summary
40
+ @how = :ole_object
41
+ return @o.summary
42
+ end
43
+
44
+ end
45
+ end
@@ -6,5 +6,23 @@
6
6
  class Gradebook
7
7
  include PageObject
8
8
  include ToolsMenu
9
- include GradebookMethods
9
+ def items_titles
10
+ titles = []
11
+ items_table = frm.table(:class=>"listHier lines nolines")
12
+ 1.upto(items_table.rows.size-1) do |x|
13
+ titles << items_table.row(:index=>x).a(:index=>0).text
14
+ end
15
+ return titles
16
+ end
17
+
18
+ # Returns the value of the "Released to Students" column
19
+ # for the specified assignment title.
20
+ def released_to_students(assignment)
21
+ frm.table(:class=>"listHier lines nolines").row(:text=>/#{Regexp.escape(assignment)}/)[4].text
22
+ end
23
+
24
+ # Returns the due date value for the specified assignment.
25
+ def due_date(assignment)
26
+ frm.table(:class=>"listHier lines nolines").row(:text=>/#{Regexp.escape(assignment)}/)[3].text
27
+ end
10
28
  end
@@ -2,5 +2,19 @@
2
2
  class Gradebook2
3
3
  include PageObject
4
4
  include ToolsMenu
5
- include Gradebook2Methods
5
+ # Returns an array of names of Gradebook items
6
+ def gradebook_items
7
+ items = []
8
+ frm.div(:class=>"x-grid3-scroller").spans.each do |span|
9
+ if span.class_name =~ /^x-tree3-node-text/
10
+ items << span.text
11
+ end
12
+ end
13
+ return items
14
+ end
15
+
16
+ in_frame(:class=>"portletMainIframe") do |frame|
17
+
18
+
19
+ end
6
20
  end
@@ -0,0 +1,440 @@
1
+
2
+ #================
3
+ # Lesson Pages
4
+ #================
5
+
6
+ # Contains items common to most Lessons pages.
7
+ module LessonsMenu
8
+
9
+ # Clicks on the Preferences link on the Lessons page,
10
+ # then instantiates the LessonPreferences class.
11
+ def preferences
12
+ frm.link(:text=>"Preferences").click
13
+ LessonPreferences.new(@browser)
14
+ end
15
+
16
+ def view
17
+ frm.link(:text=>"View").click
18
+ if frm.div(:class=>"meletePortletToolBarMessage").text=="Viewing student side..."
19
+ ViewModuleList.new(@browser)
20
+ else
21
+ #FIXME
22
+ end
23
+ end
24
+
25
+ def manage
26
+ frm.link(:text=>"Manage").click
27
+ LessonManage.new(@browser)
28
+ end
29
+
30
+ def author
31
+ #FIXME
32
+ end
33
+
34
+ end
35
+
36
+ # The Lessons page in a site ("icon-sakai-melete")
37
+ #
38
+ # Note that this class is inclusive of both the
39
+ # Instructor/Admin and the Student views of this page
40
+ # many methods will error out if used when in the
41
+ # Student view.
42
+ class Lessons
43
+
44
+ include PageObject
45
+ include ToolsMenu
46
+ include LessonsMenu
47
+
48
+ # Clicks the Add Module link, then
49
+ # instantiates the AddModule class.
50
+ #
51
+ # Assumes the Add Module link is present
52
+ # and will error out if it is not.
53
+ def add_module
54
+ frm.link(:text=>"Add Module").click
55
+ AddEditModule.new(@browser)
56
+ end
57
+
58
+ # Clicks on the link that matches the supplied
59
+ # name value, then instantiates the
60
+ # AddEditLesson, or ViewLesson class, depending
61
+ # on which page loads.
62
+ #
63
+ # Will error out if there is no
64
+ # matching link in the list.
65
+ def open_lesson(name)
66
+ frm.link(:text=>name).click
67
+ if frm.div(:class=>"meletePortletToolBarMessage").exist? && frm.div(:class=>"meletePortletToolBarMessage").text=="Editing module..."
68
+ AddEditModule.new(@browser)
69
+ else
70
+ ViewModule.new(@browser)
71
+ end
72
+ end
73
+
74
+ # Returns an array of the Module titles displayed on the page.
75
+ def lessons_list
76
+ list = []
77
+ frm.table(:id=>/lis.+module.+form:table/).links.each do |link|
78
+ if link.id=~/lis.+module.+form:table:.+:(edit|view)Mod/
79
+ list << link.text
80
+ end
81
+ end
82
+ return list
83
+ end
84
+
85
+ # Returns and array containing the list of section titles for the
86
+ # specified module.
87
+ def sections_list(module_name)
88
+ list = []
89
+ if frm.table(:id=>/lis.+module.+form:table/).row(:text=>/#{Regexp.escape(module_name)}/).table(:id=>/tablesec/).exist?
90
+ frm.table(:id=>/lis.+module.+form:table/).row(:text=>/#{Regexp.escape(module_name)}/).table(:id=>/tablesec/).links.each do |link|
91
+ if link.id=~/Sec/
92
+ list << link.text
93
+ end
94
+ end
95
+ end
96
+ return list
97
+ end
98
+
99
+ end
100
+
101
+ # The student user's view of a Lesson Module or Section.
102
+ class ViewModule
103
+
104
+ include PageObject
105
+ include ToolsMenu
106
+
107
+ def sections_list
108
+ list = []
109
+ frm.table(:id=>"viewmoduleStudentform:tablesec").links.each { |link| list << link.text }
110
+ return list
111
+ end
112
+
113
+ def next
114
+ frm.link(:text=>"Next").click
115
+ ViewModule.new(@browser)
116
+ end
117
+
118
+ # Returns the text of the Module title row
119
+ def module_title
120
+ frm.span(:id=>/modtitle/).text
121
+ end
122
+
123
+ # Returns the text of the Section title row
124
+ def section_title
125
+ frm.span(:id=>/form:title/).text
126
+ end
127
+
128
+ def content_include?(content)
129
+ frm.form(:id=>"viewsectionStudentform").text.include?(content)
130
+ end
131
+
132
+ end
133
+
134
+ # This is the Instructor's preview of the Student's view
135
+ # of the list of Lesson Modules.
136
+ class ViewModuleList
137
+
138
+ include PageObject
139
+ include ToolsMenu
140
+
141
+ def open_lesson(name)
142
+ frm.link(:text=>name).click
143
+ LessonStudentSide.new(@browser)
144
+ end
145
+
146
+ def open_section(name)
147
+ frm.link(:text=>name).click
148
+ SectionStudentSide.new(@browser)
149
+ end
150
+
151
+ end
152
+
153
+ # The instructor's preview of the student view of the lesson.
154
+ class LessonStudentSide
155
+
156
+ include PageObject
157
+ include ToolsMenu
158
+ include LessonsMenu
159
+
160
+ end
161
+
162
+ # The instructor's preview of the student's view of the section.
163
+ class SectionStudentSide
164
+
165
+ include PageObject
166
+ include ToolsMenu
167
+ include LessonsMenu
168
+
169
+ end
170
+
171
+ # The Managing Options page for Lessons
172
+ class LessonManage
173
+
174
+ include PageObject
175
+ include ToolsMenu
176
+ include LessonsMenu
177
+
178
+ def manage_content
179
+ frm.link(:text=>"Manage Content").click
180
+ LessonManageContent.new(@browser)
181
+ end
182
+
183
+ def sort
184
+ frm.link(:text=>"Sort").click
185
+ LessonManageSort.new(@browser)
186
+ end
187
+
188
+ # Clicks the Import/Export button and
189
+ # instantiates the LessonImportExport class.
190
+ def import_export
191
+ frm.link(:text=>"Import/Export").click
192
+ LessonImportExport.new(@browser)
193
+ end
194
+
195
+ end
196
+
197
+ # The Sorting Modules and Sections page in Lessons
198
+ class LessonManageSort
199
+
200
+ include PageObject
201
+ include ToolsMenu
202
+
203
+ def view
204
+ frm.link(:text=>"View").click
205
+ if frm.div(:class=>"meletePortletToolBarMessage").text=="Viewing student side..."
206
+ ViewModuleList.new(@browser)
207
+ else
208
+ #FIXME
209
+ end
210
+ end
211
+
212
+ in_frame(:index=>1) do |frame|
213
+ link(:sort_modules, :id=>"SortSectionForm:sortmod", :frame=>frame)
214
+ link(:sort_sections, :id=>"SortModuleForm:sortsec", :frame=>frame)
215
+
216
+ end
217
+ end
218
+
219
+ # The Import/Export page in Manage Lessons for a Site
220
+ class LessonImportExport
221
+
222
+ include PageObject
223
+ include ToolsMenu
224
+ include LessonsMenu
225
+
226
+ # Uploads the file specified - meaning that it enters
227
+ # the target file information, then clicks the import
228
+ # button.
229
+ #
230
+ # The file path is an optional parameter.
231
+ def upload_IMS(file_name, file_path="")
232
+ frm.file_field(:name, "impfile").set(file_path + file_name)
233
+ frm.link(:id=>"importexportform:importModule").click
234
+ frm.table(:id=>"AutoNumber1").div(:text=>"Processing...").wait_while_present
235
+ end
236
+
237
+ # Returns the text of the alert box.
238
+ def alert_text
239
+ frm.span(:class=>"BlueClass").text
240
+ end
241
+
242
+ end
243
+
244
+ # The User preference options page for Lessons.
245
+ #
246
+ # Note that this class is inclusive of Student
247
+ # and Instructor views of the page. Thus,
248
+ # not all methods in the class will work
249
+ # at all times.
250
+ class LessonPreferences
251
+
252
+ include PageObject
253
+ include ToolsMenu
254
+
255
+ # Clicks the View button
256
+ # then instantiates the Lessons class.
257
+ def view
258
+ frm.link(:text=>"View").click
259
+ Lessons.new(@browser)
260
+ end
261
+
262
+ in_frame(:index=>1) do |frame|
263
+ radio_button(:expanded) { |page| page.radio_button_element(:name=>"UserPreferenceForm:_id5", :index=>0, :frame=>frame) }
264
+ radio_button(:collapsed) { |page| page.radio_button_element(:name=>"UserPreferenceForm:_id5", :index=>1, :frame=>frame) }
265
+ link(:set, :id=>"UserPreferenceForm:SetButton", :frame=>frame)
266
+ end
267
+ end
268
+
269
+ # This Class encompasses methods for both the Add and the Edit pages for Lesson Modules.
270
+ class AddEditModule
271
+
272
+ include PageObject
273
+ include ToolsMenu
274
+
275
+ # Clicks the Add button for the Lesson Module
276
+ # then instantiates the ConfirmModule class.
277
+ def add
278
+ frm.link(:id=>/ModuleForm:submitsave/).click
279
+ ConfirmModule.new(@browser)
280
+ end
281
+
282
+ def add_content_sections
283
+ frm.link(:id=>/ModuleForm:sectionButton/).click
284
+ AddEditContentSection.new(@browser)
285
+ end
286
+
287
+ in_frame(:index=>1) do |frame|
288
+ text_field(:title, :id=>/ModuleForm:title/, :frame=>frame)
289
+ text_area(:description, :id=>/ModuleForm:description/, :frame=>frame)
290
+ text_area(:keywords, :id=>/ModuleForm:keywords/, :frame=>frame)
291
+ text_field(:start_date, :id=>/ModuleForm:startDate/, :frame=>frame)
292
+ text_field(:end_date, :id=>/ModuleForm:endDate/, :frame=>frame)
293
+ end
294
+ end
295
+
296
+ # The confirmation page when you are saving a Lesson Module.
297
+ class ConfirmModule
298
+
299
+ include PageObject
300
+ include ToolsMenu
301
+
302
+ # Clicks the Add Content Sections button and
303
+ # instantiates the AddEditSection class.
304
+ def add_content_sections
305
+ frm.link(:id=>/ModuleConfirmForm:sectionButton/).click
306
+ AddEditSection.new(@browser)
307
+ end
308
+
309
+ # Clicks the Return to Modules button, then
310
+ # instantiates the AddEditModule class.
311
+ def return_to_modules
312
+ frm.link(:id=>/ModuleConfirmForm:returnButton/).click
313
+ AddEditModule.new(@browser)
314
+ end
315
+
316
+ end
317
+
318
+ # Page for adding a section to a Lesson.
319
+ class AddEditContentSection
320
+
321
+ include PageObject
322
+ include ToolsMenu
323
+ include FCKEditor
324
+
325
+ # Clicks the Add button on the page
326
+ # then instantiates the ConfirmSectionAdd class.
327
+ def add
328
+ frm.link(:id=>/SectionForm:submitsave/).click
329
+ ConfirmSectionAdd.new(@browser)
330
+ end
331
+
332
+ # Pointer to the Edit Text box of the FCKEditor
333
+ # on the page.
334
+ def content_editor
335
+ frm.frame(:id, "AddSectionForm:fckEditorView:otherMeletecontentEditor_inputRichText___Frame")
336
+ end
337
+
338
+ def add_content=(text)
339
+ content_editor.td(:id, "xEditingArea").frame(:index=>0).send_keys(text)
340
+ end
341
+
342
+ def source=(text)
343
+ content_editor.td(:id, "xEditingArea").text_field(:class=>"SourceField").set text
344
+ end
345
+
346
+ def clear_content
347
+ frm.frame(:id, "AddSectionForm:fckEditorView:otherMeletecontentEditor_inputRichText___Frame").div(:title=>"Select All").fire_event("onclick")
348
+ content_editor.send_keys :backspace
349
+ end
350
+
351
+ def select_url
352
+ frm.link(:id=>"AddSectionForm:ContentLinkView:serverViewButton").click
353
+ SelectingContent.new(@browser)
354
+ end
355
+
356
+ # This method clicks the Select button that appears on the page
357
+ # then calls the LessonAddAttachment class.
358
+ #
359
+ # It assumes that the Content Type selection box has
360
+ # already been updated to "Upload or link to a file in Resources".
361
+ def select_or_upload_file
362
+ frm.link(:id=>"AddSectionForm:ResourceHelperLinkView:serverViewButton").click
363
+ LessonAddAttachment.new(@browser)
364
+ end
365
+
366
+ # Clicks the select button for "Upload or link to a file"
367
+ # NOT for "Upload or link to a file in Resources"!
368
+ def select_a_file
369
+ frm.link(:id=>"AddSectionForm:ContentUploadView:serverViewButton").click
370
+ end
371
+
372
+ in_frame(:index=>1) do |frame|
373
+ text_field(:title, :id=>"AddSectionForm:title", :frame=>frame)
374
+ text_field(:instructions, :id=>"AddSectionForm:instr", :frame=>frame)
375
+ select_list(:content_type, :id=>"AddSectionForm:contentType", :frame=>frame)
376
+ select_list(:copyright_status, :id=>/SectionForm:ResourcePropertiesPanel:licenseCodes/, :frame=>frame)
377
+ checkbox(:auditory, :id=>"AddSectionForm:contentaudio", :frame=>frame)
378
+ checkbox(:textual, :id=>"AddSectionForm:contentext", :frame=>frame)
379
+ checkbox(:visual, :id=>"AddSectionForm:contentaudio", :frame=>frame)
380
+ text_field(:url_title, :id=>"AddSectionForm:ResourcePropertiesPanel:res_name", :frame=>frame)
381
+ text_field(:url_description, :id=>"AddSectionForm:ResourcePropertiesPanel:res_desc", :frame=>frame)
382
+ text_field(:file_description, :id=>"AddSectionForm:ResourcePropertiesPanel:res_desc", :frame=>frame)
383
+ end
384
+ end
385
+
386
+ # Confirmation page for Adding (or Editing)
387
+ # a Section to a Module in Lessons.
388
+ class ConfirmSectionAdd
389
+
390
+ include PageObject
391
+ include ToolsMenu
392
+
393
+ # Clicks the Add Another Section button
394
+ # then instantiates the AddSection class.
395
+ def add_another_section
396
+ frm.link(:id=>/SectionConfirmForm:saveAddAnotherbutton/).click
397
+ AddEditContentSection.new(@browser)
398
+ end
399
+
400
+ # Clicks the Finish button
401
+ # then instantiates the Lessons class.
402
+ def finish
403
+ frm.link(:id=>/Form:FinishButton/).click
404
+ Lessons.new(@browser)
405
+ end
406
+
407
+ end
408
+
409
+ #
410
+ class SelectingContent
411
+
412
+ include PageObject
413
+ include ToolsMenu
414
+
415
+ def continue
416
+ frm.link(:id=>"ServerViewForm:addButton").click
417
+ AddEditContentSection.new(@browser)
418
+ end
419
+
420
+ in_frame(:index=>1) do |frame|
421
+ text_field(:new_url, :id=>"ServerViewForm:link", :frame=>frame)
422
+ text_field(:url_title, :id=>"ServerViewForm:link_title", :frame=>frame)
423
+ end
424
+ end
425
+
426
+ #
427
+ class LessonAddAttachment
428
+
429
+ include ToolsMenu
430
+ include PageObject
431
+
432
+ def continue
433
+ frm.link(:id=>"UploadServerViewForm:addButton").click
434
+ end
435
+
436
+ def upload_local_file(filename, filepath="")
437
+ frm.file_field(:id=>"file1").set(filepath + filename)
438
+ end
439
+
440
+ end