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”



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

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



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

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.



1393
1394
1395
1396
1397
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1393

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”



1423
1424
1425
1426
1427
1428
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1423

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”



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

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)


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

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)


1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1526

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.



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

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”}



1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1456

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.…



1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1500

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.



1433
1434
1435
1436
1437
1438
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1433

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



1415
1416
1417
1418
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1415

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.



1400
1401
1402
1403
1404
1405
1406
# File 'lib/sakai-oae-test-api/page_classes.rb', line 1400

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