sakai-cle-test-api 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -0
- data/README.md +44 -0
- data/lib/sakai-cle-test-api.rb +33 -0
- data/lib/sakai-cle-test-api/admin_page_elements.rb +1462 -0
- data/lib/sakai-cle-test-api/app_functions.rb +752 -0
- data/lib/sakai-cle-test-api/common_page_elements.rb +2045 -0
- data/lib/sakai-cle-test-api/site_page_elements.rb +6130 -0
- data/sakai-cle-test-api.gemspec +16 -0
- metadata +118 -0
@@ -0,0 +1,752 @@
|
|
1
|
+
#================
|
2
|
+
# Page Navigation Objects
|
3
|
+
#================
|
4
|
+
|
5
|
+
# ToolsMenu contains all possible links that could
|
6
|
+
# be found in the menu along the left side of the Sakai pages.
|
7
|
+
#
|
8
|
+
# This includes both the Administration Workspace and the
|
9
|
+
# Menus that appear when in the context of a particular Site.
|
10
|
+
module ToolsMenu
|
11
|
+
|
12
|
+
include PageObject
|
13
|
+
|
14
|
+
# Opens the "My Sites" menu box and then clicks on the link
|
15
|
+
# that matches the specified id.
|
16
|
+
#
|
17
|
+
# Errors out if nothing matches.
|
18
|
+
def open_my_site_by_id(id)
|
19
|
+
@browser.link(:text, "My Sites").click
|
20
|
+
@browser.link(:href, /#{id}/).click
|
21
|
+
$frame_index=1
|
22
|
+
Home.new(@browser)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Opens "My Sites" and then clicks on the matching
|
26
|
+
# Site name. Shortens the name used for search so
|
27
|
+
# that truncated names are not a problem.
|
28
|
+
#
|
29
|
+
# Will error out if there are not matching links.
|
30
|
+
def open_my_site_by_name(name)
|
31
|
+
short_name = name[0..19]
|
32
|
+
@browser.link(:text, "My Sites").click
|
33
|
+
@browser.link(:text, /#{Regexp.escape(short_name)}/).click
|
34
|
+
$frame_index=1
|
35
|
+
Home.new(@browser)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Clicks the "Account" link in the Adminstration Workspace
|
39
|
+
# then instantiates the UserAccount class.
|
40
|
+
#
|
41
|
+
# Throws an error if the link is not present.
|
42
|
+
def account
|
43
|
+
@browser.link(:text=>"Account").click
|
44
|
+
UserAccount.new(@browser)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Clicks the "Aliases" link in the Administration Workspace
|
48
|
+
# menu, then instantiates the Aliases class.
|
49
|
+
def aliases
|
50
|
+
@browser.link(:text=>"Aliases").click
|
51
|
+
Aliases.new(@browser)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Clicks the link for the Administration Workspace, then
|
55
|
+
# instantiates the MyWorkspace class.
|
56
|
+
def administration_workspace
|
57
|
+
@browser.link(:text, "Administration Workspace").click
|
58
|
+
$frame_index=1
|
59
|
+
MyWorkspace.new(@browser)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Clicks the Announcements link then instantiates
|
63
|
+
# the Announcements class.
|
64
|
+
def announcements
|
65
|
+
@browser.link(:class=>'icon-sakai-announcements').click
|
66
|
+
Announcements.new(@browser)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Clicks the Assignments link, then instantiates
|
70
|
+
# the Assignments class.
|
71
|
+
def assignments
|
72
|
+
@browser.link(:class=>"icon-sakai-assignment-grades").click
|
73
|
+
AssignmentsList.new(@browser)
|
74
|
+
end
|
75
|
+
|
76
|
+
def basic_lti
|
77
|
+
@browser.link(:class=>"icon-sakai-basiclti").click
|
78
|
+
BasicLTI.new(@browser)
|
79
|
+
end
|
80
|
+
|
81
|
+
def blogs
|
82
|
+
@browser.link(:class=>"icon-sakai-blogwow").click
|
83
|
+
Blogs.new(@browser)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Clicks the Blogger link in the Site menu and
|
87
|
+
# instantiates the Blogger Class.
|
88
|
+
def blogger
|
89
|
+
@browser.link(:class=>"icon-blogger").click
|
90
|
+
Blogger.new(@browser)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Clicks the Calendar link, then instantiates
|
94
|
+
# the Calendar class.
|
95
|
+
def calendar
|
96
|
+
@browser.link(:text=>"Calendar").click
|
97
|
+
Calendar.new(@browser)
|
98
|
+
end
|
99
|
+
|
100
|
+
link(:certification, :text=>"Certification")
|
101
|
+
|
102
|
+
def chat_room
|
103
|
+
@browser.link(:class=>"icon-sakai-chat").click
|
104
|
+
ChatRoom.new(@browser)
|
105
|
+
end
|
106
|
+
|
107
|
+
link(:configuration_viewer, :text=>"Configuration Viewer")
|
108
|
+
link(:customizer, :text=>"Customizer")
|
109
|
+
|
110
|
+
# Clicks the "Discussion Forums" link in the menu,
|
111
|
+
# then instantiates the JForum page class.
|
112
|
+
def discussion_forums
|
113
|
+
@browser.link(:class=>"icon-sakai-jforum-tool").click
|
114
|
+
JForums.new(@browser)
|
115
|
+
end
|
116
|
+
|
117
|
+
def drop_box
|
118
|
+
@browser.link(:class=>"icon-sakai-dropbox").click
|
119
|
+
DropBox.new(@browser)
|
120
|
+
end
|
121
|
+
|
122
|
+
link(:email, :text=>"Email")
|
123
|
+
|
124
|
+
def email_archive
|
125
|
+
@browser.link(:class=>"icon-sakai-mailbox").click
|
126
|
+
EmailArchive.new(@browser)
|
127
|
+
end
|
128
|
+
|
129
|
+
link(:email_template_administration, :text=>"Email Template Administration")
|
130
|
+
|
131
|
+
def evaluation_system
|
132
|
+
@browser.link(:class=>"icon-sakai-rsf-evaluation").click
|
133
|
+
EvaluationSystem.new(@browser)
|
134
|
+
end
|
135
|
+
|
136
|
+
def feedback
|
137
|
+
@browser.link(:class=>"icon-sakai-postem").click
|
138
|
+
Feedback.new(@browser)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Clicks the Forms link that is found in menus for
|
142
|
+
# Portfolio sites.
|
143
|
+
def forms
|
144
|
+
@browser.link(:text=>"Forms", :class=>"icon-sakai-metaobj").click
|
145
|
+
Forms.new(@browser)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Clicks the Forums link, then instantiates
|
149
|
+
# the forums class.
|
150
|
+
def forums
|
151
|
+
@browser.link(:text=>"Forums").click
|
152
|
+
Forums.new(@browser)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Clicks the Glossary link, then instantiates the Glossary Class.
|
156
|
+
def glossary
|
157
|
+
@browser.link(:text=>"Glossary").click
|
158
|
+
Glossary.new(@browser)
|
159
|
+
end
|
160
|
+
|
161
|
+
# Clicks the "Gradebook" link, then
|
162
|
+
# instantiates the Gradebook Class.
|
163
|
+
def gradebook
|
164
|
+
@browser.link(:text=>"Gradebook").click
|
165
|
+
Gradebook.new(@browser)
|
166
|
+
end
|
167
|
+
|
168
|
+
def gradebook2
|
169
|
+
@browser.link(:text=>"Gradebook2").click
|
170
|
+
frm.div(:id=>"borderLayoutContainer").wait_until_present
|
171
|
+
Gradebook2.new(@browser)
|
172
|
+
end
|
173
|
+
|
174
|
+
link(:help, :text=>"Help")
|
175
|
+
|
176
|
+
# Clicks the Home link, then instantiates the
|
177
|
+
# Home class--unless the target page happens to be
|
178
|
+
# My Workspace, in which case the MyWorkspace
|
179
|
+
# page is instantiated.
|
180
|
+
def home
|
181
|
+
@browser.link(:text, "Home").click
|
182
|
+
if @browser.div(:id=>"siteTitle").text == "My Workspace"
|
183
|
+
MyWorkspace.new(@browser)
|
184
|
+
else
|
185
|
+
Home.new(@browser)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# Clicks the Job Scheduler link, then
|
190
|
+
# instantiates the Job Scheduler class.
|
191
|
+
def job_scheduler
|
192
|
+
@browser.link(:text=>"Job Scheduler").click
|
193
|
+
JobScheduler.new(@browser)
|
194
|
+
end
|
195
|
+
|
196
|
+
# Clicks the Lessons link, then instantiates
|
197
|
+
# the Lessons class.
|
198
|
+
def lessons
|
199
|
+
@browser.link(:text=>"Lessons").click
|
200
|
+
Lessons.new(@browser)
|
201
|
+
end
|
202
|
+
|
203
|
+
link(:lesson_builder, :text=>"Lesson Builder")
|
204
|
+
link(:link_tool, :text=>"Link Tool")
|
205
|
+
link(:live_virtual_classroom, :text=>"Live Virtual Classroom")
|
206
|
+
|
207
|
+
# Clicks the "Matrices" link, then
|
208
|
+
# instantiates the Matrices Class.
|
209
|
+
def matrices
|
210
|
+
@browser.link(:text=>"Matrices").click
|
211
|
+
Matrices.new(@browser)
|
212
|
+
end
|
213
|
+
|
214
|
+
def media_gallery
|
215
|
+
@browser.link(:class=>"icon-sakai-kaltura").click
|
216
|
+
MediaGallery.new(@browser)
|
217
|
+
end
|
218
|
+
|
219
|
+
link(:membership, :text=>"Membership")
|
220
|
+
link(:memory, :text=>"Memory")
|
221
|
+
|
222
|
+
# Clicks the Messages link, then instantiates the Messages class.
|
223
|
+
def messages
|
224
|
+
@browser.link(:text=>"Messages").click
|
225
|
+
Messages.new(@browser)
|
226
|
+
end
|
227
|
+
|
228
|
+
link(:my_sites, :text=>"My Sites")
|
229
|
+
|
230
|
+
# Clicks the "My Workspace" link, sets the
|
231
|
+
# $frame_index global variable to 0, then instantiates
|
232
|
+
# the MyWorkspace Class.
|
233
|
+
def my_workspace
|
234
|
+
@browser.link(:text=>"My Workspace").click
|
235
|
+
$frame_index=0
|
236
|
+
MyWorkspace.new(@browser)
|
237
|
+
end
|
238
|
+
|
239
|
+
def news
|
240
|
+
@browser.link(:class=>"icon-sakai-news").click
|
241
|
+
News.new(@browser)
|
242
|
+
end
|
243
|
+
|
244
|
+
link(:online, :text=>"On-Line")
|
245
|
+
link(:oauth_providers, :text=>"Oauth Providers")
|
246
|
+
link(:oauth_tokens, :text=>"Oauth Tokens")
|
247
|
+
link(:openSyllabus, :text=>"OpenSyllabus")
|
248
|
+
|
249
|
+
def podcasts
|
250
|
+
@browser.link(:class=>"icon-sakai-podcasts").click
|
251
|
+
Podcasts.new(@browser)
|
252
|
+
end
|
253
|
+
|
254
|
+
def polls
|
255
|
+
@browser.link(:class=>"icon-sakai-poll").click
|
256
|
+
Polls.new(@browser)
|
257
|
+
end
|
258
|
+
|
259
|
+
def portfolios
|
260
|
+
@browser.link(:class=>"icon-osp-presentation").click
|
261
|
+
Portfolios.new @browser
|
262
|
+
end
|
263
|
+
|
264
|
+
# Clicks the Portfolio Templates link, then
|
265
|
+
# instantiates the Portfolio
|
266
|
+
def portfolio_templates
|
267
|
+
@browser.link(:text=>"Portfolio Templates").click
|
268
|
+
PortfolioTemplates.new(@browser)
|
269
|
+
end
|
270
|
+
|
271
|
+
link(:preferences, :text=>"Preferences")
|
272
|
+
|
273
|
+
def profile
|
274
|
+
@browser.link(:text=>"Profile").click
|
275
|
+
Profile.new @browser
|
276
|
+
end
|
277
|
+
|
278
|
+
def profile2
|
279
|
+
@browser.link(:class=>"icon-sakai-profile2").click
|
280
|
+
Profile2.new @browser
|
281
|
+
end
|
282
|
+
|
283
|
+
link(:realms, :text=>"Realms")
|
284
|
+
|
285
|
+
# Clicks the Resources link, then instantiates
|
286
|
+
# the Resources class.
|
287
|
+
def resources
|
288
|
+
@browser.link(:text, "Resources").click
|
289
|
+
Resources.new(@browser)
|
290
|
+
end
|
291
|
+
|
292
|
+
def roster
|
293
|
+
@browser.link(:class=>"icon-sakai-site-roster").click
|
294
|
+
Roster.new @browser
|
295
|
+
end
|
296
|
+
|
297
|
+
link(:rsmart_support, :text=>"rSmart Support")
|
298
|
+
|
299
|
+
# Because "Search" is used in many pages,
|
300
|
+
# The Search button found in the Site Management
|
301
|
+
# Menu must be given the more explicit name
|
302
|
+
#
|
303
|
+
def site_management_search
|
304
|
+
@browser.link(:class=>"icon-sakai-search").click
|
305
|
+
end
|
306
|
+
|
307
|
+
def sections
|
308
|
+
@browser.link(:class=>"icon-sakai-sections").click
|
309
|
+
Sections.new(@browser)
|
310
|
+
end
|
311
|
+
|
312
|
+
link(:site_archive, :text=>"Site Archive")
|
313
|
+
|
314
|
+
# Clicks the Site Editor link, then instantiates
|
315
|
+
# the Site Editor class.
|
316
|
+
def site_editor
|
317
|
+
@browser.link(:text=>"Site Editor").click
|
318
|
+
SiteEditor.new(@browser)
|
319
|
+
end
|
320
|
+
|
321
|
+
# Clicks the Site Setup link, then instantiates
|
322
|
+
# The SiteEditor class.
|
323
|
+
def site_setup
|
324
|
+
@browser.link(:text=>"Site Setup").click
|
325
|
+
SiteSetup.new(@browser)
|
326
|
+
end
|
327
|
+
|
328
|
+
link(:site_statistics, :text=>"Site Statistics")
|
329
|
+
|
330
|
+
# Clicks the Sites link, then instantiates
|
331
|
+
# the Sites class.
|
332
|
+
def sites
|
333
|
+
@browser.link(:class=>"icon-sakai-sites").click
|
334
|
+
frm.text_field(:id=>"search_site").wait_until_present
|
335
|
+
Sites.new(@browser)
|
336
|
+
end
|
337
|
+
|
338
|
+
link(:skin_manager, :text=>"Skin Manager")
|
339
|
+
link(:super_user, :text=>"Super User")
|
340
|
+
|
341
|
+
def styles
|
342
|
+
@browser.link(:text=>"Styles").click
|
343
|
+
Styles.new(@browser)
|
344
|
+
end
|
345
|
+
|
346
|
+
# Clicks the Syllabus link, then instantiates
|
347
|
+
# the Syllabus class.
|
348
|
+
def syllabus
|
349
|
+
@browser.link(:text=>"Syllabus").click
|
350
|
+
Syllabus.new(@browser)
|
351
|
+
end
|
352
|
+
|
353
|
+
# Clicks the Tests & Quizzes link, then
|
354
|
+
# instantiates the AssessmentsList class.
|
355
|
+
def tests_and_quizzes
|
356
|
+
# Need this logic to determine whether user
|
357
|
+
# is a student or instructor/admin
|
358
|
+
@browser.link(:class, "icon-sakai-siteinfo").exist? ? x=0 : x=1
|
359
|
+
@browser.link(:text=>"Tests & Quizzes").click
|
360
|
+
x==0 ? AssessmentsList.new(@browser) : TakeAssessmentList.new(@browser)
|
361
|
+
end
|
362
|
+
|
363
|
+
# Synonym for tests_and_quizzes method.
|
364
|
+
def assessments
|
365
|
+
tests_and_quizzes
|
366
|
+
end
|
367
|
+
|
368
|
+
def user_membership
|
369
|
+
@browser.link(:class=>"icon-sakai-usermembership").click
|
370
|
+
UserMembership.new(@browser)
|
371
|
+
end
|
372
|
+
|
373
|
+
def users
|
374
|
+
@browser.link(:class=>"icon-sakai-users").click
|
375
|
+
Users.new(@browser)
|
376
|
+
end
|
377
|
+
|
378
|
+
def web_content
|
379
|
+
@browser.link(:class=>"icon-sakai-iframe").click
|
380
|
+
WebContent.new(@browser)
|
381
|
+
end
|
382
|
+
|
383
|
+
def wiki
|
384
|
+
@browser.link(:class=>"icon-sakai-rwiki").click
|
385
|
+
Wikis.new(@browser)
|
386
|
+
end
|
387
|
+
|
388
|
+
# The Page Reset button, found on all Site pages
|
389
|
+
def reset
|
390
|
+
@browser.link(:href=>/tool-reset/).click
|
391
|
+
page_title = @browser.div(:class=>"title").text
|
392
|
+
case(page_title)
|
393
|
+
when "Lessons"
|
394
|
+
Lessons.new(@browser)
|
395
|
+
when "Syllabus"
|
396
|
+
Syllabus.new(@browser)
|
397
|
+
when "Portfolios"
|
398
|
+
Portfolios.new @browser
|
399
|
+
# Add more cases here, as necessary...
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
# Clicks the "(Logout)" link in the upper right of the page.
|
404
|
+
# Instantiates the Login class.
|
405
|
+
def logout
|
406
|
+
@browser.link(:text, "Logout").click
|
407
|
+
Login.new(@browser)
|
408
|
+
end
|
409
|
+
alias log_out logout
|
410
|
+
alias sign_out logout
|
411
|
+
|
412
|
+
# Shortcut method so you don't have to type out
|
413
|
+
# the whole string: @browser.frame(:index=>index)
|
414
|
+
def frm
|
415
|
+
@browser.frame(:class=>"portletMainIframe")
|
416
|
+
end
|
417
|
+
|
418
|
+
end
|
419
|
+
|
420
|
+
# This is a module containing methods that are
|
421
|
+
# common to all the question pages inside the
|
422
|
+
# Assessment section of a Site.
|
423
|
+
module QuestionHelpers
|
424
|
+
|
425
|
+
include PageObject
|
426
|
+
|
427
|
+
# Saves the question by clicking the Save button, then makes the determination
|
428
|
+
# whether to instantiate the EditAssessment class, or the EditQuestionPool class.
|
429
|
+
def save
|
430
|
+
|
431
|
+
quiz = frm.div(:class=>"portletBody").div(:index=>0).text
|
432
|
+
pool = frm.div(:class=>"portletBody").div(:index=>1).text
|
433
|
+
|
434
|
+
frm.button(:value=>"Save").click
|
435
|
+
|
436
|
+
if quiz =~ /^Assessments/
|
437
|
+
EditAssessment.new(@browser)
|
438
|
+
elsif pool =~ /^Question Pools/
|
439
|
+
EditQuestionPool.new(@browser)
|
440
|
+
else
|
441
|
+
puts "Unexpected text: "
|
442
|
+
p pool
|
443
|
+
p quiz
|
444
|
+
end
|
445
|
+
|
446
|
+
end
|
447
|
+
|
448
|
+
in_frame(:index=>1) do |frame|
|
449
|
+
link(:assessments, :text=>"Assessments", :frame=>frame)
|
450
|
+
link(:assessment_types, :text=>"Assessment Types", :frame=>frame)
|
451
|
+
link(:question_pools, :text=>"Question Pools", :frame=>frame)
|
452
|
+
link(:questions, :text=>/Questions:/, :frame=>frame)
|
453
|
+
end
|
454
|
+
|
455
|
+
end
|
456
|
+
|
457
|
+
# This class consolidates the code that can be shared among all the
|
458
|
+
# File Upload and Attachment pages.
|
459
|
+
#
|
460
|
+
# Not every method in this class will be appropriate for every attachment page.
|
461
|
+
class AttachPageTools
|
462
|
+
|
463
|
+
@@classes = { :this=>"Superclassdummy", :parent=>"Superclassdummy" }
|
464
|
+
|
465
|
+
# Use this for debugging purposes only...
|
466
|
+
def what_is_parent?
|
467
|
+
puts @@classes[:parent]
|
468
|
+
end
|
469
|
+
|
470
|
+
# Returns an array of the displayed folder names.
|
471
|
+
def folder_names
|
472
|
+
names = []
|
473
|
+
frm.table(:class=>/listHier lines/).rows.each do |row|
|
474
|
+
next if row.td(:class=>"specialLink").exist? == false
|
475
|
+
next if row.td(:class=>"specialLink").link(:title=>"Folder").exist? == false
|
476
|
+
names << row.td(:class=>"specialLink").link(:title=>"Folder").text
|
477
|
+
end
|
478
|
+
return names
|
479
|
+
end
|
480
|
+
|
481
|
+
# Returns an array of the file names currently listed
|
482
|
+
# on the page.
|
483
|
+
#
|
484
|
+
# It excludes folder names.
|
485
|
+
def file_names
|
486
|
+
names = []
|
487
|
+
frm.table(:class=>/listHier lines/).rows.each do |row|
|
488
|
+
next if row.td(:class=>"specialLink").exist? == false
|
489
|
+
next if row.td(:class=>"specialLink").link(:title=>"Folder").exist?
|
490
|
+
names << row.td(:class=>"specialLink").link(:href=>/access.content/, :index=>1).text
|
491
|
+
end
|
492
|
+
return names
|
493
|
+
end
|
494
|
+
|
495
|
+
# Clicks the Select button next to the specified file.
|
496
|
+
def select_file(filename)
|
497
|
+
frm.table(:class=>/listHier lines/).row(:text, /#{Regexp.escape(filename)}/).link(:text=>"Select").click
|
498
|
+
end
|
499
|
+
|
500
|
+
# Clicks the Remove button.
|
501
|
+
def remove
|
502
|
+
frm.button(:value=>"Remove").click
|
503
|
+
end
|
504
|
+
|
505
|
+
# Clicks the remove link for the specified item in the attachment list.
|
506
|
+
def remove_item(file_name)
|
507
|
+
frm.table(:class=>/listHier/).row(:text=>/#{Regexp.escape(file_name)}/).link(:href=>/doRemoveitem/).click
|
508
|
+
end
|
509
|
+
|
510
|
+
# Clicks the Move button.
|
511
|
+
def move
|
512
|
+
frm.button(:value=>"Move").click
|
513
|
+
end
|
514
|
+
|
515
|
+
# Clicks the Show Other Sites link.
|
516
|
+
def show_other_sites
|
517
|
+
frm.link(:text=>"Show other sites").click
|
518
|
+
end
|
519
|
+
|
520
|
+
# Clicks on the specified folder image, which
|
521
|
+
# will open the folder tree and remain on the page.
|
522
|
+
def open_folder(foldername)
|
523
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(foldername)}/).link(:title=>"Open this folder").click
|
524
|
+
end
|
525
|
+
|
526
|
+
# Clicks on the specified folder name, which should open
|
527
|
+
# the folder contents on a refreshed page.
|
528
|
+
def go_to_folder(foldername)
|
529
|
+
frm.link(:text=>foldername).click
|
530
|
+
end
|
531
|
+
|
532
|
+
# Sets the URL field to the specified value.
|
533
|
+
def url=(url_string)
|
534
|
+
frm.text_field(:id=>"url").set(url_string)
|
535
|
+
end
|
536
|
+
|
537
|
+
# Clicks the Add button next to the URL field.
|
538
|
+
def add
|
539
|
+
frm.button(:value=>"Add").click
|
540
|
+
end
|
541
|
+
|
542
|
+
# Gets the value of the access level cell for the specified
|
543
|
+
# file.
|
544
|
+
def access_level(filename)
|
545
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(filename)}/)[6].text
|
546
|
+
end
|
547
|
+
|
548
|
+
def edit_details(name)
|
549
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(name)}/).li(:text=>/Action/, :class=>"menuOpen").fire_event("onclick")
|
550
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(name)}/).link(:text=>"Edit Details").click
|
551
|
+
instantiate_class(:file_details)
|
552
|
+
end
|
553
|
+
|
554
|
+
# Clicks the Create Folders menu item in the
|
555
|
+
# Add menu of the specified folder.
|
556
|
+
def create_subfolders_in(folder_name)
|
557
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Start Add Menu").fire_event("onfocus")
|
558
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Create Folders").click
|
559
|
+
instantiate_class(:create_folders)
|
560
|
+
end
|
561
|
+
|
562
|
+
# Enters the specified file into the file field name (assuming it's in the
|
563
|
+
# data/sakai-cle-test-api folder or a subfolder therein)
|
564
|
+
#
|
565
|
+
# Does NOT instantiate any class, so use only when no page refresh occurs.
|
566
|
+
def upload_file(filename)
|
567
|
+
frm.file_field(:id=>"upload").set(File.expand_path(File.dirname(__FILE__)) + "/../../data/sakai-cle-test-api/" + filename)
|
568
|
+
if frm.div(:class=>"alertMessage").exist?
|
569
|
+
sleep 2
|
570
|
+
upload_file(filename)
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
# Enters the specified file into the file field name (assuming it's in the
|
575
|
+
# data/sakai-cle-test-api folder or a subfolder therein)
|
576
|
+
#
|
577
|
+
# Use this method ONLY for instances where there's a file field on the page
|
578
|
+
# with an "upload" id.
|
579
|
+
def upload_local_file(filename)
|
580
|
+
frm.file_field(:id=>"upload").set(File.expand_path(File.dirname(__FILE__)) + "/../../data/sakai-cle-test-api/" + filename)
|
581
|
+
if frm.div(:class=>"alertMessage").exist?
|
582
|
+
sleep 2
|
583
|
+
upload_local_file(filename)
|
584
|
+
end
|
585
|
+
instantiate_class(:this)
|
586
|
+
end
|
587
|
+
|
588
|
+
# Clicks the Add Menu for the specified
|
589
|
+
# folder, then selects the Upload Files
|
590
|
+
# command in the menu that appears.
|
591
|
+
def upload_file_to_folder(folder_name)
|
592
|
+
upload_files_to_folder(folder_name)
|
593
|
+
end
|
594
|
+
|
595
|
+
# Clicks the Add Menu for the specified
|
596
|
+
# folder, then selects the Upload Files
|
597
|
+
# command in the menu that appears.
|
598
|
+
def upload_files_to_folder(folder_name)
|
599
|
+
if frm.li(:text=>/A/, :class=>"menuOpen").exist?
|
600
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).li(:text=>/A/, :class=>"menuOpen").fire_event("onclick")
|
601
|
+
else
|
602
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Start Add Menu").fire_event("onfocus")
|
603
|
+
end
|
604
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Upload Files").click
|
605
|
+
instantiate_class(:upload_files)
|
606
|
+
end
|
607
|
+
|
608
|
+
# Clicks the "Attach a copy" link for the specified
|
609
|
+
# file, then reinstantiates the Class.
|
610
|
+
# If an alert box appears, the method will call itself again.
|
611
|
+
# Note that this can lead to an infinite loop. Will need to fix later.
|
612
|
+
def attach_a_copy(file_name)
|
613
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(file_name)}/).link(:href=>/doAttachitem/).click
|
614
|
+
if frm.div(:class=>"alertMessage").exist?
|
615
|
+
sleep 1
|
616
|
+
attach_a_copy(file_name) # TODO - This can loop infinitely
|
617
|
+
end
|
618
|
+
instantiate_class(:this)
|
619
|
+
end
|
620
|
+
|
621
|
+
# Clicks the Create Folders menu item in the
|
622
|
+
# Add menu of the specified folder.
|
623
|
+
def create_subfolders_in(folder_name)
|
624
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Start Add Menu").fire_event("onfocus")
|
625
|
+
frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Create Folders").click
|
626
|
+
instantiate_class(:create_folders)
|
627
|
+
end
|
628
|
+
|
629
|
+
# Takes the specified array object containing pointers
|
630
|
+
# to local file resources, then uploads those files to
|
631
|
+
# the folder specified, checks if they all uploaded properly and
|
632
|
+
# if not, re-tries the ones that failed the first time.
|
633
|
+
#
|
634
|
+
# Finally, it re-instantiates the AnnouncementsAttach page class.
|
635
|
+
def upload_multiple_files_to_folder(folder, file_array)
|
636
|
+
|
637
|
+
upload = upload_files_to_folder folder
|
638
|
+
|
639
|
+
file_array.each do |file|
|
640
|
+
upload.file_to_upload=file
|
641
|
+
upload.add_another_file
|
642
|
+
end
|
643
|
+
|
644
|
+
resources = upload.upload_files_now
|
645
|
+
|
646
|
+
file_array.each do |file|
|
647
|
+
file =~ /(?<=\/).+/
|
648
|
+
# puts $~.to_s # For debugging purposes
|
649
|
+
unless resources.file_names.include?($~.to_s)
|
650
|
+
upload_files = resources.upload_files_to_folder(folder)
|
651
|
+
upload_files.file_to_upload=file
|
652
|
+
resources = upload_files.upload_files_now
|
653
|
+
end
|
654
|
+
end
|
655
|
+
instantiate_class(:this)
|
656
|
+
end
|
657
|
+
|
658
|
+
# Clicks the Continue button then
|
659
|
+
# decides which page class to instantiate
|
660
|
+
# based on the page that appears. This is going to need to be fixed.
|
661
|
+
def continue
|
662
|
+
frm.div(:class=>"highlightPanel").span(:id=>"submitnotifxxx").wait_while_present
|
663
|
+
frm.button(:value=>"Continue").click
|
664
|
+
page_title = @browser.div(:class=>"title").text
|
665
|
+
case(page_title)
|
666
|
+
when "Lessons"
|
667
|
+
instantiate_class(:parent)
|
668
|
+
when "Assignments"
|
669
|
+
if frm.div(:class=>"portletBody").h3.text=~/In progress/ || frm.div(:class=>"portletBody").h3.text == "Select supporting files"
|
670
|
+
instantiate_class(:second)
|
671
|
+
elsif frm.div(:class=>"portletBody").h3.text=~/edit/i || frm.div(:class=>"portletBody").h3.text=~/add/i
|
672
|
+
instantiate_class(:parent)
|
673
|
+
elsif frm.form(:id=>"gradeForm").exist?
|
674
|
+
instantiate_class(:third)
|
675
|
+
end
|
676
|
+
when "Forums"
|
677
|
+
if frm.div(:class=>"portletBody").h3.text == "Forum Settings"
|
678
|
+
instantiate_class(:second)
|
679
|
+
else
|
680
|
+
instantiate_class(:parent)
|
681
|
+
end
|
682
|
+
when "Messages"
|
683
|
+
if frm.div(:class=>/breadCrumb/).text =~ /Reply to Message/
|
684
|
+
instantiate_class(:second)
|
685
|
+
else
|
686
|
+
instantiate_class(:parent)
|
687
|
+
end
|
688
|
+
when "Calendar"
|
689
|
+
frm.frame(:id, "description___Frame").td(:id, "xEditingArea").frame(:index=>0).wait_until_present
|
690
|
+
instantiate_class(:parent)
|
691
|
+
when "Portfolio Templates"
|
692
|
+
if frm.div(:class=>"portletBody").h3.text=="Select supporting files"
|
693
|
+
instantiate_class(:second)
|
694
|
+
else
|
695
|
+
instantiate_class(:parent)
|
696
|
+
end
|
697
|
+
else
|
698
|
+
instantiate_class(:parent)
|
699
|
+
end
|
700
|
+
end
|
701
|
+
|
702
|
+
private
|
703
|
+
|
704
|
+
# This is a private method that is only used inside this superclass.
|
705
|
+
def instantiate_class(key)
|
706
|
+
eval(@@classes[key]).new(@browser)
|
707
|
+
end
|
708
|
+
|
709
|
+
# This is another private method--a better way to
|
710
|
+
# instantiate the @@classes hash variable.
|
711
|
+
def set_classes_hash(hash_object)
|
712
|
+
@@classes = hash_object
|
713
|
+
end
|
714
|
+
|
715
|
+
end
|
716
|
+
|
717
|
+
# Methods to extend the page-object gem...
|
718
|
+
module PageObject
|
719
|
+
module Elements
|
720
|
+
class Element
|
721
|
+
|
722
|
+
def disabled?
|
723
|
+
@element.disabled?
|
724
|
+
end
|
725
|
+
|
726
|
+
end
|
727
|
+
end
|
728
|
+
end
|
729
|
+
|
730
|
+
# Need this to extend Watir to be able to attach to Sakai's non-standard tags...
|
731
|
+
module Watir
|
732
|
+
class Element
|
733
|
+
# attaches to the "headers" tags inside of the assignments table.
|
734
|
+
def headers
|
735
|
+
@how = :ole_object
|
736
|
+
return @o.headers
|
737
|
+
end
|
738
|
+
|
739
|
+
# attaches to the "for" tags in "label" tags.
|
740
|
+
def for
|
741
|
+
@how = :ole_object
|
742
|
+
return @o.for
|
743
|
+
end
|
744
|
+
|
745
|
+
# attaches to the "summary" tag
|
746
|
+
def summary
|
747
|
+
@how = :ole_object
|
748
|
+
return @o.summary
|
749
|
+
end
|
750
|
+
|
751
|
+
end
|
752
|
+
end
|