sakai-oae-test-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1273 @@
1
+ # coding: UTF-8
2
+
3
+ # Methods related to the My Account Pop Up dialog.
4
+ module AccountPreferencesPopUp
5
+
6
+ include PageObject
7
+
8
+ # Page Object Definitions
9
+ button(:preferences, :id=>"accountpreferences_preferences_tab")
10
+ button(:privacy_settings, :id=>"accountpreferences_privacy_tab")
11
+ button(:password, :id=>"accountpreferences_password_tab")
12
+
13
+ select_list(:time_zone, :id=>"time_zone")
14
+ select_list(:language, :id=>"pass_language")
15
+
16
+ text_field(:current_password, :id=>"curr_pass")
17
+ text_field(:new_password, :id=>"new_pass")
18
+ text_field(:retype_password, :id=>"retype_pass")
19
+
20
+ button(:save_new_password, :text=>"Save new password")
21
+ button(:save_preferences, :text=>"Save preferences")
22
+ button(:save_privacy_settings, :text=>"Save privacy settings")
23
+
24
+ span(:new_password_error, :id=>"new_pass_error")
25
+ span(:retype_password_error, :id=>"retype_pass_error")
26
+
27
+ # Custom methods...
28
+
29
+ # Need this custom Cancel button method because there are three different
30
+ # cancel buttons on this pop-up. This method will find the one that works
31
+ # and click on it.
32
+ def cancel
33
+ case
34
+ when self.div(:id=>"accountpreferences_preferContainer").visible?
35
+ self.div(:id=>"accountpreferences_preferContainer").button(:class=>"s3d-link-button s3d-bold accountpreferences_cancel").click
36
+ when self.div(:id=>"accountpreferences_changePrivacyContainer").visible?
37
+ self.div(:id=>"accountpreferences_changePrivacyContainer").button(:class=>"s3d-link-button s3d-bold accountpreferences_cancel").click
38
+ when self.div(:id=>"accountpreferences_changePassContainer").visible?
39
+ self.div(:id=>"accountpreferences_changePassContainer").button(:class=>"s3d-link-button s3d-bold accountpreferences_cancel").click
40
+ else
41
+ puts "\nCouldn't find the cancel button!\n"
42
+ end
43
+ end
44
+
45
+ end # AccountPreferencesPopUp
46
+
47
+ # Page Objects and Methods for the Add Areas Pop up dialog.
48
+ # Many page objects in this module are NOT defined using the
49
+ # Page Object gem, so they will need to be handled differently
50
+ # than usual. See the descriptions of the methods for more detail.
51
+ module AddAreasPopUp
52
+
53
+ include PageObject
54
+
55
+ # Page Object Definitions...
56
+
57
+ # Common elements...
58
+ button(:done_add_button, :id=>"addarea_create_doc_button" )
59
+ button(:cancel, :class=>"s3d-link-button jqmClose s3d-bold", :text=>"Cancel")
60
+
61
+ # New...
62
+ button(:new_container, :text=>"New", :class=>"s3d-button s3d-link-button")
63
+ text_field(:new_doc_name, :name=>"addarea_new_name", :class=>"addarea_name_field")
64
+ select_list(:new_doc_permissions, :id=>"addarea_new_permissions")
65
+ select_list(:number_of_pages, :id=>"addarea_new_numberofpages")
66
+ text_area(:new_doc_tags_and_categories, :name=>"addarea_new_tagsandcategories")
67
+ button(:list_categories_button, :text=>"List categories")
68
+
69
+ # Currently viewing...
70
+ button(:currently_viewing, :text=>"Currently viewing")
71
+
72
+ # My library...
73
+ button(:from_my_library, :class=>"s3d-button s3d-link-button subnav_button", :text=>"My library")
74
+
75
+ # Everywhere...
76
+ button(:everywhere, :text=>"Everywhere")
77
+
78
+ # Content list...
79
+ button(:content_list, :text=>"Content list")
80
+
81
+ # Participants list...
82
+ button(:participants_list, :text=>"Participants list")
83
+
84
+ # Widgets...
85
+ button(:widgets, :text=>"Widgets")
86
+
87
+ # Custom Methods...
88
+
89
+ # Clicks the list categories link.
90
+ def list_categories
91
+ self.list_categories_button
92
+ self.wait_for_ajax
93
+ self.class.class_eval { include AddRemoveCategories }
94
+ end
95
+
96
+ # The "Search Everywhere" text field. Due to a strange bug with
97
+ # Watir-webdriver and/or PageObject, we're using this method for the
98
+ # definition of the field, so if you need to enter a text string into it
99
+ # you'll need to use Watir-webdriver's ".set" method, like this:
100
+ # page_object.search_everywhere.set "text string"
101
+ def search_everywhere
102
+ self.text_field(:id=>"addarea_existing_everywhere_search")
103
+ end
104
+
105
+ # Defines the Existing Document Name field based on the currently
106
+ # selected tab. Test script steps will need to use Watir's .set method
107
+ # for entering text strings into the fields.
108
+ def existing_doc_name
109
+ a = "addarea_existing_mylibrary_container"
110
+ b = "addarea_existing_everywhere_container"
111
+ c = "addarea_existing_currentlyviewing_container"
112
+ case
113
+ when self.div(:id=>a).visible?
114
+ return self.div(:id=>a).text_field(:name=>"addarea_existing_name")
115
+ when self.div(:id=>b).visible?
116
+ return self.div(:id=>b).text_field(:name=>"addarea_existing_name")
117
+ when self.div(:id=>c).visible?
118
+ return self.div(:id=>c).text_field(:name=>"addarea_existing_name")
119
+ end
120
+ end
121
+
122
+ # Defines the Existing Doc Permissions select list field.
123
+ # To select an item from this field you'll need to include Watir's
124
+ # .select method in your test script step, like this:
125
+ # page_object.existing_doc_permissions.select "option"
126
+ def existing_doc_permissions
127
+ a = "addarea_existing_mylibrary_container"
128
+ b = "addarea_existing_everywhere_container"
129
+ c = "addarea_existing_currentlyviewing_container"
130
+ case
131
+ when self.div(:id=>a).visible?
132
+ return self.div(:id=>a).select(:name=>"addarea_existing_permissions")
133
+ when self.div(:id=>b).visible?
134
+ return self.div(:id=>b).select(:name=>"addarea_existing_permissions")
135
+ when self.div(:id=>c).visible?
136
+ return self.div(:id=>c).select(:name=>"addarea_existing_permissions")
137
+ end
138
+ end
139
+
140
+ # The div containing the search results list.
141
+ # This method is primarily for use in the procedural methods
142
+ # in this module rather than for steps in a test script (because it
143
+ # only refers to the "Everywhere" list.
144
+ def search_results
145
+ self.div(:id=>"addarea_existing_everywhere_bottom")
146
+ end
147
+
148
+ # The name field for adding a Content List page. Use of this method
149
+ # in a test script will require including a Watir method. For example,
150
+ # if you want to send the field a text string, you'll use the .set
151
+ # method, like this: page_object.content_list_name.set "Name"
152
+ def content_list_name
153
+ self.text_field(:id=>"addarea_contentlist_name")
154
+ end
155
+
156
+ # The permissions field for adding a Content List page. Use of this method
157
+ # in a test script will require including a Watir method. For example,
158
+ # if you want to send the field a text string, you'll use the .set
159
+ # method, like this: page_object.content_list_permissions.select "Option"
160
+ def content_list_permissions
161
+ self.select(:id=>"addarea_contentlist_permissions")
162
+ end
163
+
164
+ # The name field for adding a Participant List page. Use of this method
165
+ # in a test script will require including a Watir method. For example,
166
+ # if you want to send the field a text string, you'll use the .set
167
+ # method, like this: page_object.participants_list_name.set "Name"
168
+ def participants_list_name
169
+ self.text_field(:id=>"addarea_participants_name")
170
+ end
171
+
172
+ # The permissions field for adding a Participants List page. Use of this method
173
+ # in a test script will require including a Watir method. For example,
174
+ # if you want to send the field a text string, you'll use the .set
175
+ # method, like this: page_object.participants_list_permissions.select "Option"
176
+ def participants_list_permissions
177
+ @browser.select(:id=>"addarea_participants_permissions")
178
+ end
179
+
180
+ # The text field for entering the widget name. When using this method directly,
181
+ # be sure to remember that it will require Watir-webdriver methods, as well.
182
+ # However, it should not be necessary to call this method directly, as it is
183
+ # used as a helper for other methods in this class.
184
+ def widget_name
185
+ self.text_field(:id=>"addarea_widgets_name")
186
+ end
187
+
188
+ # The select list field for selecting the widget. When using this method directly,
189
+ # be sure to remember that it will require Watir-webdriver methods, as well.
190
+ # However, it should not be necessary to call this method directly, as it is
191
+ # used as a helper for other methods in this class.
192
+ def select_widget
193
+ self.select(:id=>"addarea_widgets_widget")
194
+ end
195
+
196
+ # The select list for defining the widget permissions. When using this method directly,
197
+ # be sure to remember that it will require Watir-webdriver methods, as well.
198
+ # However, it should not be necessary to call this method directly, as it is
199
+ # used as a helper for other methods in this class.
200
+ def widget_permissions
201
+ self.select(:id=>"addarea_widgets_permissions")
202
+ end
203
+
204
+ # Clicks the "Done, add" button in the Add Area flyout dialog, then
205
+ # waits for the Ajax calls to drop to zero.
206
+ def create
207
+ self.done_add_button
208
+ self.wait_for_ajax
209
+ end
210
+
211
+ alias done_add create
212
+
213
+ # This method expects to be passed a hash object like this:
214
+ # { :name=>"The name of the target document",
215
+ # :title=>"The placement title string",
216
+ # :visible=>"Who can see it" }
217
+ # The method adds an existing document using the specified hash contents.
218
+ # Note that it uses the "Everywhere" page, so if you want to use
219
+ # one of the other pages for the search, you'll have to code all steps in
220
+ # the test script itself.
221
+ def add_from_existing(document)
222
+ self.everywhere
223
+ search_everywhere.set(document[:name] + "\n")
224
+ self.wait_for_ajax #
225
+ search_results.li(:text=>/#{Regexp.escape(document[:name])}/).fire_event("onclick")
226
+ existing_doc_name.set document[:title]
227
+ existing_doc_permissions.select document[:visible]
228
+
229
+ self.create
230
+ end
231
+
232
+ alias add_existing_document add_from_existing
233
+ alias add_existing_doc add_from_existing
234
+ alias add_an_existing_document add_from_existing
235
+
236
+ # Adds a Participant List Area to the Group/Course. The passed
237
+ # object needs to be a hash with :name and :visible keys and values.
238
+ def add_participant_list(list)
239
+ participants_list
240
+ participants_list_name.set list[:name]
241
+ participants_list_permissions.select list[:visible]
242
+
243
+ create
244
+ end
245
+
246
+ alias add_participants_list add_participant_list
247
+
248
+ # Adds a new Content Library area to a Group/Course.
249
+ # The method requires a hash for the variable, with :name and :visible keys and values.
250
+ def add_content_list(document)
251
+ content_list
252
+ content_list_name.set document[:name]
253
+ content_list_permissions.select document[:visible]
254
+ create
255
+ end
256
+
257
+ alias add_a_content_library add_content_list
258
+ alias add_content_library add_content_list
259
+
260
+ # Adds a new Widget Area to a Group/Course. The method
261
+ # requires that the passed variable be a hash, with :name,
262
+ # :widget, and :visible keys and values.
263
+ def add_widget_page(document)
264
+ widgets
265
+ select_widget.select document[:widget]
266
+ widget_name.set document[:name]
267
+ widget_permissions.select document[:visible]
268
+ create
269
+ end
270
+
271
+ alias add_widget add_widget_page
272
+ alias add_a_widget add_widget_page
273
+ alias add_a_widget_page add_widget_page
274
+
275
+ end # AddAreasPopUp
276
+
277
+ # Page objects in the Add content dialog box
278
+ module AddContentContainer
279
+
280
+ include PageObject
281
+
282
+ # Page Objects
283
+
284
+ # Upload content tab...
285
+ link(:upload_content, :text=>"Upload content")
286
+
287
+ text_field(:file_title, :id=>"newaddcontent_upload_content_title")
288
+ text_area(:file_description, :id=>"newaddcontent_upload_content_description")
289
+ # "tags and categories" field is defined below...
290
+ select_list(:who_can_see_file, :id=>"newaddcontent_upload_content_permissions")
291
+ select_list(:file_copyright, :id=>"newaddcontent_upload_content_copyright")
292
+
293
+ # Create new document tab...
294
+ link(:create_new_document, :text=>"Create new document")
295
+
296
+ text_field(:name_document, :id=>"newaddcontent_add_document_title")
297
+ text_area(:document_description, :id=>"newaddcontent_add_document_description")
298
+ # "tags and categories" field is defined below...
299
+ select_list(:who_can_see_document, :id=>"newaddcontent_add_document_permissions")
300
+ select_list(:document_copyright, :id=>"newaddcontent_upload_content_copyright")
301
+
302
+ # Use existing content tab...
303
+ link(:all_content, :text=>"All content")
304
+ link(:add_content_my_library, :text=>"My Library")
305
+
306
+ # Add link tab...
307
+ link(:add_link, :text=>"Add link")
308
+
309
+ text_field(:paste_link_address, :id=>"newaddcontent_add_link_url")
310
+ text_field(:link_title, :id=>"newaddcontent_add_link_title")
311
+ text_area(:link_description, :id=>"newaddcontent_add_link_description")
312
+ # "tags and categories" field is defined below...
313
+
314
+ # button(:add, :text=>"Add") Must be defined with a custom method. See below...
315
+
316
+ # Collected items column...
317
+ select_list(:save_all_to, :id=>"newaddcontent_saveto")
318
+
319
+ button(:list_categories, :text=>"List categories")
320
+
321
+ button(:done_add_collected_button, :text=>"Done, add collected")
322
+
323
+ # Progress Indicator that appears while files are uploading
324
+ div(:progress_indicator, :id=>"sakai_progressindicator")
325
+
326
+ # Custom Methods...
327
+
328
+ # Clicks the "Add" button that moves items into the
329
+ # "Collected Items" list.
330
+ def add
331
+ active_content_div.button(:text=>"Add").click
332
+ sleep 0.1
333
+ self.wait_until { self.done_add_collected_button_element.enabled? }
334
+ end
335
+
336
+ # Works to enter text into any of the "Tags and Categories"
337
+ # fields on the "Add Content" dialog.
338
+ def tags_and_categories=(text)
339
+ active_content_div.text_field(:id=>/as-input-\d+/).set("#{text}\n")
340
+ self.wait_for_ajax
341
+ end
342
+
343
+ # Removes the item from the selected list.
344
+ def remove(item)
345
+ name_li(item).button(:title=>"Remove").click
346
+ self.wait_for_ajax
347
+ end
348
+
349
+ # Enters the specified text in the Search field.
350
+ # Note that the method appends a line feed on the string, so the search will
351
+ # happen immediately when it is invoked.
352
+ def search_for_content=(text)
353
+ self.text_field(:class=>"newaddcontent_existingitems_search").set("#{text}\n")
354
+ end
355
+
356
+ # Checks the checkbox for the specified item.
357
+ def check_content(item)
358
+ name_li(item).wait_until_present
359
+ name_li(item).checkbox.set
360
+ end
361
+
362
+ alias check_item check_content
363
+ alias check_document check_content
364
+
365
+ # Enters the specified filename in the file field.
366
+ #
367
+ # The method takes an optional file_path parameter.
368
+ # This allows the file_name parameter to be a variable
369
+ # distinct from the path containing the file.
370
+ def upload_file=(file_name, file_path="")
371
+ self.file_field(:name=>"fileData").wait_until_present
372
+ self.file_field(:name=>"fileData").set(file_path + file_name)
373
+ end
374
+
375
+ # Clicks the "Done, add collected" button, then waits for
376
+ # the page to refresh and any ajax calls to complete.
377
+ def done_add_collected
378
+ self.done_add_collected_button
379
+ self.progress_indicator_element.wait_while_present
380
+ end
381
+
382
+ # Private methods...
383
+ private
384
+
385
+ # A helper method for determining what div
386
+ # is currently visible.
387
+ def active_content_div
388
+ case
389
+ when self.div(:id=>"newaddcontent_upload_content_template").visible?
390
+ return self.div(:id=>"newaddcontent_upload_content_template")
391
+ when self.div(:id=>"newaddcontent_add_document_template").visible?
392
+ return self.div(:id=>"newaddcontent_add_document_template")
393
+ when self.div(:id=>"newaddcontent_add_existing_template").visible?
394
+ return self.div(:id=>"newaddcontent_add_existing_template")
395
+ when self.div(:id=>"newaddcontent_add_link_template").visible?
396
+ return self.div(:id=>"newaddcontent_add_link_template")
397
+ end
398
+ end
399
+
400
+ end # AddContentContainer
401
+
402
+ # Page Objects and Methods related to the Pop Up for Categories.
403
+ module AddRemoveCategories
404
+
405
+ include PageObject
406
+
407
+ # Page Objects
408
+
409
+ button(:save_categories, :text=>"Assign and save")
410
+ button(:dont_save, :text=>"Don't save")
411
+
412
+ # Custom Methods...
413
+
414
+ # Opens the specified category tree.
415
+ def open_tree(text)
416
+ self.link(:title=>text).parent.ins.fire_event("onclick")
417
+ end
418
+
419
+ # Checks the specified category.
420
+ def check_category(text)
421
+ if self.link(:title=>text).exists? == false
422
+ puts "\nCategory...\n#{text}\n...not found in list!\n\nPlease check for typos in your test data.\n"
423
+ end
424
+ if self.link(:title=>text).visible? == false
425
+ self.link(:title=>text).parent.parent.parent.ins.click
426
+ end
427
+ if self.link(:title=>text).parent.class_name =~ /jstree-unchecked/
428
+ self.link(:title=>text).click
429
+ end
430
+ sleep 0.3
431
+ end
432
+
433
+ # Returns an array of the categories selected in the pop-up container.
434
+ def selected_categories
435
+ list = []
436
+ self.div(:id=>"assignlocation_jstree_selected_container").lis.each do |li|
437
+ list << li.text
438
+ end
439
+ return list
440
+ end
441
+
442
+ end # AddRemoveCategories
443
+
444
+ # Page Objects and Methods related to the "Add widgets" pop-up on the Dashboard
445
+ module AddRemoveWidgets
446
+
447
+ include PageObject
448
+
449
+ # Clicks the Close button on the dialog for adding/removing widgets
450
+ # to/from the Dashboard. Returns the MyDashboard class object.
451
+ def close_add_widget
452
+ self.div(:class=>"s3d-dialog-close jqmClose").fire_event("onclick")
453
+ self.wait_for_ajax
454
+ MyDashboard.new @browser
455
+ end
456
+
457
+ # Adds all widgets to the dashboard
458
+ def add_all_widgets
459
+ array = self.div(:id=>"add_goodies_body").lis.select { |li| li.class_name == "add" }
460
+ sub_array = array.select { |li| li.visible? }
461
+ sub_array.each do |li|
462
+ li.button(:text=>"Add").click
463
+ self.wait_for_ajax
464
+ end
465
+ close_add_widget
466
+ end
467
+
468
+ # Removes all widgets from the dashboard
469
+ def remove_all_widgets
470
+ array = self.div(:id=>"add_goodies_body").lis.select { |li| li.class_name == "remove" }
471
+ sub_array = array.select { |li| li.visible? }
472
+ sub_array.each do |li|
473
+ li.button(:text=>"Remove").click
474
+ self.wait_for_ajax
475
+ end
476
+ close_add_widget
477
+ end
478
+
479
+ # Clicks the "Add" button for the specified widget
480
+ def add_widget(name)
481
+ self.div(:id=>"add_goodies_body").li(:text=>/#{Regexp.escape(name)}/).button.click
482
+ end
483
+
484
+ # Unchecks the checkbox for the specified widget.
485
+ def remove_widget(name)
486
+ self.div(:id=>"add_goodies_body").li(:text=>/#{Regexp.escape(name)}/, :id=>/_remove_/).button.click
487
+ end
488
+
489
+ end # AddRemoveWidgets
490
+
491
+ # Page Objects and Methods related to the Pop Up Dialog for Contacts
492
+ module AddToContactsPopUp
493
+
494
+ include PageObject
495
+
496
+ # Page Object
497
+ button(:invite_button, :text=>"Invite")
498
+ button(:dont_invite, :text=>"Don't Invite")
499
+
500
+ text_area(:personal_note, :id=>"addtocontacts_form_personalnote")
501
+
502
+ checkbox(:is_my_classmate, :value=>"Classmate")
503
+ checkbox(:is_my_supervisor, :value=>"Supervisor")
504
+ checkbox(:is_being_supervised_by_me, :value=>"Supervised")
505
+ checkbox(:is_my_lecturer, :value=>"Lecturer")
506
+ checkbox(:is_my_student, :value=>"Student")
507
+ checkbox(:is_my_colleague, :value=>"Colleague")
508
+ checkbox(:is_my_college_mate, :value=>"College Mate")
509
+ checkbox(:shares_an_interest_with_me, :value=>"Shares Interests")
510
+
511
+ # Custom Methods...
512
+
513
+ # Clicks the Invite button then waits for ajax calls to
514
+ # calm down.
515
+ def invite
516
+ self.invite_button
517
+ sleep 0.5
518
+ self.wait_for_ajax
519
+ end
520
+
521
+ end # AddToContactsPopUp
522
+
523
+ #
524
+ module AddToGroupsPopUp
525
+
526
+ include PageObject
527
+
528
+
529
+
530
+ end # AddToGroupsPopUp
531
+
532
+ #
533
+ module AppearancePopUp
534
+
535
+ include PageObject
536
+
537
+ # Page Object
538
+
539
+ # Custom Methods...
540
+
541
+ end
542
+
543
+ # Page Objects and Custom Methods related to the "Select your profile picture" pop-up dialog
544
+ module ChangePicturePopUp
545
+
546
+ include PageObject
547
+
548
+ # Page Objects
549
+
550
+ h1(:pop_up_title, :class=>"s3d-dialog-header")
551
+ file_field(:pic_file, :id=>"profilepicture")
552
+ button(:upload, :id=>"profile_upload")
553
+ button(:save, :id=>"save_new_selection")
554
+ button(:cancel, :text=>"Cancel")
555
+ div(:error_message, :id=>"changepic_nofile_error")
556
+ image(:thumbnail, :id=>"thumbnail_img")
557
+
558
+ # Custom Methods...
559
+
560
+ # Uploads the specified file name for the Avatar photo.
561
+ # The method takes an optional file_path parameter that allows
562
+ # the file_name and its file_path to be distinct variables.
563
+ def upload_a_new_picture(file_name, file_path="")
564
+ self.back_to_top
565
+ #puts(File.expand_path(file_path + file_name)
566
+ self.pic_file_element.when_visible { self.pic_file=(file_path + file_name) }
567
+ self.upload
568
+ self.linger_for_ajax(5)
569
+ end
570
+
571
+ # Clicks the Save button for the Change Picture Pop Up.
572
+ def save_new_selection
573
+ self.save_element.when_visible { self.save }
574
+ self.wait_for_ajax
575
+ end
576
+
577
+ def thumbnail_source
578
+ self.thumbnail_element.src
579
+ end
580
+
581
+ end
582
+
583
+ #
584
+ module CommentsPopUp
585
+
586
+ include PageObject
587
+
588
+ end
589
+
590
+ # Objects in the Pop Up dialog for setting viewing permissions for Content
591
+ module ContentPermissionsPopUp
592
+
593
+ include PageObject
594
+
595
+ # Page Objects
596
+ radio_button(:anyone_public, :id=>"contentpermissions_see_public")
597
+ radio_button(:logged_in_people_only, :id=>"contentpermissions_see_everyone")
598
+ radio_button(:private_to_the_shared_with_list, :id=>"contentpermissions_see_private")
599
+ select_list(:content_permissions, :id=>"contentpermissions_members_autosuggest_permissions")
600
+ text_area(:sharing_message, :id=>"contentpermissions_members_autosuggest_text")
601
+ button(:share_button, :id=>"contentpermissions_members_autosuggest_sharebutton")
602
+ button(:save_and_close_button, :id=>"contentpermissions_apply_permissions")
603
+ button(:cancel, :class=>"s3d-link-button jqmClose s3d-bold")
604
+
605
+ # Custom Methods...
606
+
607
+ # Enters the specified name in the "Who can edit it or
608
+ # who is it associated with?" search field. Then clicks
609
+ # on the first item in the search results menu--which means
610
+ # that this method assumes the search will be successful
611
+ # and the first item listed is the desired item to select.
612
+ def share_with=(name)
613
+ self.text_field(:id=>/contentpermissionscontainer\d+/).set name
614
+ sleep 0.6
615
+ self.wait_for_ajax
616
+ self.div(:class=>"as-results").li(:id=>"as-result-item-0").fire_event "onclick"
617
+ self.wait_for_ajax
618
+ end
619
+
620
+ # Clicks the "Save and close" button then waits for all ajax calls
621
+ # to finish
622
+ def save_and_close
623
+ save_and_close_button
624
+ self.wait_for_ajax
625
+ end
626
+
627
+ # Clicks the "Share" button and waits for the ajax calls to finish.
628
+ def share
629
+ self.button(:id=>"contentpermissions_members_autosuggest_sharebutton").flash
630
+ self.button(:id=>"contentpermissions_members_autosuggest_sharebutton").click
631
+ self.wait_for_ajax
632
+ end
633
+
634
+ end
635
+
636
+ # Methods for the Pop-up dialog that appears when you want to remove
637
+ # content from Libraries.
638
+ module DeleteContentPopUp
639
+
640
+ include PageObject
641
+
642
+ button(:remove_from_library_button, :text=>"Remove from library")
643
+ button(:delete_from_the_system_button, :text=>"Delete from the system")
644
+
645
+ # Clicks the cancel button on the Pop-up and waits for the Ajax calls to finish
646
+ def cancel
647
+ begin
648
+ self.div(:id=>"deletecontent_dialog").button(:text=>"Cancel").click
649
+ rescue
650
+ self.button(:text=>"Cancel").click
651
+ end
652
+ self.wait_for_ajax
653
+ end
654
+ alias cancel_deleting_content cancel
655
+
656
+ # Clicks the 'Remove from library' button and
657
+ # waits for the Ajax calls to complete.
658
+ def remove_from_library
659
+ self.remove_from_library_button
660
+ self.remove_from_library_button_element.wait_while_present
661
+ sleep 1.5
662
+ self.wait_for_ajax
663
+ end
664
+
665
+ # Clicks the 'Delete from the system' button and waits for
666
+ # The Ajax calls to complete.
667
+ def delete_from_the_system
668
+ self.delete_from_the_system_button
669
+ sleep 2
670
+ self.wait_for_ajax
671
+ end
672
+
673
+ # TODO - Define this method
674
+ def remove_from_the_system_anyway
675
+
676
+ end
677
+
678
+ # TODO - Define this method
679
+ def remove_from_this_library_only
680
+
681
+ end
682
+
683
+ end
684
+
685
+ # Methods for the "Delete" Pop-up dialog.
686
+ module DeletePagePopUp
687
+
688
+ include PageObject
689
+
690
+ # Page Objects
691
+ button(:delete_button, :id=>"lhnavigation_delete_confirm")
692
+ button(:dont_delete_button, :class=>"s3d-link-button s3d-bold jqmClose")
693
+
694
+ # Custom Methods
695
+
696
+ # Clicks the Delete button, then waits for any ajax calls to finish.
697
+ def delete
698
+ self.delete_button
699
+ self.wait_for_ajax
700
+ end
701
+
702
+ # Clicks the "Don't delete" button, then waits for any Ajax calls
703
+ # to complete
704
+ def dont_delete
705
+ self.dont_delete_button
706
+ self.wait_for_ajax
707
+ end
708
+
709
+ end
710
+
711
+ #
712
+ module DiscussionPopUp
713
+
714
+ include PageObject
715
+
716
+ # Page Objects
717
+
718
+ # Custom Methods
719
+
720
+ end
721
+
722
+ #
723
+ module ExportAsTemplate
724
+
725
+ include PageObject
726
+
727
+ # Page Objects
728
+
729
+ # Custom Methods
730
+
731
+ end
732
+
733
+ #
734
+ module FilesAndDocsPopUp
735
+
736
+ include PageObject
737
+
738
+ # Page Objects
739
+ link(:display_settings, :id=>"embedcontent_tab_display")
740
+ text_field(:name, :class=>"as-input")
741
+ button(:dont_add_button, :class=>"s3d-link-button s3d-bold embedcontent_dont_add")
742
+
743
+ # Custom Methods...
744
+
745
+ # Clicks the "Don't add" button, then waits for any Ajax calls
746
+ # to complete
747
+ def dont_add
748
+ self.dont_add_button
749
+ self.wait_for_ajax
750
+ end
751
+
752
+ end
753
+
754
+ #
755
+ module GoogleGadgetPopUp
756
+
757
+ include PageObject
758
+
759
+ # Page Objects
760
+
761
+ # Custom Methods
762
+
763
+ end
764
+
765
+ # Page Objects and Methods related to the Pop Up that appears for modifying
766
+ # the settings for the Google Maps Widget.
767
+ module GoogleMapsPopUp
768
+
769
+ include PageObject
770
+
771
+ # Page Objects
772
+ text_field(:location, :id=>"googlemaps_input_text_location")
773
+ button(:search_button, :id=>"googlemaps_button_search")
774
+ button(:dont_add, :id=>"googlemaps_cancel")
775
+ button(:add_map, :id=>"googlemaps_save")
776
+ radio_button(:large, :id=>"googlemaps_radio_large")
777
+ radio_button(:small, :id=>"googlemaps_radio_small")
778
+
779
+ # Custom Methods...
780
+
781
+ # Clicks the "Search" button, then waits for 2.5 seconds.
782
+ def search
783
+ self.search_button
784
+ sleep 2.5
785
+ end
786
+
787
+ end
788
+
789
+ #
790
+ module InlineContentPopUp
791
+
792
+ include PageObject
793
+
794
+ # Page Objects
795
+
796
+ # Custom Methods
797
+
798
+ end
799
+
800
+ #
801
+ module LeaveWorldPopUp
802
+
803
+ include PageObject
804
+
805
+ # Clicks the "Yes, Apply" button and waits for
806
+ # Ajax calls to finish
807
+ def yes_apply
808
+ self.button(:id=>"mymemberships_delete_membership_confirm").click
809
+ sleep 1.5
810
+ self.linger_for_ajax(2)
811
+ end
812
+
813
+ # Clicks the "Cancel" button and waits for Ajax
814
+ # calls to complete
815
+ def cancel
816
+ self.div(:id=>"mymemberships_delete_membership_dialog").button(:class=>"s3d-link-button s3d-bold jqmClose").click
817
+ self.linger_for_ajax(1)
818
+ end
819
+
820
+ end
821
+
822
+ # Page Objects and Methods related to the Pop Up that allows modifying a
823
+ # Group's/Course's participants.
824
+ module ManageParticipants
825
+
826
+ include PageObject
827
+
828
+ # Page Objects
829
+ checkbox(:add_all_contacts, :id=>"addpeople_select_all_contacts")
830
+ checkbox(:remove_all_contacts, :id=>"addpeople_select_all_selected_contacts")
831
+ button(:remove_selected, :text=>"Remove selected")
832
+ button(:save, :class=>"s3d-button s3d-overlay-action-button addpeople_finish_adding")
833
+ button(:cancel, :class=>"s3d-link-button jqmClose s3d-bold")
834
+ select_list(:role_for_selected_members, :id=>"addpeople_selected_all_permissions")
835
+
836
+ # Custom Methods
837
+
838
+ # Checks the specified contact for adding.
839
+ def add_contact(contact)
840
+ self.li(:text=>contact).checkbox(:class=>"addpeople_checkbox").set
841
+ end
842
+
843
+ alias check_contact add_contact
844
+ alias add_participant add_contact
845
+
846
+ # Adds the specified contact to the members list (does not save, though).
847
+ # This method assumes the specified name will be found in the search.
848
+ # It makes no allowances for failing to find the target user/member.
849
+ def add_by_search(name)
850
+ name.split("", 2).each do |letter|
851
+ self.text_field(:id=>/addpeople/, :class=>"as-input").focus
852
+ self.text_field(:id=>/addpeople/, :class=>"as-input").send_keys(letter)
853
+ self.wait_until { self.div(:id=>/^as-results-/).visible? }
854
+ if self.li(:text=>/#{Regexp.escape(name)}/, :id=>/as-result-item-\d+/).present?
855
+ self.li(:text=>/#{Regexp.escape(name)}/, :id=>/as-result-item-\d+/).click
856
+ break
857
+ end
858
+ end
859
+ end
860
+ alias add_contact_by_search add_by_search
861
+ alias add_participant_by_search add_by_search
862
+ alias search_and_add_participant add_by_search
863
+ alias add_by_search= add_by_search
864
+
865
+ alias done_apply_settings save
866
+ alias apply_and_save save
867
+
868
+ alias dont_apply cancel
869
+
870
+ # Checks to remove the specified contact.
871
+ def check_remove_contact(contact)
872
+ self.div(:id=>"addpeople_selected_contacts_container").link(:text=>contact).parent.checkbox.set
873
+ end
874
+
875
+ # Unchecks the remove checkbox for the specified contact
876
+ def uncheck_remove_contact(contact)
877
+ self.div(:id=>"addpeople_selected_contacts_container").link(:text=>contact).parent.checkbox.clear
878
+ end
879
+
880
+ # For the specified contact, updates to the specified role.fd
881
+ def set_role_for(contact, role)
882
+ self.div(:id=>"addpeople_selected_contacts_container").link(:text=>contact).parent.select(:class=>"addpeople_selected_permissions").select(role)
883
+ end
884
+
885
+ end
886
+
887
+ #
888
+ module OurAgreementPopUp
889
+
890
+ include PageObject
891
+
892
+ # Page Objects
893
+ button(:no_button, :id=>"acceptterms_action_dont_accept")
894
+ button(:yes_button, :id=>"acceptterms_action_accept")
895
+
896
+ # Custom Methods
897
+
898
+ # Clicks the "No, please log me out" button, then returns the
899
+ # LoginPage class object.
900
+ def no_please_log_me_out
901
+
902
+ end
903
+
904
+ # Clicks the "Yes, I accept" button, then returns the MyDashboard
905
+ # class object.
906
+ def yes_I_accept
907
+ self.yes_button
908
+ self.wait_for_ajax
909
+ MyDashboard.new @browser
910
+ end
911
+
912
+ end
913
+
914
+ #
915
+ module OwnerInfoPopUp
916
+
917
+ include PageObject
918
+
919
+ # Page Objects
920
+ button(:close_owner_info, :id=>"personinfo_close_button")
921
+
922
+ # Custom Methods
923
+
924
+ # Clicks the button to send a message to the owner.
925
+ def message_owner
926
+ self.button(:text=>"Message").click
927
+ self.wait_for_ajax
928
+ self.class.class_eval { include SendMessagePopUp }
929
+ end
930
+
931
+ # Clicks the button to add the owner to the user's contacts list
932
+ def add_to_contacts
933
+ self.button(:text=>"Add to contacts").click
934
+ self.wait_for_ajax
935
+ self.class.class_eval { include AddToContactsPopUp }
936
+ end
937
+
938
+ # Clicks the link to go to the owner's profile page. Returns the
939
+ # ViewPerson class object.
940
+ def view_owner_profile
941
+ self.span(:id=>"personinfo_user_name").link.click
942
+ sleep 2
943
+ ViewPerson.new @browser
944
+ end
945
+
946
+ end
947
+
948
+ # The Pending Requests Pop-Up for Groups/Courses/Projects
949
+ module PendingRequestsPopUp
950
+
951
+ include PageObject
952
+
953
+ # Page Objects
954
+ button(:done_button, :text=>"Done")
955
+
956
+ # Custom Methods...
957
+
958
+ # Clicks the "Add as a member" link for the
959
+ # specified user.
960
+ def add_as_member(name)
961
+ self.div(:class=>"fl-force-left joinrequests_details",:text=>/#{Regexp.escape(name)}/).button(:text=>"Add as a member").click
962
+ self.linger_for_ajax(3)
963
+ end
964
+ alias add_as_a_member add_as_member
965
+
966
+ # Clicks the "ignore" button for the specified
967
+ # user
968
+ def ignore(name)
969
+ self.div(:class=>"fl-force-left joinrequests_details",:text=>/#{Regexp.escape(name)}/).button(:text=>"Ignore").click
970
+ self.linger_for_ajax(3)
971
+ end
972
+
973
+ def done
974
+ self.done_button
975
+ self.linger_for_ajax(3)
976
+ end
977
+
978
+ end
979
+
980
+ # Objects and Methods for the Area Permissions Pop Up dialog
981
+ module PermissionsPopUp
982
+
983
+ include PageObject
984
+
985
+ # Page Objects
986
+ h1(:permissions_header, :class=>"s3d-dialog-header")
987
+ radio_button(:anyone_public, :id=>"areapermissions_see_public")
988
+ radio_button(:anyone_logged_in, :id=>"areapermissions_see_loggedin")
989
+ radio_button(:specific_roles_only, :id=>"areapermissions_see_private")
990
+
991
+ checkbox(:lecturers_can_see, :id=>"areapermissions_see_lecturer")
992
+ checkbox(:teaching_assistants_can_see, :id=>"areapermissions_see_ta")
993
+ checkbox(:students_can_see, :id=>"areapermissions_see_student")
994
+
995
+ checkbox(:lecturers_can_edit, :id=>"areapermissions_edit_lecturer")
996
+ checkbox(:teaching_assistants_can_edit, :id=>"areapermissions_edit_ta")
997
+ checkbox(:students_can_edit, :id=>"areapermissions_edit_student")
998
+
999
+ button(:cancel_button, :class=>"s3d-link-button jqmClose s3d-bold")
1000
+ button(:apply_permissions_button, :id=>"areapermissions_apply_permissions")
1001
+
1002
+ # Custom Methods
1003
+
1004
+ # Clicks the "Apply permissions" button
1005
+ def apply_permissions
1006
+ self.apply_permissions_button
1007
+ sleep 0.3
1008
+ #wait_for_ajax(2)
1009
+ end
1010
+
1011
+ # Clicks the "Cancel" button
1012
+ def cancel
1013
+ self.cancel_button
1014
+ self.linger_for_ajax(2)
1015
+ end
1016
+
1017
+ end
1018
+
1019
+ # Methods and objects for the Profile Permissions Pop Up--that appears when
1020
+ # you select the Permissions item for the "My Profile" pages.
1021
+ module ProfilePermissionsPopUp
1022
+
1023
+ include PageObject
1024
+
1025
+ select_list(:can_be_seen_by, :id=>"userpermissions_area_general_visibility")
1026
+ button(:apply_permissions_button, :id=>"userpermissions_apply_permissions")
1027
+
1028
+ # Clicks the "Apply permissions" button
1029
+ def apply_permissions
1030
+ self.apply_permissions_button
1031
+ self.linger_for_ajax
1032
+ end
1033
+
1034
+ # Clicks the "Cancel" button
1035
+ def cancel
1036
+ self.div(:id=>"userpermissions_container").button(:class=>"s3d-link-button jqmClose s3d-bold").click
1037
+ end
1038
+
1039
+ end
1040
+
1041
+ #
1042
+ module RemoteContentPopUp
1043
+
1044
+ include PageObject
1045
+
1046
+ end
1047
+
1048
+ #
1049
+ module RemoveContactsPopUp
1050
+
1051
+ include PageObject
1052
+
1053
+ # Page Objects
1054
+ button(:remove_contact_button, :id=>"contacts_delete_contact_confirm")
1055
+ button(:cancel_button, :class=>"s3d-link-button s3d-bold jqmClose")
1056
+
1057
+ # Custom Methods...
1058
+
1059
+ # Clicks the Remove contact button and waits for the Ajax calls
1060
+ # to complete.
1061
+ def remove_contact
1062
+ self.remove_contact_button
1063
+ sleep 0.5
1064
+ self.linger_for_ajax
1065
+ end
1066
+
1067
+ end
1068
+
1069
+ #
1070
+ module RSSFeedPopUp
1071
+
1072
+ include PageObject
1073
+
1074
+ end
1075
+
1076
+ # Methods related to the Save Content Pop Up dialog.
1077
+ module SaveContentPopUp
1078
+
1079
+ include PageObject
1080
+
1081
+ select_list(:saving_to, :id=>"savecontent_select")
1082
+ button(:add_button, :id=>"savecontent_save", :text=>"Add") # Don't use this method for clicking the button. Use the method below.
1083
+ button(:cancel_button, :class=>"savecontent_close s3d-link-button s3d-bold") # Don't use this method for clicking the button. Use the method below.
1084
+
1085
+ # Clicks the Add button and waits for Ajax calls to finish
1086
+ def add
1087
+ self.add_button
1088
+ self.linger_for_ajax
1089
+ end
1090
+
1091
+ # Clicks the Cancel button and waits for Ajax calls to finish
1092
+ def cancel
1093
+ self.cancel_button
1094
+ self.linger_for_ajax
1095
+ end
1096
+
1097
+ end
1098
+
1099
+ # The Email message fields in My Messages and the pop up dialog
1100
+ # that appears when in the Worlds context
1101
+ # (or when you click the little envelop icon in lists of People).
1102
+ module SendMessagePopUp
1103
+
1104
+ include PageObject
1105
+
1106
+ list_item(:no_results, :class=>"as-message")
1107
+
1108
+ # The "See all" page element definition.
1109
+ def see_all_element
1110
+ current_div.link(:id=>"inbox_back_to_messages")
1111
+ end
1112
+
1113
+ # Clicks the "See all" element on the page.
1114
+ def see_all
1115
+ see_all_element.click
1116
+ end
1117
+
1118
+ # Removes the recipient from the To list for the email by
1119
+ # clicking on the item's "x" button.
1120
+ def remove_recipient(name)
1121
+ name_li(name).link(:text=>"×").click
1122
+ end
1123
+
1124
+ # Returns an array containing the listed message recipients
1125
+ def message_recipients
1126
+ recipients = []
1127
+ self.lis(:id=>/as-selection-/).each do |li|
1128
+ string = li.text
1129
+ string.gsub!("×\n","")
1130
+ recipients << string
1131
+ end
1132
+ return recipients
1133
+ end
1134
+
1135
+ # Enters the specified text string into the
1136
+ # "Send this message to" text box, then clicks
1137
+ # The matching item in the results list box.
1138
+ def send_this_message_to=(name)
1139
+ name.split("", 4).each do |letter|
1140
+ current_div.text_field(:id=>"sendmessage_to_autoSuggest", :class=>"as-input").focus
1141
+ current_div.text_field(:id=>"sendmessage_to_autoSuggest", :class=>"as-input").send_keys(letter)
1142
+ self.wait_until { self.div(:id=>"as-results-sendmessage_to_autoSuggest").visible? }
1143
+ if self.li(:text=>/#{Regexp.escape(name)}/, :id=>/as-result-item-\d+/).present?
1144
+ self.li(:text=>/#{Regexp.escape(name)}/, :id=>/as-result-item-\d+/).click
1145
+ break
1146
+ end
1147
+ end
1148
+ end
1149
+
1150
+ # The "Subject" text field page element definition.
1151
+ def subject_element
1152
+ current_div.text_field(:id=>"comp-subject")
1153
+ end
1154
+
1155
+ # Enters the specified text string into the
1156
+ # "Subject" field
1157
+ def subject=(text)
1158
+ subject_element.set text
1159
+ end
1160
+
1161
+ # The "Body" text area element for the message.
1162
+ def body_element
1163
+ current_div.textarea(:id=>"comp-body")
1164
+ end
1165
+
1166
+ # Enters the specified text string into the Body
1167
+ # field.
1168
+ def body=(text)
1169
+ body_element.set text
1170
+ end
1171
+
1172
+ # The "Send message" button element on the page.
1173
+ def send_message_element
1174
+ current_div.button(:id=>"send_message")
1175
+ end
1176
+
1177
+ # Clicks the "Send message" button
1178
+ def send_message
1179
+ send_message_element.click
1180
+ self.wait_for_ajax
1181
+ end
1182
+
1183
+ # Clicks the "Don't send" button
1184
+ def dont_send
1185
+ current_div.button(:id=>"send_message_cancel").click
1186
+ self.linger_for_ajax(2)
1187
+ end
1188
+
1189
+ # Clicks the link for accepting a join request inside a Manager's join
1190
+ # request email
1191
+ def accept_join_request
1192
+ self.link(:text=>/=joinrequests/).click
1193
+ # currently this opens a page in a new tab. So it's best not to use it.
1194
+ # UGLY!!!
1195
+ # TODO - Refactor this ugly method. They may change the behavior so that a new tab isn't opened
1196
+ end
1197
+
1198
+ # Private Methods
1199
+ private
1200
+
1201
+ def current_div
1202
+ begin
1203
+ self.div(:id=>"sendmessage_dialog_box")
1204
+ #return active_div
1205
+ rescue
1206
+ begin
1207
+ return active_div
1208
+ rescue NoMethodError
1209
+ return self
1210
+ end
1211
+ end
1212
+ end
1213
+
1214
+ end
1215
+
1216
+ # The Settings Pop Up dialog for Courses/Groups/Research...
1217
+ module SettingsPopUp
1218
+
1219
+ include PageObject
1220
+
1221
+ text_field(:title, :id=>"worldsettings_title")
1222
+ text_area(:description, :id=>"worldsettings_description")
1223
+ text_area(:tags, :id=>"worldsettings_tags")
1224
+ select_list(:can_be_discovered_by, :id=>"worldsettings_can_be_found_in")
1225
+ select_list(:membership, :id=>"worldsettings_membership")
1226
+
1227
+ button(:apply_settings_button, :id=>"worldsettings_apply_button")
1228
+
1229
+ # Clicks the "Apply settings" button and waits for Ajax calls to complete.
1230
+ def apply_settings
1231
+ self.apply_settings_button
1232
+ self.wait_for_ajax
1233
+ end
1234
+
1235
+ end
1236
+
1237
+ # Methods related to the Pop Up for Sharing Content with others.
1238
+ module ShareWithPopUp
1239
+
1240
+ include PageObject
1241
+
1242
+ text_field(:share_with_field, :id=>/newsharecontentcontainer\d+/)
1243
+
1244
+ # Clicks the arrow for adding a custom message to the share.
1245
+ def add_a_message
1246
+ self.span(:id=>"newsharecontent_message_arrow").fire_event('onclick')
1247
+ end
1248
+
1249
+ text_area(:message_text, :id=>"newsharecontent_message")
1250
+
1251
+ button(:share, :id=>"sharecontent_send_button")
1252
+ button(:cancel, :id=>"newsharecontent_cancel")
1253
+
1254
+ # Enters the specified name value into the "Share with" field, a character
1255
+ # at a time, then waits for the search results to return the expected name.
1256
+ # When the name is found in the results list, it gets clicked on.
1257
+ def share_with=(name)
1258
+
1259
+ name.split("", 5).each do |letter|
1260
+ self.share_with_field_element.focus
1261
+ self.share_with_field_element.send_keys(letter)
1262
+ self.wait_until { self.ul(:class=>"as-list").present? }
1263
+ if self.li(:text=>/#{Regexp.escape(name)}/, :id=>/as-result-item-\d+/).present?
1264
+ @browser.li(:text=>/#{Regexp.escape(name)}/, :id=>/as-result-item-\d+/).click
1265
+ break
1266
+ end
1267
+ end
1268
+
1269
+ end
1270
+
1271
+ # Gonna add the social network validations later
1272
+
1273
+ end