Class: AttachPageTools
- Inherits:
-
Object
- Object
- AttachPageTools
- Defined in:
- lib/sakai-oae-test-api/cle_frame_classes.rb
Direct Known Subclasses
Constant Summary collapse
- @@classes =
{ :this=>"Superclassdummy", :parent=>"Superclassdummy" }
Instance Method Summary collapse
-
#access_level(filename) ⇒ Object
Gets the value of the access level cell for the specified file.
-
#add ⇒ Object
Clicks the Add button next to the URL field.
-
#attach_a_copy(file_name) ⇒ Object
Clicks the “Attach a copy” link for the specified file, then reinstantiates the Class.
-
#continue ⇒ Object
Clicks the Continue button then decides which page class to instantiate based on the page that appears.
-
#create_subfolders_in(folder_name) ⇒ Object
Clicks the Create Folders menu item in the Add menu of the specified folder.
- #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.
-
#go_to_folder(foldername) ⇒ Object
Clicks on the specified folder name, which should open the folder contents on a refreshed page.
-
#items_to_attach ⇒ Object
Returns an array containing the list of items that are slated to be attached.
-
#move ⇒ Object
Clicks the Move button.
-
#open_folder(foldername) ⇒ Object
Clicks on the specified folder image, which will open the folder tree and remain on the page.
-
#remove ⇒ Object
Clicks the Remove button.
-
#remove_item(file_name) ⇒ Object
Clicks the remove link for the specified item in the attachment list.
-
#select_file(filename) ⇒ Object
Clicks the Select button next to the specified file.
-
#show_other_sites ⇒ Object
Clicks the Show Other Sites link.
-
#upload_file(filename, file_path = "") ⇒ Object
Enters the specified file into the file field name.
-
#upload_file_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_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_multiple_files_to_folder(folder, file_array) ⇒ 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.
-
#url=(url_string) ⇒ Object
Sets the URL field to the specified value.
-
#what_is_parent? ⇒ Boolean
Use this for debugging purposes only…
Instance Method Details
#access_level(filename) ⇒ Object
Gets the value of the access level cell for the specified file.
2028 2029 2030 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2028 def access_level(filename) frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(filename)}/)[6].text end |
#add ⇒ Object
Clicks the Add button next to the URL field.
2022 2023 2024 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2022 def add frm.(:value=>"Add").click end |
#attach_a_copy(file_name) ⇒ Object
Clicks the “Attach a copy” link for the specified file, then reinstantiates the Class. 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.
2075 2076 2077 2078 2079 2080 2081 2082 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2075 def attach_a_copy(file_name) frm.table(:class=>/listHier lines/).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 instantiate_class(:this) end |
#continue ⇒ Object
Clicks the Continue button then decides which page class to instantiate based on the page that appears. This is going to need to be fixed.
2124 2125 2126 2127 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2124 def continue frm.div(:class=>"highlightPanel").span(:id=>"submitnotifxxx").wait_while_present frm.(:value=>"Continue").click end |
#create_subfolders_in(folder_name) ⇒ Object
Clicks the Create Folders menu item in the Add menu of the specified folder.
2086 2087 2088 2089 2090 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2086 def create_subfolders_in(folder_name) frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Start Add Menu").fire_event("onfocus") frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Create Folders").click instantiate_class(:create_folders) end |
#edit_details(name) ⇒ Object
2032 2033 2034 2035 2036 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2032 def edit_details(name) frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(name)}/).li(:text=>/Action/, :class=>"menuOpen").fire_event("onclick") frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(name)}/).link(:text=>"Edit Details").click instantiate_class(:file_details) end |
#file_names ⇒ Object
Returns an array of the file names currently listed on the page.
It excludes folder names and does not include any items slated to be attached.
1969 1970 1971 1972 1973 1974 1975 1976 1977 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 1969 def file_names names = [] frm.table(:class=>/listHier lines/, :text=>/Title/).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 return names end |
#folder_names ⇒ Object
Returns an array of the displayed folder names.
1946 1947 1948 1949 1950 1951 1952 1953 1954 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 1946 def folder_names names = [] frm.table(:class=>/listHier lines/, :text=>/Title/).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 return names end |
#go_to_folder(foldername) ⇒ Object
Clicks on the specified folder name, which should open the folder contents on a refreshed page.
2012 2013 2014 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2012 def go_to_folder(foldername) frm.link(:text=>foldername).click end |
#items_to_attach ⇒ Object
Returns an array containing the list of items that are slated to be attached.
1958 1959 1960 1961 1962 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 1958 def items_to_attach array = [] frm.table(:text=>/Items to attach/).links(:href=>/access.content.attachment/).each { |link| array << link.text } array end |
#move ⇒ Object
Clicks the Move button.
1995 1996 1997 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 1995 def move frm.(:value=>"Move").click end |
#open_folder(foldername) ⇒ Object
Clicks on the specified folder image, which will open the folder tree and remain on the page.
2006 2007 2008 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2006 def open_folder(foldername) frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(foldername)}/).link(:title=>"Open this folder").click end |
#remove ⇒ Object
Clicks the Remove button.
1985 1986 1987 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 1985 def remove frm.(:value=>"Remove").click end |
#remove_item(file_name) ⇒ Object
Clicks the remove link for the specified item in the attachment list.
1990 1991 1992 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 1990 def remove_item(file_name) frm.table(:class=>/listHier/).row(:text=>/#{Regexp.escape(file_name)}/).link(:href=>/doRemoveitem/).click end |
#select_file(filename) ⇒ Object
Clicks the Select button next to the specified file.
1980 1981 1982 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 1980 def select_file(filename) frm.table(:class=>/listHier lines/).row(:text, /#{Regexp.escape(filename)}/).link(:text=>"Select").click end |
#show_other_sites ⇒ Object
Clicks the Show Other Sites link.
2000 2001 2002 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2000 def show_other_sites frm.link(:text=>"Show other sites").click end |
#upload_file(filename, file_path = "") ⇒ Object
Enters the specified file into the file field name. Method takes an optional file_path parameter that it will pre-pend before the supplied filename, allowing the file name and path name to be distinct variables.
Does NOT instantiate any class, so use only when no page refresh occurs.
2043 2044 2045 2046 2047 2048 2049 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2043 def upload_file(filename, file_path="") frm.file_field(:id=>"upload").set(file_path + filename) if frm.div(:class=>"alertMessage").exist? sleep 2 upload_file(filename) end end |
#upload_file_to_folder(folder_name) ⇒ Object
Clicks the Add Menu for the specified folder, then selects the Upload Files command in the menu that appears.
2054 2055 2056 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2054 def upload_file_to_folder(folder_name) upload_files_to_folder(folder_name) 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.
2061 2062 2063 2064 2065 2066 2067 2068 2069 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2061 def upload_files_to_folder(folder_name) if frm.li(:text=>/A/, :class=>"menuOpen").exist? frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).li(:text=>/A/, :class=>"menuOpen").fire_event("onclick") else frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Start Add Menu").fire_event("onfocus") end frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(folder_name)}/).link(:text=>"Upload Files").click instantiate_class(:upload_files) end |
#upload_multiple_files_to_folder(folder, file_array) ⇒ 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 AnnouncementsAttach page class.
2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2098 def upload_multiple_files_to_folder(folder, file_array) upload = upload_files_to_folder folder file_array.each do |file| upload.file_to_upload=file 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 resources = upload_files.upload_files_now end end instantiate_class(:this) end |
#url=(url_string) ⇒ Object
Sets the URL field to the specified value.
2017 2018 2019 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 2017 def url=(url_string) frm.text_field(:id=>"url").set(url_string) end |
#what_is_parent? ⇒ Boolean
Use this for debugging purposes only…
1941 1942 1943 |
# File 'lib/sakai-oae-test-api/cle_frame_classes.rb', line 1941 def what_is_parent? puts @@classes[:parent] end |