Class: Resources
- Inherits:
-
ResourcesBase
- Object
- PageFactory
- BasePage
- ResourcesBase
- Resources
- Defined in:
- lib/sambal-cle/page_objects/resources.rb
Overview
Resources page for a given Site, in the Course Tools menu
Instance Method Summary collapse
-
#attach_a_copy(file_name) ⇒ Object
Clicks the “Attach a copy” link for the specified file.
-
#continue ⇒ Object
Clicks the Continue button.
- #create_html_page_in(folder_name) ⇒ Object
-
#create_subfolders_in(folder_name) ⇒ Object
Clicks the Create Folders menu item in the Add menu of the specified folder.
- #edit_content(html_page_name) ⇒ Object
- #edit_details(name) ⇒ Object
-
#file_names ⇒ Object
Returns an array of the file names currently listed on the page.
-
#folder_names ⇒ Object
Returns an array of the displayed folder names.
- #open_actions_menu(name) ⇒ Object
- #open_add_menu(folder_name) ⇒ Object
-
#upload_file(filename, filepath = "") ⇒ Object
Enters the specified file into the file field name (assuming it’s in the data/sakai-cle-test-api folder or a subfolder therein).
-
#upload_files_to_folder(folder_name) ⇒ Object
Clicks the Add Menu for the specified folder, then selects the Upload Files command in the menu that appears.
-
#upload_local_file(filename, filepath = "") ⇒ Object
Enters the specified file into the file field name (assuming it’s in the data/sakai-cle-test-api folder or a subfolder therein).
-
#upload_multiple_files_to_folder(folder, file_array, file_path = "") ⇒ Object
Takes the specified array object containing pointers to local file resources, then uploads those files to the folder specified, checks if they all uploaded properly and if not, re-tries the ones that failed the first time.
Methods inherited from ResourcesBase
Methods inherited from BasePage
basic_page_elements, button, damballa, frame_element, link
Instance Method Details
#attach_a_copy(file_name) ⇒ Object
Clicks the “Attach a copy” link for the specified file. If an alert box appears, the method will call itself again. Note that this can lead to an infinite loop. Will need to fix later.
134 135 136 137 138 139 140 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 134 def attach_a_copy(file_name) files_table.row(:text=>/#{Regexp.escape(file_name)}/).link(:href=>/doAttachitem/).click if frm.div(:class=>"alertMessage").exist? sleep 1 attach_a_copy(file_name) # TODO - This can loop infinitely end end |
#continue ⇒ Object
Clicks the Continue button
194 195 196 197 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 194 def continue frm.div(:class=>"highlightPanel").span(:id=>"submitnotifxxx").wait_while_present frm.(:value=>"Continue").click end |
#create_html_page_in(folder_name) ⇒ Object
188 189 190 191 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 188 def create_html_page_in(folder_name) (folder_name) files_table.row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Create HTML Page").click end |
#create_subfolders_in(folder_name) ⇒ Object
Clicks the Create Folders menu item in the Add menu of the specified folder.
183 184 185 186 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 183 def create_subfolders_in(folder_name) (folder_name) files_table.row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Create Folders").click end |
#edit_content(html_page_name) ⇒ Object
176 177 178 179 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 176 def edit_content(html_page_name) (html_page_name) files_table.row(:text=>/#{Regexp.escape(html_page_name)}/).link(:text=>"Edit Content").click end |
#edit_details(name) ⇒ Object
171 172 173 174 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 171 def edit_details(name) (name) files_table.row(:text=>/#{Regexp.escape(name)}/).link(:text=>"Edit Details").click end |
#file_names ⇒ Object
Returns an array of the file names currently listed on the page.
It excludes folder names.
84 85 86 87 88 89 90 91 92 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 84 def file_names names = [] files_table.rows.each do |row| next if row.td(:class=>"specialLink").exist? == false next if row.td(:class=>"specialLink").link(:title=>"Folder").exist? names << row.td(:class=>"specialLink").link(:href=>/access.content/, :index=>1).text end names end |
#folder_names ⇒ Object
Returns an array of the displayed folder names.
70 71 72 73 74 75 76 77 78 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 70 def folder_names names = [] files_table.rows.each do |row| next if row.td(:class=>"specialLink").exist? == false next if row.td(:class=>"specialLink").link(:title=>"Folder").exist? == false names << row.td(:class=>"specialLink").link(:title=>"Folder").text end names end |
#open_actions_menu(name) ⇒ Object
203 204 205 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 203 def (name) files_table.row(:text=>/#{Regexp.escape(name)}/).li(:text=>/Action/, :class=>"menuOpen").fire_event("onclick") end |
#open_add_menu(folder_name) ⇒ Object
199 200 201 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 199 def (folder_name) files_table.row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Start Add Menu").fire_event("onfocus") end |
#upload_file(filename, filepath = "") ⇒ Object
Enters the specified file into the file field name (assuming it’s in the data/sakai-cle-test-api folder or a subfolder therein)
97 98 99 100 101 102 103 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 97 def upload_file(filename, filepath="") upload_file_field.set(filepath + filename) if frm.div(:class=>"alertMessage").exist? sleep 2 upload_file(filename) end end |
#upload_files_to_folder(folder_name) ⇒ Object
Clicks the Add Menu for the specified folder, then selects the Upload Files command in the menu that appears.
121 122 123 124 125 126 127 128 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 121 def upload_files_to_folder(folder_name) if frm.li(:text=>/A/, :class=>"menuOpen").exist? files_table.row(:text=>/#{Regexp.escape(folder_name)}/).li(:text=>/A/, :class=>"menuOpen").fire_event("onclick") else files_table.row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Start Add Menu").fire_event("onfocus") end files_table.row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Upload Files").click end |
#upload_local_file(filename, filepath = "") ⇒ Object
Enters the specified file into the file field name (assuming it’s in the data/sakai-cle-test-api folder or a subfolder therein)
Use this method ONLY for instances where there’s a file field on the page with an “upload” id.
110 111 112 113 114 115 116 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 110 def upload_local_file(filename, filepath="") upload_file_field.set(filepath + filename) if frm.div(:class=>"alertMessage").exist? sleep 2 upload_local_file(filename) end end |
#upload_multiple_files_to_folder(folder, file_array, file_path = "") ⇒ Object
Takes the specified array object containing pointers to local file resources, then uploads those files to the folder specified, checks if they all uploaded properly and if not, re-tries the ones that failed the first time.
Finally, it re-instantiates the appropriate page class. Note that it expects all files to be located in the same folder (can be in subfolders of that folder).
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/sambal-cle/page_objects/resources.rb', line 149 def upload_multiple_files_to_folder(folder, file_array, file_path="") upload = upload_files_to_folder folder file_array.each do |file| upload.file_to_upload(file, file_path) upload.add_another_file end resources = upload.upload_files_now file_array.each do |file| file =~ /(?<=\/).+/ # puts $~.to_s # For debugging purposes unless resources.file_names.include?($~.to_s) upload_files = resources.upload_files_to_folder(folder) upload_files.file_to_upload(file, file_path) upload_files.upload_files_now end end end |