Class: MyMessages

Inherits:
Object
  • Object
show all
Includes:
GlobalMethods, HeaderFooterBar, LeftMenuBarYou, PageObject
Defined in:
lib/sakai-oae-test-api/page_classes.rb

Overview

Methods related to the My Messages pages.

Instance Method Summary collapse

Methods included from LeftMenuBarYou

#change_picture, #inbox, #invitations, #my_contacts_count, #my_library_count, #my_messages_lock_icon, #sent, #show_hide_my_messages_tree, #trash, #unread_inbox_count, #unread_invitations_count, #unread_message_count

Methods included from PageObject

#method_missing, #name_li, #name_link

Methods included from HeaderFooterBar

#acknowledgements, #add_collection, #add_content, #browse_footer, #browse_footer_link, #change_language, #change_location, #click_link, #explore_footer, #explore_footer_link, #login, #messages_container, #my_account, #sign_out, #sign_up, #toggle_collector, #user_agreement

Methods included from GlobalMethods

#close_notification, #menu_item, #open_page, #view_person

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PageObject

Instance Method Details

#compose_messageObject

Clicks the “Compose message” button on any of the My messages pages.



683
684
685
686
687
# File 'lib/sakai-oae-test-api/page_classes.rb', line 683

def compose_message
  active_div.link(:id=>"inbox_create_new_message").click
  self.wait_for_ajax(2)
  self.class.class_eval { include SendMessagePopUp }
end

#delete_message(subject) ⇒ Object

Clicks the Delete button for the specified message (specified by Subject), then waits for Ajax calls to complete.



707
708
709
710
711
# File 'lib/sakai-oae-test-api/page_classes.rb', line 707

def delete_message(subject)
  subject_div = active_div.div(:class=>"inbox_subject", :text=>subject)
  subject_div.parent.parent.parent.button(:title=>"Delete message").click
  self.wait_for_ajax
end

#delete_selectedObject

Clicks the “Delete selected” buton and waits for Ajax calls to complete



789
790
791
792
# File 'lib/sakai-oae-test-api/page_classes.rb', line 789

def delete_selected
  delete_selected_element.click
  self.wait_for_ajax
end

#delete_selected_elementObject

The page element for the “Delete selected” button.



784
785
786
# File 'lib/sakai-oae-test-api/page_classes.rb', line 784

def delete_selected_element
  active_div.button(:id=>"inbox_delete_selected")
end

#mark_as_readObject

Clicks the “Mark as read” button, then waits for Ajax calls to complete



800
801
802
803
804
# File 'lib/sakai-oae-test-api/page_classes.rb', line 800

def mark_as_read
  mark_as_read_element.click
  sleep 0.3
  self.wait_for_ajax
end

#mark_as_read_elementObject

The page element for the “Mark as read” button



795
796
797
# File 'lib/sakai-oae-test-api/page_classes.rb', line 795

def mark_as_read_element
  active_div.button(:id=>"inbox_mark_as_read")
end

#message_bodyObject

Returns the text of the message body.The method assumes you’re currently viewing a message–that you’re not looking at a list of messages.



779
780
781
# File 'lib/sakai-oae-test-api/page_classes.rb', line 779

def message_body
  active_div.div(:id=>"inbox_show_message").div(:class=>"inbox_excerpt").text
end

#message_countsObject

Counts the number of displayed messages on the current page. Returns a hash containing counts for read and unread messages on the page. Keys in the hash are :all, :read, and :unread.



825
826
827
828
829
830
831
832
833
834
# File 'lib/sakai-oae-test-api/page_classes.rb', line 825

def message_counts
  hash = {}
  total = active_div.divs(:class=>"inbox_items_inner").length
  unread = active_div.divs(:class=>/unread/).length
  read = total - unread
  hash.store(:total, total)
  hash.store(:unread, unread)
  hash.store(:read, read)
  return hash
end

#message_dateObject

Returns the date of the message being viewed (as a String object)



767
768
769
# File 'lib/sakai-oae-test-api/page_classes.rb', line 767

def message_date
  active_div.div(:id=>"inbox_show_message").div(:class=>"inbox_date").span.text
end

#message_recipientObject

Returns the recipient name text. The method assumes you’re currently viewing a message–that you’re not looking at a list of messages.



762
763
764
# File 'lib/sakai-oae-test-api/page_classes.rb', line 762

def message_recipient
  active_div.div(:class, "inbox_name").span(:class=>"inbox_to_list").text
end

#message_senderObject

Returns the text of the name of the sender of the message being viewed



756
757
758
# File 'lib/sakai-oae-test-api/page_classes.rb', line 756

def message_sender
  active_div.div(:id=>"inbox_show_message").div(:class=>"inbox_name").button(:class=>"s3d-regular-links s3d-link-button s3d-bold personinfo_trigger_click personinfo_trigger").text
end

#message_status(subject) ⇒ Object

Returns “read” or “unread”, based on the relevant div’s class setting.



813
814
815
816
817
818
819
820
# File 'lib/sakai-oae-test-api/page_classes.rb', line 813

def message_status(subject)
  classname = self.div(:class=>/^inbox_item fl-container fl-fix/, :text=>/#{Regexp.escape(subject)}/).class_name
  if classname =~ /unread/
    return "unread"
  else
    return "read"
  end
end

#message_subjectObject

Returns the text of the message subject. The method assumes you’re currently viewing a message–that you’re not looking at a list of messages.



773
774
775
# File 'lib/sakai-oae-test-api/page_classes.rb', line 773

def message_subject
  active_div.div(:id=>"inbox_show_message").div(:class=>"inbox_subject").link.text
end

#message_subjectsObject

Returns an Array containing the list of Email subjects.



690
691
692
693
694
695
696
# File 'lib/sakai-oae-test-api/page_classes.rb', line 690

def message_subjects
  list = []
  active_div.divs(:class=>"inbox_subject").each do |div|
    list << div.text
  end
  return list
end

#open_message(subject) ⇒ Object Also known as: read_message

Clicks on the specified email to open it for reading



699
700
701
702
703
# File 'lib/sakai-oae-test-api/page_classes.rb', line 699

def open_message(subject)
  active_div.div(:class=>"inbox_subject").link(:text=>subject).click
  self.wait_for_ajax(2)
  self.class.class_eval { include SendMessagePopUp }
end

#page_titleObject

Returns the text of the displayed page title



677
678
679
# File 'lib/sakai-oae-test-api/page_classes.rb', line 677

def page_title
  active_div.span(:id=>"inbox_box_title").text
end

#preview_body(subject) ⇒ Object

Returns the text of the Body of the specified message.



747
748
749
# File 'lib/sakai-oae-test-api/page_classes.rb', line 747

def preview_body(subject)
  message_div(subject).div(:class=>"inbox_excerpt").text
end

#preview_date(subject) ⇒ Object

Returns the date/time string for the specified message.



736
737
738
# File 'lib/sakai-oae-test-api/page_classes.rb', line 736

def preview_date(subject)
  message_div(subject).div(:class=>"inbox_date").span.text
end

#preview_profile_pic(subject) ⇒ Object

Returns the file path and name of the displayed profile pic of the specified message.



742
743
744
# File 'lib/sakai-oae-test-api/page_classes.rb', line 742

def preview_profile_pic(subject)
  message_div(subject).parent.image(:class=>"person_icon").src
end

#preview_recipient(subject) ⇒ Object

Returns the message recipient name for the specified message (by Subject)



731
732
733
# File 'lib/sakai-oae-test-api/page_classes.rb', line 731

def preview_recipient(subject)
  message_div(subject).div(:class=>"inbox_name").span.text
end

#preview_sender(subject) ⇒ Object

Returns the Sender text for the specified message (by Subject)



726
727
728
# File 'lib/sakai-oae-test-api/page_classes.rb', line 726

def preview_sender(subject)
  message_div(subject).div(:class=>"inbox_name").button.text
end

#reply_to_message(subject) ⇒ Object

Clicks the Reply button for the specified (by Subject) message then waits for the Ajax calls to complete



715
716
717
718
719
720
# File 'lib/sakai-oae-test-api/page_classes.rb', line 715

def reply_to_message(subject)
  subject_div = active_div.div(:class=>"inbox_subject", :text=>subject)
  subject_div.parent.parent.parent.link(:title=>"Reply").click
  self.wait_for_ajax
  self.class.class_eval { include SendMessagePopUp }
end

#search_button_elementObject

The page element for the Search button



858
859
860
# File 'lib/sakai-oae-test-api/page_classes.rb', line 858

def search_button_element
  active_div.button(:class=>"s3d-button s3d-overlay-button s3d-search-button")
end

#search_field_elementObject

The page element for the Search text field.



839
840
841
# File 'lib/sakai-oae-test-api/page_classes.rb', line 839

def search_field_element
  active_div.text_field(:id=>"inbox_search_messages")
end

#search_messagesObject

Clicks the Search button and waits for Ajax calls to complete



863
864
865
866
# File 'lib/sakai-oae-test-api/page_classes.rb', line 863

def search_messages
  search_button_element.click
  self.wait_for_ajax
end

#search_messages=(text) ⇒ Object

Enters the specified text in the Search text box. Note that it appends a line feed on the end of the text so that the search happens immediately. Thus there is no need for a second line in the test script to specify clicking the Search button.



848
849
850
851
852
853
854
855
# File 'lib/sakai-oae-test-api/page_classes.rb', line 848

def search_messages=(text)
  search_field_element.set(text+"\n")
  begin
    active_div.p(:id=>"inbox_search_term").wait_until_present(3)
  rescue
    # do nothing because the result set might be empty
  end
end

#select_message(subject) ⇒ Object

Checks the checkbox for the specified message in the list.



807
808
809
810
# File 'lib/sakai-oae-test-api/page_classes.rb', line 807

def select_message(subject)
  subject_div = active_div.div(:class=>"inbox_subject", :text=>subject)
  subject_div.parent.parent.parent.checkbox.set
end