Class: Forums

Inherits:
BasePage show all
Defined in:
lib/sakai-cle-test-api/page_objects/forums.rb

Instance Method Summary collapse

Methods inherited from BasePage

basic_page_elements, frame_element

Methods inherited from PageMaker

element, expected_element, expected_title, #initialize, #method_missing, page_url

Constructor Details

This class inherits a constructor from PageMaker

Dynamic Method Handling

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

Instance Method Details

#delete_forum(name) ⇒ Object



63
64
65
66
67
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 63

def delete_forum(name)
  index = forum_titles.index(name)
  frm.link(:id=>/msgForum:forums:\d+:delete/,:text=>"Delete", :index=>index).click
  EditForum.new(@browser)
end

#delete_topic(name) ⇒ Object



69
70
71
72
73
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 69

def delete_topic(name)
  index = topic_titles.index(name)
  frm.link(:id=>/topics:\d+:delete_confirm/, :text=>"Delete", :index=>index).click
  AddEditTopic.new(@browser)
end

#draft?(title) ⇒ Boolean

Pass this method a string that matches the title of a Forum on the page, it returns True if the specified forum row has “DRAFT” in it.

Returns:

  • (Boolean)


8
9
10
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 8

def draft?(title)
  frm.table(:id=>"msgForum:forums").row(:text=>/#{Regexp.escape(title)}/).span(:text=>"DRAFT").exist?
end

#forum_settings(name) ⇒ Object



51
52
53
54
55
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 51

def forum_settings(name)
  index = forum_titles.index(name)
  frm.link(:text=>"Forum Settings", :index=>index).click
  EditForum.new(@browser)
end

#forum_titlesObject



37
38
39
40
41
42
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 37

def forum_titles
  titles = []
  title_links = frm.div(:class=>"portletBody").links.find_all { |link| link.class_name=="title" && link.id=="" }
  title_links.each { |link| titles << link.text }
  return titles
end

#forums_tableObject



33
34
35
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 33

def forums_table
  frm.div(:class=>"portletBody").table(:id=>"msgForum:forums")
end

#new_forumObject



12
13
14
15
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 12

def new_forum
  frm.link(:text=>"New Forum").click
  EditForum.new(@browser)
end

#new_topic_for_forum(name) ⇒ Object



17
18
19
20
21
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 17

def new_topic_for_forum(name)
  index = forum_titles.index(name)
  frm.link(:text=>"New Topic", :index=>index).click
  AddEditTopic.new(@browser)
end

#open_forum(forum_title) ⇒ Object



75
76
77
78
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 75

def open_forum(forum_title)
  frm.link(:text=>forum_title).click
  # New Class def goes here.
end

#open_topic(topic_title) ⇒ Object



80
81
82
83
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 80

def open_topic(topic_title)
  frm.link(:text=>topic_title).click
  TopicPage.new(@browser)
end

#organizeObject



23
24
25
26
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 23

def organize
  frm.link(:text=>"Organize").click
  OrganizeForums.new(@browser)
end

#template_settingsObject



28
29
30
31
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 28

def template_settings
  frm.link(:text=>"Template Settings").click
  ForumTemplateSettings.new(@browser)
end

#topic_settings(name) ⇒ Object



57
58
59
60
61
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 57

def topic_settings(name)
  index = topic_titles.index(name)
  frm.link(:text=>"Topic Settings", :index=>index).click
  AddEditTopic.new(@browser)
end

#topic_titlesObject



44
45
46
47
48
49
# File 'lib/sakai-cle-test-api/page_objects/forums.rb', line 44

def topic_titles
  titles = []
  title_links = frm.div(:class=>"portletBody").links.find_all { |link| link.class_name == "title" && link.id != "" }
  title_links.each { |link| titles << link.text }
  return titles
end