Class: ViewPerson

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 page for viewing a User’s profile

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

#about_me_dataObject

This method assumes it will be run on the About Me page. It returns a hash object where the key => value pair is: “Field Title” => “Field Value” –e.g.: “About Me:”=>“Text of field”



1427
1428
1429
1430
1431
1432
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1427

def about_me_data
  hash = {}
  target_div = self.div(:class=>"s3d-contentpage-title", :text=>"About Me").parent.parent.div(:id=>"displayprofilesection_body")
  target_div.divs(:class=>"displayprofilesection_field").each { |div| hash.store(div.span(:class=>"s3d-input-label").text, div.span(:class=>"field_value").text) }
  return hash
end

#accept_invitationObject

Clicks the “Accept invitation” button and waits for any Ajax calls to complete



1363
1364
1365
1366
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1363

def accept_invitation
  self.accept_invitation_button
  self.wait_for_ajax(2)
end

#add_to_contactsObject

Clicks the “Add to contacts” button and waits for the Pop-up dialog to appear.



1377
1378
1379
1380
1381
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1377

def add_to_contacts
  self.add_to_contacts_button
  self.wait_until { @browser.text.include? "Add a personal note to the invitation:" }
  self.class.class_eval { include AddToContactsPopUp }
end

#basic_info_dataObject

This method assumes the current page is the Basic Info page. It returns a hash object where the key => value pair is: “Field Title” => “Field Value” –e.g.: “Given name:”=>“Billy”



1407
1408
1409
1410
1411
1412
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1407

def basic_info_data
  hash = {}
  target_div = self.div(:class=>"s3d-contentpage-title", :text=>"Basic Information").parent.parent.div(:id=>"displayprofilesection_body")
  target_div.divs(:class=>"displayprofilesection_field").each { |div| hash.store(div.span(:class=>"s3d-input-label").text, div.span(:class=>"field_value").text) }
  return hash
end

#contact_info_dataObject

Returns a hash object where the key=>value pair is determined by the field title and field values shown on the “Contact Information” page.

Example: “Institution:”=>“University of Hard Knocks”



1455
1456
1457
1458
1459
1460
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1455

def contact_info_data
  hash = {}
  target_div = self.div(:class=>"s3d-contentpage-title", :text=>"Contact Information").parent.parent.div(:id=>"displayprofilesection_body")
  target_div.divs(:class=>"displayprofilesection_field").each { |div| hash.store(div.span(:class=>"s3d-input-label").text, div.span(:class=>"field_value").text) }
  return hash
end

#expected_contact_info?(hash) ⇒ Boolean

Takes a hash object containing the test contact info (see required format below), evaluates that data against the data returned with the contact_info_data method and returns true if the data match, and false, if they do not.

The hash object passed to the method must contain the following keys, exactly: :institution, :department, :title, :email, :im, :phone, :mobile, :fax, :address, :city, :state, :zip, :country

Returns:

  • (Boolean)


1469
1470
1471
1472
1473
1474
1475
1476
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1469

def expected_contact_info?(hash)
  info = self.contact_info_data
  key_map = {"Institution:"=>:institution, "Department:"=>:department, "Title/Role:"=>:title,
    "Email:"=>:email, "Instant Messaging:"=>:im, "Phone:"=>:phone, "Mobile:"=>:mobile, "Fax:"=>:fax,
    "Address:"=>:address, "City:"=>:city, "State:"=>:state, "Postal Code:"=>:zip, "Country:"=>:country}
  fixed = Hash[info.map { |k, v| [key_map[k], v ] } ]
  fixed==hash ? true : false
end

#expected_publications_data?(array_of_hash) ⇒ Boolean

Expects to be passed an array containing one or more hashes (see below for how the hash should be formed). Note that it’s okay to send a single hash instead of an array containing one hash element. The method will do the necessary cleaning of the data.

The method returns true if the contents of the hash(es) match the data evaluated against, otherwise returns false. The hash(es) should contain all of the following keys… :main_title, main_author, :co_authors, :publisher, :place, :volume_title, :volume_info, :year, :number, :series, :url

Returns:

  • (Boolean)


1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1510

def expected_publications_data?(array_of_hash)
  expected_data=[]
  expected_data << array_of_hash
  expected_data.flatten!
  data_array = self.publications_data
  new_array = []
  key_map = { "Main title:"=>:main_title, "Main author:"=>:main_author,
  "Co-author(s):"=>:co_authors, "Publisher:"=>:publisher, "Place of publication:"=>:place,
  "Volume title:"=>:volume_title, "Volume information:"=>:volume_info,
  "Year:"=>:year, "Number:"=>:number, "Series title:"=>:series, "URL:"=>:url }
  data_array.each do |hash|
    fixed = Hash[hash.map { |k, v| [key_map[k], v ] } ]
    new_array << fixed
  end
  expected_data==new_array ? true : false
end

#messageObject

Clicks the message button and waits for the Pop-up dialog to appear.



1369
1370
1371
1372
1373
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1369

def message
  self.message_button
  self.wait_until { self.text.include? "Send this message to:" }
  self.class.class_eval { include SendMessagePopUp }
end

#online_dataObject

Returns a hash object where the key=>value pair is determined by the field title and field values shown on the “Online” page.

Because there can be an arbitrary number of Sites listed on the page, The hash keys will have a number appended on the end. Example: { “Site:1”=>“Twitter”, “URL:1”=>“www.twitter.com”,“Site:2”=>“Facebook”,“URL:2”=>“www.facebook.com”}



1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1440

def online_data
  hash = {}
  target_div = self.div(:class=>"s3d-contentpage-title", :text=>"Online").parent.parent.div(:id=>"displayprofilesection_body")
  x=0
  target_div.divs(:class=>"displayprofilesection_field").each do |div|
    div.span(:class=>"s3d-input-label").text == "Site:" ? x+=1 : x
    hash.store("#{div.span(:class=>"s3d-input-label").text}#{x}", div.span(:class=>"field_value").text)
  end
  return hash
end

#publications_dataObject Also known as: publication_data, publications_list

Returns an array of hashes. Each hash in the array refers to one of the listed publications.

Each hash’s key=>value pairs are determined by the field title and field values for the publications.

Example: “Main title:”=>“War and Peace”,“Main author:”=>“Tolstoy”, etc.…



1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1484

def publications_data
  list = []
  hash = {}
  self.div(:class=>"publications").divs(:class=>"displayprofilesection_field").each do |div|
    if div.span(:class=>"s3d-input-label").text=="Main title:" && hash != {}
      list << hash
      hash={}
    end
    hash.store(div.span(:class=>"s3d-input-label").text, div.span(:class=>"field_value").text)
  end
  list << hash
  return list
end

#tags_and_categories_listObject

Returns an array containing the text of all of the tags and categories listed on the Basic Information page. Note that it splits them up into parent and child categories.



1417
1418
1419
1420
1421
1422
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1417

def tags_and_categories_list
  list = []
  target_div = self.div(:class=>"s3d-contentpage-title", :text=>"Basic Information").parent.parent.div(:id=>"displayprofilesection_body")
  target_div.links.each { |link| list << link.text.split(" » ") }
  return list.flatten.uniq
end

#users_contactsObject

Opens the user’s Contacts page to display their contacts



1399
1400
1401
1402
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1399

def users_contacts
  self.link(:class=>/s3d-bold lhnavigation_toplevel lhnavigation_page_title_value/, :text=>/Contacts/).click
  self.class.class_eval { include ListWidget }
end

#users_libraryObject

Clicks the link to open the user’s library profile page.



1384
1385
1386
1387
1388
1389
1390
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1384

def users_library
  self.link(:class=>/s3d-bold lhnavigation_toplevel lhnavigation_page_title_value/, :text=>/Library/).click
  sleep 2
  self.wait_for_ajax(2)
  self.class.class_eval { include ListWidget
                          include LibraryWidget }
end