sakai-cle-test-api 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/README.md +2 -5
  2. data/lib/sakai-cle-test-api.rb +4 -8
  3. data/lib/sakai-cle-test-api/admin_page_elements.rb +1 -433
  4. data/lib/sakai-cle-test-api/announcements.rb +59 -0
  5. data/lib/sakai-cle-test-api/assessments.rb +194 -0
  6. data/lib/sakai-cle-test-api/assignments.rb +113 -0
  7. data/lib/sakai-cle-test-api/basic_lti.rb +5 -0
  8. data/lib/sakai-cle-test-api/blogs.rb +5 -0
  9. data/lib/sakai-cle-test-api/calendar.rb +65 -0
  10. data/lib/sakai-cle-test-api/calendar_summary.rb +0 -0
  11. data/lib/sakai-cle-test-api/common_page_elements.rb +1 -817
  12. data/lib/sakai-cle-test-api/drop_box.rb +0 -0
  13. data/lib/sakai-cle-test-api/email_archive.rb +10 -0
  14. data/lib/sakai-cle-test-api/forums.rb +39 -0
  15. data/lib/sakai-cle-test-api/gradebook.rb +10 -0
  16. data/lib/sakai-cle-test-api/gradebook2.rb +6 -0
  17. data/lib/sakai-cle-test-api/messages.rb +119 -0
  18. data/lib/sakai-cle-test-api/news.rb +9 -0
  19. data/lib/sakai-cle-test-api/polls.rb +24 -0
  20. data/lib/sakai-cle-test-api/post_em.rb +0 -0
  21. data/lib/sakai-cle-test-api/profile.rb +17 -0
  22. data/lib/sakai-cle-test-api/profile2.rb +43 -0
  23. data/lib/sakai-cle-test-api/resources_roster.rb +0 -0
  24. data/lib/sakai-cle-test-api/rwiki.rb +0 -0
  25. data/lib/sakai-cle-test-api/sections.rb +43 -0
  26. data/lib/sakai-cle-test-api/single_user.rb +0 -0
  27. data/lib/sakai-cle-test-api/site_page_elements.rb +1236 -5017
  28. data/lib/sakai-cle-test-api/site_statistics.rb +0 -0
  29. data/lib/sakai-cle-test-api/syllabus.rb +77 -0
  30. data/lib/sakai-cle-test-api/tools_menu.rb +415 -0
  31. data/sakai-cle-test-api.gemspec +2 -2
  32. metadata +30 -6
  33. data/lib/sakai-cle-test-api/app_functions.rb +0 -753
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'sakai-cle-test-api'
3
- s.version = '0.0.5'
3
+ s.version = '0.0.6'
4
4
  s.summary = %q{Sakai-CLE functional testing API for the rSmart Collaborative Learning Environment}
5
5
  s.description = %q{The Sakai-OAE gem provides an API for interacting with pages and page elements in rSmart's deployment of the Sakai Collaborative Learning Environment.}
6
6
  s.files = Dir.glob("**/**/**")
@@ -11,6 +11,6 @@ spec = Gem::Specification.new do |s|
11
11
  s.add_dependency 'page-object', '>= 0.6.6'
12
12
  s.add_dependency 'watir-webdriver', '>= 0.5.5'
13
13
  s.add_dependency 'selenium-webdriver', '>= 2.21.2'
14
- s.add_dependency 'kuali-sakai-common-lib', '>= 0.0.1'
14
+ s.add_dependency 'kuali-sakai-common-lib', '>= 0.0.6'
15
15
  s.required_ruby_version = '>= 1.9.2'
16
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sakai-cle-test-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-01 00:00:00.000000000 Z
12
+ date: 2012-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: page-object
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
- version: 0.0.1
69
+ version: 0.0.6
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
- version: 0.0.1
77
+ version: 0.0.6
78
78
  description: The Sakai-OAE gem provides an API for interacting with pages and page
79
79
  elements in rSmart's deployment of the Sakai Collaborative Learning Environment.
80
80
  email:
@@ -85,9 +85,33 @@ extra_rdoc_files: []
85
85
  files:
86
86
  - Gemfile
87
87
  - lib/sakai-cle-test-api/admin_page_elements.rb
88
- - lib/sakai-cle-test-api/app_functions.rb
88
+ - lib/sakai-cle-test-api/announcements.rb
89
+ - lib/sakai-cle-test-api/assessments.rb
90
+ - lib/sakai-cle-test-api/assignments.rb
91
+ - lib/sakai-cle-test-api/basic_lti.rb
92
+ - lib/sakai-cle-test-api/blogs.rb
93
+ - lib/sakai-cle-test-api/calendar.rb
94
+ - lib/sakai-cle-test-api/calendar_summary.rb
89
95
  - lib/sakai-cle-test-api/common_page_elements.rb
96
+ - lib/sakai-cle-test-api/drop_box.rb
97
+ - lib/sakai-cle-test-api/email_archive.rb
98
+ - lib/sakai-cle-test-api/forums.rb
99
+ - lib/sakai-cle-test-api/gradebook.rb
100
+ - lib/sakai-cle-test-api/gradebook2.rb
101
+ - lib/sakai-cle-test-api/messages.rb
102
+ - lib/sakai-cle-test-api/news.rb
103
+ - lib/sakai-cle-test-api/polls.rb
104
+ - lib/sakai-cle-test-api/post_em.rb
105
+ - lib/sakai-cle-test-api/profile.rb
106
+ - lib/sakai-cle-test-api/profile2.rb
107
+ - lib/sakai-cle-test-api/resources_roster.rb
108
+ - lib/sakai-cle-test-api/rwiki.rb
109
+ - lib/sakai-cle-test-api/sections.rb
110
+ - lib/sakai-cle-test-api/single_user.rb
90
111
  - lib/sakai-cle-test-api/site_page_elements.rb
112
+ - lib/sakai-cle-test-api/site_statistics.rb
113
+ - lib/sakai-cle-test-api/syllabus.rb
114
+ - lib/sakai-cle-test-api/tools_menu.rb
91
115
  - lib/sakai-cle-test-api/utilities.rb
92
116
  - lib/sakai-cle-test-api.rb
93
117
  - README.md
@@ -112,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
136
  version: '0'
113
137
  requirements: []
114
138
  rubyforge_project:
115
- rubygems_version: 1.8.22
139
+ rubygems_version: 1.8.24
116
140
  signing_key:
117
141
  specification_version: 3
118
142
  summary: Sakai-CLE functional testing API for the rSmart Collaborative Learning Environment
@@ -1,753 +0,0 @@
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, filepath="")
567
- frm.file_field(:id=>"upload").set(filepath + 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, filepath="")
580
- frm.file_field(:id=>"upload").set(filepath + 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 appropriate page class.
635
- # Note that it expects all files to be located in the same folder (can be in subfolders of that folder).
636
- def upload_multiple_files_to_folder(folder, file_array, file_path="")
637
-
638
- upload = upload_files_to_folder folder
639
-
640
- file_array.each do |file|
641
- upload.file_to_upload(file, file_path)
642
- upload.add_another_file
643
- end
644
-
645
- resources = upload.upload_files_now
646
-
647
- file_array.each do |file|
648
- file =~ /(?<=\/).+/
649
- # puts $~.to_s # For debugging purposes
650
- unless resources.file_names.include?($~.to_s)
651
- upload_files = resources.upload_files_to_folder(folder)
652
- upload_files.file_to_upload(file, file_path)
653
- resources = upload_files.upload_files_now
654
- end
655
- end
656
- instantiate_class(:this)
657
- end
658
-
659
- # Clicks the Continue button then
660
- # decides which page class to instantiate
661
- # based on the page that appears. This is going to need to be fixed.
662
- def continue
663
- frm.div(:class=>"highlightPanel").span(:id=>"submitnotifxxx").wait_while_present
664
- frm.button(:value=>"Continue").click
665
- page_title = @browser.div(:class=>"title").text
666
- case(page_title)
667
- when "Lessons"
668
- instantiate_class(:parent)
669
- when "Assignments"
670
- if frm.div(:class=>"portletBody").h3.text=~/In progress/ || frm.div(:class=>"portletBody").h3.text == "Select supporting files"
671
- instantiate_class(:second)
672
- elsif frm.div(:class=>"portletBody").h3.text=~/edit/i || frm.div(:class=>"portletBody").h3.text=~/add/i
673
- instantiate_class(:parent)
674
- elsif frm.form(:id=>"gradeForm").exist?
675
- instantiate_class(:third)
676
- end
677
- when "Forums"
678
- if frm.div(:class=>"portletBody").h3.text == "Forum Settings"
679
- instantiate_class(:second)
680
- else
681
- instantiate_class(:parent)
682
- end
683
- when "Messages"
684
- if frm.div(:class=>/breadCrumb/).text =~ /Reply to Message/
685
- instantiate_class(:second)
686
- else
687
- instantiate_class(:parent)
688
- end
689
- when "Calendar"
690
- frm.frame(:id, "description___Frame").td(:id, "xEditingArea").frame(:index=>0).wait_until_present
691
- instantiate_class(:parent)
692
- when "Portfolio Templates"
693
- if frm.div(:class=>"portletBody").h3.text=="Select supporting files"
694
- instantiate_class(:second)
695
- else
696
- instantiate_class(:parent)
697
- end
698
- else
699
- instantiate_class(:parent)
700
- end
701
- end
702
-
703
- private
704
-
705
- # This is a private method that is only used inside this superclass.
706
- def instantiate_class(key)
707
- eval(@@classes[key]).new(@browser)
708
- end
709
-
710
- # This is another private method--a better way to
711
- # instantiate the @@classes hash variable.
712
- def set_classes_hash(hash_object)
713
- @@classes = hash_object
714
- end
715
-
716
- end
717
-
718
- # Methods to extend the page-object gem...
719
- module PageObject
720
- module Elements
721
- class Element
722
-
723
- def disabled?
724
- @element.disabled?
725
- end
726
-
727
- end
728
- end
729
- end
730
-
731
- # Need this to extend Watir to be able to attach to Sakai's non-standard tags...
732
- module Watir
733
- class Element
734
- # attaches to the "headers" tags inside of the assignments table.
735
- def headers
736
- @how = :ole_object
737
- return @o.headers
738
- end
739
-
740
- # attaches to the "for" tags in "label" tags.
741
- def for
742
- @how = :ole_object
743
- return @o.for
744
- end
745
-
746
- # attaches to the "summary" tag
747
- def summary
748
- @how = :ole_object
749
- return @o.summary
750
- end
751
-
752
- end
753
- end