sambal-cle 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/README.md +4 -0
  2. data/lib/sambal-cle/base_page.rb +20 -0
  3. data/lib/sambal-cle/core-ext.rb +90 -0
  4. data/lib/sambal-cle/data_objects/announcement.rb +82 -0
  5. data/lib/sambal-cle/data_objects/assessment.rb +32 -0
  6. data/lib/sambal-cle/data_objects/assignment.rb +205 -0
  7. data/lib/sambal-cle/data_objects/blog.rb +46 -0
  8. data/lib/sambal-cle/data_objects/blogger.rb +49 -0
  9. data/lib/sambal-cle/data_objects/chat_room.rb +54 -0
  10. data/lib/sambal-cle/data_objects/event.rb +89 -0
  11. data/lib/sambal-cle/data_objects/forum.rb +212 -0
  12. data/lib/sambal-cle/data_objects/lesson.rb +185 -0
  13. data/lib/sambal-cle/data_objects/message.rb +57 -0
  14. data/lib/sambal-cle/data_objects/poll.rb +74 -0
  15. data/lib/sambal-cle/data_objects/resource.rb +209 -0
  16. data/lib/sambal-cle/data_objects/site.rb +295 -0
  17. data/lib/sambal-cle/data_objects/syllabus.rb +73 -0
  18. data/lib/sambal-cle/data_objects/web_content_tool.rb +51 -0
  19. data/lib/sambal-cle/data_objects/wiki.rb +63 -0
  20. data/lib/sambal-cle/date_makers.rb +118 -0
  21. data/lib/sambal-cle/gem_ext.rb +23 -0
  22. data/lib/sambal-cle/page_helper.rb +22 -0
  23. data/lib/sambal-cle/page_maker.rb +48 -0
  24. data/lib/sambal-cle/page_objects/account.rb +111 -0
  25. data/lib/sambal-cle/page_objects/aliases.rb +43 -0
  26. data/lib/sambal-cle/page_objects/announcements.rb +190 -0
  27. data/lib/sambal-cle/page_objects/assessments.rb +874 -0
  28. data/lib/sambal-cle/page_objects/assignments.rb +770 -0
  29. data/lib/sambal-cle/page_objects/basic_lti.rb +6 -0
  30. data/lib/sambal-cle/page_objects/blogger.rb +205 -0
  31. data/lib/sambal-cle/page_objects/blogs.rb +60 -0
  32. data/lib/sambal-cle/page_objects/calendar.rb +330 -0
  33. data/lib/sambal-cle/page_objects/calendar_summary.rb +1 -0
  34. data/lib/sambal-cle/page_objects/chat_room.rb +22 -0
  35. data/lib/sambal-cle/page_objects/drop_box.rb +9 -0
  36. data/lib/sambal-cle/page_objects/email_archive.rb +22 -0
  37. data/lib/sambal-cle/page_objects/entity_picker.rb +62 -0
  38. data/lib/sambal-cle/page_objects/evaluations.rb +158 -0
  39. data/lib/sambal-cle/page_objects/feedback.rb +36 -0
  40. data/lib/sambal-cle/page_objects/forms.rb +120 -0
  41. data/lib/sambal-cle/page_objects/forums.rb +254 -0
  42. data/lib/sambal-cle/page_objects/glossary.rb +117 -0
  43. data/lib/sambal-cle/page_objects/gradebook.rb +29 -0
  44. data/lib/sambal-cle/page_objects/gradebook2.rb +17 -0
  45. data/lib/sambal-cle/page_objects/home.rb +36 -0
  46. data/lib/sambal-cle/page_objects/jforums.rb +444 -0
  47. data/lib/sambal-cle/page_objects/job_scheduler.rb +121 -0
  48. data/lib/sambal-cle/page_objects/lessons.rb +361 -0
  49. data/lib/sambal-cle/page_objects/login.rb +28 -0
  50. data/lib/sambal-cle/page_objects/matrix.rb +241 -0
  51. data/lib/sambal-cle/page_objects/media_gallery.rb +13 -0
  52. data/lib/sambal-cle/page_objects/messages.rb +622 -0
  53. data/lib/sambal-cle/page_objects/my_workspace.rb +44 -0
  54. data/lib/sambal-cle/page_objects/news.rb +8 -0
  55. data/lib/sambal-cle/page_objects/podcasts.rb +27 -0
  56. data/lib/sambal-cle/page_objects/polls.rb +69 -0
  57. data/lib/sambal-cle/page_objects/portfolio_templates.rb +161 -0
  58. data/lib/sambal-cle/page_objects/portfolios.rb +162 -0
  59. data/lib/sambal-cle/page_objects/post_em.rb +1 -0
  60. data/lib/sambal-cle/page_objects/profile.rb +51 -0
  61. data/lib/sambal-cle/page_objects/profile2.rb +344 -0
  62. data/lib/sambal-cle/page_objects/public_search.rb +61 -0
  63. data/lib/sambal-cle/page_objects/realms.rb +19 -0
  64. data/lib/sambal-cle/page_objects/resources.rb +326 -0
  65. data/lib/sambal-cle/page_objects/resources_roster.rb +0 -0
  66. data/lib/sambal-cle/page_objects/rosters.rb +70 -0
  67. data/lib/sambal-cle/page_objects/rwiki.rb +34 -0
  68. data/lib/sambal-cle/page_objects/search.rb +34 -0
  69. data/lib/sambal-cle/page_objects/sections.rb +295 -0
  70. data/lib/sambal-cle/page_objects/single_user.rb +1 -0
  71. data/lib/sambal-cle/page_objects/site_setup.rb +621 -0
  72. data/lib/sambal-cle/page_objects/site_statistics.rb +1 -0
  73. data/lib/sambal-cle/page_objects/sites.rb +255 -0
  74. data/lib/sambal-cle/page_objects/styles.rb +74 -0
  75. data/lib/sambal-cle/page_objects/syllabus.rb +166 -0
  76. data/lib/sambal-cle/page_objects/user_membership.rb +57 -0
  77. data/lib/sambal-cle/page_objects/users.rb +88 -0
  78. data/lib/sambal-cle/randomizers.rb +117 -0
  79. data/lib/sambal-cle/rich_text.rb +38 -0
  80. data/lib/sambal-cle/utilities.rb +31 -0
  81. data/lib/sambal-cle/workflows.rb +223 -0
  82. data/lib/sambal-cle.rb +31 -0
  83. data/sambal-cle.gemspec +14 -0
  84. data/test/add_assignment_to_calendar_spec.rb +86 -0
  85. data/test/assignment_announcements_spec.rb +71 -0
  86. data/test/assignment_gradebook_spec.rb +98 -0
  87. data/test/config.yml.template +4 -0
  88. data/test/directory.yml.template +123 -0
  89. data/test/duplicate_site_spec.rb +244 -0
  90. metadata +167 -0
@@ -0,0 +1,117 @@
1
+ #================
2
+ # Glossary Pages - for a Portfolio Site
3
+ #================
4
+
5
+ class Glossary < BasePage
6
+
7
+ frame_element
8
+
9
+ def add
10
+ frm.link(:text=>"Add").click
11
+ frm.frame(:id, "longDescription___Frame").td(:id, "xEditingArea").wait_until_present
12
+ AddEditTerm.new(@browser)
13
+ end
14
+
15
+ def import
16
+ frm.link(:text=>"Import").click
17
+ GlossaryImport.new(@browser)
18
+ end
19
+
20
+ def edit(term)
21
+ frm.table(:class=>"listHier lines nolines").row(:text=>/#{Regexp.escape(term)}/).link(:text=>"Edit").click
22
+ AddEditTerm.new(@browser)
23
+ end
24
+
25
+ def delete(term)
26
+ frm.table(:class=>"listHier lines nolines").row(:text=>/#{Regexp.escape(term)}/).link(:text=>"Delete").click
27
+ AddEditTerm.new(@browser)
28
+ end
29
+
30
+ def open(term)
31
+ frm.link(:text=>term).click
32
+ #FIXME!
33
+ # Need to do special handling here because of the new window.
34
+ end
35
+
36
+ # Returns an array containing the string values of the terms
37
+ # displayed in the list.
38
+ def terms
39
+ term_list = []
40
+ frm.table(:class=>"listHier lines nolines").rows.each do |row|
41
+ term_list << row[0].text
42
+ end
43
+ term_list.delete_at(0)
44
+ return term_list
45
+ end
46
+
47
+ end
48
+
49
+ class AddEditTerm < BasePage
50
+
51
+ frame_element
52
+
53
+ def add_term
54
+ frm.button(:value=>"Add Term").click
55
+ Glossary.new(@browser)
56
+ end
57
+
58
+ def save_changes
59
+ frm.button(:value=>"Save Changes").click
60
+ Glossary.new(@browser)
61
+ end
62
+
63
+ def long_description=(text)
64
+ frm.frame(:id, "longDescription___Frame").td(:id, "xEditingArea").frame(:index=>0).send_keys(text)
65
+ end
66
+
67
+
68
+ element(:term) { |b| b.frm.text_field(:id=>"term-id") }
69
+ element(:short_description) { |b| b.frm.text_field(:id=>"description-id") }
70
+
71
+ end
72
+
73
+ # Page for importing Glossary files into a Glossary
74
+ class GlossaryImport < BasePage
75
+
76
+ frame_element
77
+
78
+ def select_file
79
+ frm.link(:text=>"Select file...").click
80
+ GlossaryAttach.new(@browser)
81
+ end
82
+
83
+ def import
84
+ frm.button(:value=>"Import").click
85
+ Glossary.new(@browser)
86
+ end
87
+
88
+ end
89
+
90
+ # The file upload page for Glossary importing
91
+ class GlossaryFileUpload < BasePage
92
+
93
+ frame_element
94
+
95
+ @@filex=0
96
+
97
+ # Note that the file_to_upload method can be used
98
+ # multiple times, but it assumes
99
+ # that the add_another_file method is used
100
+ # before it, every time except before the first time.
101
+ def file_to_upload(file_name, file_path="")
102
+ frm.file_field(:id, "content_#{@@filex}").set(file_path + file_name)
103
+ @@filex+=1
104
+ end
105
+
106
+ def upload_files_now
107
+ frm.button(:value=>"Upload Files Now").click
108
+ sleep 0.5
109
+ @@filex=0
110
+ GlossaryAttach.new(@browser)
111
+ end
112
+
113
+ def add_another_file
114
+ frm.link(:text=>"Add Another File").click
115
+ end
116
+
117
+ end
@@ -0,0 +1,29 @@
1
+ #================
2
+ # Gradebook Pages
3
+ #================
4
+
5
+ # The topmost page in a Site's Gradebook
6
+ class Gradebook < BasePage
7
+
8
+ frame_element
9
+
10
+ def items_titles
11
+ titles = []
12
+ items_table = frm.table(:class=>"listHier lines nolines")
13
+ 1.upto(items_table.rows.size-1) do |x|
14
+ titles << items_table.row(:index=>x).a(:index=>0).text
15
+ end
16
+ return titles
17
+ end
18
+
19
+ # Returns the value of the "Released to Students" column
20
+ # for the specified assignment title.
21
+ def released_to_students(assignment)
22
+ frm.table(:class=>"listHier lines nolines").row(:text=>/#{Regexp.escape(assignment)}/)[4].text
23
+ end
24
+
25
+ # Returns the due date value for the specified assignment.
26
+ def due_date(assignment)
27
+ frm.table(:class=>"listHier lines nolines").row(:text=>/#{Regexp.escape(assignment)}/)[3].text
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ #
2
+ class Gradebook2 < BasePage
3
+
4
+ frame_element
5
+
6
+ # Returns an array of names of Gradebook items
7
+ def gradebook_items
8
+ items = []
9
+ frm.div(:class=>"x-grid3-scroller").spans.each do |span|
10
+ if span.class_name =~ /^x-tree3-node-text/
11
+ items << span.text
12
+ end
13
+ end
14
+ return items
15
+ end
16
+
17
+ end
@@ -0,0 +1,36 @@
1
+ # Topmost page for a Site in Sakai
2
+ class Home < BasePage
3
+
4
+ frame_element
5
+
6
+ # Because the links below are contained within iframes
7
+ # we need the in_frame method in place so that the
8
+ # links can be properly parsed in the PageObject
9
+ # methods for them.
10
+ # Note that the iframes are being identified by their
11
+ # index values on the page. This is a very brittle
12
+ # method for identifying them, but for now it's our
13
+ # only option because both the <id> and <name>
14
+ # tags are unique for every site.
15
+ # Site Information Display, Options button
16
+ action(:site_info_display_options) { |b| b.frm.link(:text=>"Options").click }
17
+
18
+ # Recent Announcements Options button
19
+ action(:recent_announcements_options) { |b| b.frm.link(:text=>"Options").click }
20
+ # Link for New In Forms
21
+ action(:new_in_forums) { |b| b.frm.link(:text=>"New Messages").click }
22
+ element(:number_of_announcements) { |b| b.frm.text_field(:id=>"itemsEntryField") }
23
+ action(:update_announcements) { |b| b.frm.button(:name=>"eventSubmit_doUpdate").click }
24
+
25
+
26
+ # Gets the text of the displayed announcements, for
27
+ # test case verification
28
+ def announcements_list
29
+ list = []
30
+ links = @browser.frame(:index=>2).links
31
+ links.each { |link| list << link.text }
32
+ list.delete_if { |item| item=="Options" } # Deletes the Options link if it's there.
33
+ return list
34
+ end
35
+
36
+ end
@@ -0,0 +1,444 @@
1
+ #================
2
+ # Discussion Forums Pages
3
+ #================
4
+
5
+ # This module includes page objects that are common to
6
+ # all pages in the JForums.
7
+ module JForumsResources
8
+
9
+ # Clicks the Discussion Home link, then
10
+ # instantiates the JForums page class.
11
+ def discussion_home
12
+ frm.link(:id=>"backtosite").click
13
+ JForums.new(@browser)
14
+ end
15
+
16
+ # Clicks the Search button in the Main Menu, then
17
+ # instantiates the DiscussionSearch page class.
18
+ def search
19
+ frm.link(:id=>"search", :class=>"mainmenu").click
20
+ DiscussionSearch.new(@browser)
21
+ end
22
+
23
+ # Clicks the My Bookmarks link in the Main Menu,
24
+ # then instantiates the MyBookmarks page class.
25
+ def my_bookmarks
26
+ frm.link(:class=>"mainmenu", :text=>"My Bookmarks").click
27
+ MyBookmarks.new(@browser)
28
+ end
29
+
30
+ # Clicks the My Profile link in the Main Menu, then
31
+ # instantiates the DiscussionsMyProfile page class.
32
+ def my_profile
33
+ frm.link(:id=>"myprofile").click
34
+ DiscussionsMyProfile.new(@browser)
35
+ end
36
+
37
+ # Clicks the Member Listing link in the Main Menu, then
38
+ # instantiates the DiscussionMemberListing page class.
39
+ def member_listing
40
+ frm.link(:text=>"Member Listing", :id=>"latest", :class=>"mainmenu").click
41
+ DiscussionMemberListing.new(@browser)
42
+ end
43
+
44
+ # Clicks the Private Messages link in the Main Menu, then
45
+ # instantiates the PrivateMessages page class.
46
+ def private_messages
47
+ frm.link(:id=>"privatemessages", :class=>"mainmenu").click
48
+ PrivateMessages.new(@browser)
49
+ end
50
+
51
+ # Clicks the Manage link on the Main Menu, then
52
+ # instantiates the ManageDiscussions page class.
53
+ def manage
54
+ frm.link(:id=>"adminpanel", :text=>"Manage").click
55
+ ManageDiscussions.new(@browser)
56
+ end
57
+
58
+ end
59
+
60
+ # The topmost page in Discussion Forums
61
+ class JForums < BasePage
62
+
63
+ frame_element
64
+ include JForumsResources
65
+
66
+ # Clicks on the supplied forum name
67
+ # Then instantiates the DiscussionForum class.
68
+ def open_forum(forum_name)
69
+ frm.link(:text=>forum_name).click
70
+ DiscussionForum.new(@browser)
71
+ end
72
+
73
+ # Clicks the specified Topic and instantiates
74
+ # the ViewTopic Class.
75
+ def open_topic(topic_title)
76
+ frm.link(:text=>topic_title).click
77
+ ViewTopic.new(@browser)
78
+ end
79
+
80
+ # Returns an array containing the names of the Forums listed on the page.
81
+ def forum_list
82
+ list = frm.table(:class=>"forumline").links.map do |link|
83
+ if link.href =~ /forums\/show\//
84
+ link.text
85
+ end
86
+ end
87
+ list.compact!
88
+ return list
89
+ end
90
+
91
+ # Returns the displayed count of topics for the specified
92
+ # Forum.
93
+ def topic_count(forum_name)
94
+ frm.table(:class=>"forumline").row(:text=>/#{Regexp.escape(forum_name)}/)[2].text
95
+ end
96
+
97
+ end
98
+
99
+ # The page of a particular Discussion Forum, show the list
100
+ # of Topics in the forum.
101
+ class DiscussionForum < BasePage
102
+
103
+ frame_element
104
+ include JForumsResources
105
+
106
+ # Clicks the New Topic button,
107
+ # then instantiates the NewTopic class
108
+ def new_topic
109
+ frm.image(:alt=>"New Topic").fire_event("onclick")
110
+ frm.frame(:id, "message___Frame").td(:id, "xEditingArea").wait_until_present
111
+ NewTopic.new(@browser)
112
+ end
113
+
114
+ # Clicks the specified Topic Title, then
115
+ # instantiates the ViewTopic Class.
116
+ def open_topic(topic_title)
117
+ frm.link(:href=>/posts.list/, :text=>topic_title).click
118
+ ViewTopic.new(@browser)
119
+ end
120
+
121
+ end
122
+
123
+ # The Discussion Forums Search page.
124
+ class DiscussionSearch < BasePage
125
+
126
+ frame_element
127
+
128
+ include JForumsResources
129
+
130
+ # Clicks the Search button on the page,
131
+ # then instantiates the JForums class.
132
+ def click_search
133
+ frm.button(:value=>"Search").click
134
+ JForums.new(@browser)
135
+ end
136
+
137
+
138
+ element(:keywords) { |b| b.frm.text_field(:name=>"search_keywords") }
139
+
140
+ end
141
+
142
+ # The Manage Discussions page in Discussion Forums.
143
+ class ManageDiscussions < BasePage
144
+
145
+ frame_element
146
+
147
+ include JForumsResources
148
+
149
+ # Clicks the Manage Forums link,
150
+ # then instantiates the ManageForums Class.
151
+ def manage_forums
152
+ frm.link(:text=>"Manage Forums").click
153
+ ManageForums.new(@browser)
154
+ end
155
+
156
+ # Creates and returns an array of forum titles
157
+ # which can be used for verification
158
+ def forum_titles
159
+ forum_titles = []
160
+ forum_links = frm.links.find_all { |link| link.id=="forumEdit"}
161
+ forum_links.each { |link| forum_titles << link.text }
162
+ return forum_titles
163
+ end
164
+
165
+ end
166
+
167
+ # The page for Managing Forums in the Discussion Forums
168
+ # feature.
169
+ class ManageForums < BasePage
170
+
171
+ frame_element
172
+ include JForumsResources
173
+
174
+ # Clicks the Add button, then
175
+ # instantiates the ManageForums Class.
176
+ def add
177
+ frm.button(:value=>"Add").click
178
+ ManageForums.new(@browser)
179
+ end
180
+
181
+ # Clicks the Update button, then
182
+ # instantiates the ManageDiscussions Class.
183
+ def update
184
+ frm.button(:value=>"Update").click
185
+ ManageDiscussions.new(@browser)
186
+ end
187
+
188
+
189
+ element(:forum_name) { |b| b.frm.text_field(:name=>"forum_name") }
190
+ element(:category) { |b| b.frm.select(:id=>"categories_id") }
191
+ element(:description) { |b| b.frm.text_field(:name=>"description") }
192
+
193
+ end
194
+
195
+ # Page for editing/creating Bookmarks in Discussion Forums.
196
+ class MyBookmarks < BasePage
197
+
198
+ frame_element
199
+ include JForumsResources
200
+
201
+
202
+ end
203
+
204
+ # The page for adding a new discussion topic.
205
+ class NewTopic < BasePage
206
+
207
+ frame_element
208
+ include JForumsResources
209
+
210
+ # Enters the specified string into the FCKEditor for the Message.
211
+ def message_text=(text)
212
+ frm.frame(:id, "message___Frame").td(:id, "xEditingArea").frame(:index=>0).send_keys(:home)
213
+ frm.frame(:id, "message___Frame").td(:id, "xEditingArea").frame(:index=>0).send_keys(text)
214
+ end
215
+
216
+ # Clicks the Submit button, then instantiates the ViewTopic Class.
217
+ def submit
218
+ frm.button(:value=>"Submit").click
219
+ ViewTopic.new(@browser)
220
+ end
221
+
222
+ # Clicks the Preview button and instantiates the PreviewDiscussionTopic Class.
223
+ def preview
224
+ frm.button(:value=>"Preview").click
225
+ PreviewDiscussionTopic.new(@browser)
226
+ end
227
+
228
+ # Enters the specified filename in the file field. The path to the file can be entered as an optional second parameter
229
+ def filename1(filename, filepath="")
230
+ frm.file_field(:name=>"file_0").set(filepath + filename)
231
+ end
232
+
233
+ # Enters the specified filename in the file field.
234
+ #
235
+ # Note that the file should be inside the data/sakai-cle-test-api folder.
236
+ # The file or folder name used for the filename variable
237
+ # should not include a preceding / character.
238
+ def filename2(filename)
239
+ frm.file_field(:name=>"file_1").set(File.expand_path(File.dirname(__FILE__)) + "/../../data/sakai-cle-test-api/" + filename)
240
+ end
241
+
242
+
243
+ element(:subject) { |b| b.frm.text_field(:id=>"subject") }
244
+ action(:attach_files) { |b| b.frm.button(:value=>"Attach Files").click }
245
+ action(:add_another_file) { |b| b.frm.button(:value=>"Add another file").click }
246
+
247
+ end
248
+
249
+ # Viewing a Topic/Message
250
+ class ViewTopic < BasePage
251
+
252
+ frame_element
253
+ include JForumsResources
254
+
255
+ # Gets the text of the Topic title.
256
+ # Useful for verification.
257
+ def topic_name
258
+ frm.link(:id=>"top", :class=>"maintitle").text
259
+ end
260
+
261
+ # Gets the message text for the specified message (not zero-based).
262
+ # Useful for verification.
263
+ def message_text(message_number)
264
+ frm.span(:class=>"postbody", :index=>message_number.to_i-1).text
265
+ end
266
+
267
+ # Clicks the Post Reply button, then
268
+ # instantiates the NewTopic Class.
269
+ def post_reply
270
+ frm.image(:alt=>"Post Reply").fire_event("onclick")
271
+ NewTopic.new(@browser)
272
+ end
273
+
274
+ # Clicks the Quick Reply button
275
+ # and does not instantiate any page classes.
276
+ def quick_reply
277
+ frm.image(:alt=>"Quick Reply").fire_event("onclick")
278
+ end
279
+
280
+ # Clicks the submit button underneath the Quick Reply box,
281
+ # then re-instantiates the class, due to the page update.
282
+ def submit
283
+ frm.button(:value=>"Submit").click
284
+ ViewTopic.new(@browser)
285
+ end
286
+
287
+
288
+ element(:reply_text) { |b| b.frm.text_field(:name=>"quickmessage") }
289
+
290
+
291
+ end
292
+
293
+ # The Profile page for Discussion Forums
294
+ class DiscussionsMyProfile < BasePage
295
+
296
+ frame_element
297
+ include JForumsResources
298
+
299
+ def submit
300
+ frm.button(:value=>"Submit").click
301
+ DiscussionsMyProfile.new(@browser)
302
+ end
303
+
304
+ # Gets the text at the top of the table.
305
+ # Useful for verification.
306
+ def header_text
307
+ frm.table(:class=>"forumline").span(:class=>"gens").text
308
+ end
309
+
310
+ # Enters the specified filename in the file field.
311
+ #
312
+ # The method takes the filepath as an optional second parameter.
313
+ def avatar(filename, filepath="")
314
+ frm.file_field(:name=>"avatar").set(filepath + filename)
315
+ end
316
+
317
+ element(:icq_uin) { |b| b.frm.text_field(:name=>"icq") }
318
+ element(:aim) { |b| b.frm.text_field(:name=>"aim") }
319
+ element(:web_site) { |b| b.frm.text_field(:name=>"website") }
320
+ element(:occupation) { |b| b.frm.text_field(:name=>"occupation") }
321
+ element(:view_email) { |b| b.radio(:name=>"viewemail") }
322
+
323
+ end
324
+
325
+ # The List of Members of a Site's Discussion Forums
326
+ class DiscussionMemberListing < BasePage
327
+
328
+ frame_element
329
+ include JForumsResources
330
+
331
+ # Checks if the specified Member name appears
332
+ # in the member listing.
333
+ def name_present?(name)
334
+ member_links = frm.links.find_all { |link| link.href=~/user.profile/ }
335
+ member_names = []
336
+ member_links.each { |link| member_names << link.text }
337
+ member_names.include?(name)
338
+ end
339
+
340
+ end
341
+
342
+ # The page where users go to read their private messages in the Discussion
343
+ # Forums.
344
+ class PrivateMessages < BasePage
345
+
346
+ frame_element
347
+ include JForumsResources
348
+
349
+ # Clicks the "New PM" button, then
350
+ # instantiates the NewPrivateMessage Class.
351
+ def new_pm
352
+ frm.image(:alt=>"New PM").fire_event("onclick")
353
+ NewPrivateMessage.new(@browser)
354
+ end
355
+
356
+ # Clicks to open the specified message,
357
+ # then instantiates the ViewPM Class.
358
+ def open_message(title)
359
+ frm.link(:class=>"topictitle", :text=>title).click
360
+ ViewPM.new(@browser)
361
+ end
362
+
363
+ # Collects all subject text strings of the listed
364
+ # private messages and returns them in an Array.
365
+ def pm_subjects
366
+ anchor_objects = frm.links.find_all { |link| link.href=~/pm.read.+page/ }
367
+ subjects = []
368
+ anchor_objects.each { |link| subjects << link.text }
369
+ return subjects
370
+ end
371
+
372
+ end
373
+
374
+ # The page of Viewing a particular Private Message.
375
+ class ViewPM < BasePage
376
+
377
+ frame_element
378
+
379
+ # Clicks the Reply Quote button, then
380
+ # instantiates the NewPrivateMessage Class.
381
+ def reply_quote
382
+ frm.image(:alt=>"Reply Quote").fire_event("onclick")
383
+ NewPrivateMessage.new(@browser)
384
+ end
385
+
386
+ end
387
+
388
+ # New Private Message page in Discussion Forums.
389
+ class NewPrivateMessage < BasePage
390
+
391
+ frame_element
392
+ include JForumsResources
393
+
394
+ # Enters text into the FCKEditor text area, after
395
+ # going to the beginning of any existing text in the field.
396
+ def message_body=(text)
397
+ frm.frame(:id, "message___Frame").td(:id, "xEditingArea").frame(:index=>0).send_keys(:home)
398
+ frm.frame(:id, "message___Frame").td(:id, "xEditingArea").frame(:index=>0).send_keys(text)
399
+ end
400
+
401
+ # Clicks the Submit button, then
402
+ # instantiates the Information Class.
403
+ def submit
404
+ frm.button(:value=>"Submit").click
405
+ Information.new(@browser)
406
+ end
407
+
408
+ # Enters the specified filename in the file field.
409
+ def filename1(filename)
410
+ frm.file_field(:name=>"file_0").set(File.expand_path(File.dirname(__FILE__)) + "/../../data/sakai-cle-test-api/" + filename)
411
+ end
412
+
413
+ # Enters the specified filename in the file field.
414
+ #
415
+ # Note that the file should be inside the data/sakai-cle-test-api folder.
416
+ # The file or folder name used for the filename variable
417
+ # should not include a preceding / character.
418
+ def filename2(filename)
419
+ frm.file_field(:name=>"file_1").set(File.expand_path(File.dirname(__FILE__)) + "/../../data/sakai-cle-test-api/" + filename)
420
+ end
421
+
422
+
423
+ element(:to_user) { |b| b.frm.select(:name=>"toUsername") }
424
+ element(:subject) { |b| b.frm.text_field(:id=>"subject") }
425
+ action(:attach_files) { |b| b.frm.button(:value=>"Attach Files").click }
426
+ action(:add_another_file) { |b| b.frm.button(:value=>"Add another file").click }
427
+
428
+
429
+ end
430
+
431
+ # The page that appears when you've done something in discussions, like
432
+ # sent a Private Message.
433
+ class Information < BasePage
434
+
435
+ frame_element
436
+ include JForumsResources
437
+
438
+ # Gets the information message on the page.
439
+ # Useful for verification.
440
+ def information_text
441
+ frm.table(:class=>"forumline").span(:class=>"gen").text
442
+ end
443
+
444
+ end