Module: AssignmentsListMethods

Includes:
PageObject
Defined in:
lib/kuali-sakai-common-lib/assignments.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.page_elements(identifier) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 125

def self.page_elements(identifier)
  in_frame(identifier) do |frame|
    link(:grade_report, :text=>"Grade Report", :frame=>frame)
    link(:student_view, :text=>"Student View", :frame=>frame)
    link(:options, :text=>"Options", :frame=>frame)
    link(:sort_assignment_title, :text=>"Assignment title", :frame=>frame)
    link(:sort_status, :text=>"Status", :frame=>frame)
    link(:sort_open, :text=>"Open", :frame=>frame)
    link(:sort_due, :text=>"Due", :frame=>frame)
    link(:sort_in, :text=>"In", :frame=>frame)
    link(:sort_new, :text=>"New", :frame=>frame)
    link(:sort_scale, :text=>"Scale", :frame=>frame)
    select_list(:view, :id=>"view", :frame=>frame)
    select_list(:select_page_size, :id=>"selectPageSize", :frame=>frame)
    button(:next, :name=>"eventSubmit_doList_next", :frame=>frame)
    button(:last, :name=>"eventSubmit_doList_last", :frame=>frame)
    button(:previous, :name=>"eventSubmit_doList_prev", :frame=>frame)
    button(:first, :name=>"eventSubmit_doList_first", :frame=>frame)
    button(:update, :name=>"eventSubmit_doDelete_confirm_assignment", :frame=>frame)
  end
end

Instance Method Details

#addObject

Clicks the Add link, then instantiates the AssignmentAdd page class.



20
21
22
23
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 20

def add
  frm.link(:text=>"Add").click
  AssignmentAdd.new(@browser)
end

#assignments_titlesObject Also known as: assignment_titles, assignment_list, assignments_list

Returns an array of the displayed assignment titles. Use for verification of test steps.



6
7
8
9
10
11
12
13
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 6

def assignments_titles
  titles = []
  a_table = frm.table(:class=>"listHier lines nolines")
  1.upto(a_table.rows.size-1) do |x|
    titles << a_table[x][1].h4(:index=>0).text
  end
  return titles
end

#check_assignment(id) ⇒ Object

Checks the checkbox for the specified Assignment, using the assignment id as the identifier.



75
76
77
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 75

def check_assignment(id) #FIXME to use name instead of id.
  frm.checkbox(:value, /#{id}/).set
end

#delete_assignment(assignment_name) ⇒ Object

Checks the appropriate checkbox, based on the specified assignment_name Then clicks the Update button and confirms the deletion request. It then reinstantiates the AssignmentsList class because of the page update.



44
45
46
47
48
49
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 44

def delete_assignment(assignment_name)
  frm.table(:class=>"listHier lines nolines").row(:text=>/#{Regexp.escape(assignment_name)}/).checkbox(:name=>"selectedAssignments").set
  frm.button(:value=>"Update").click
  frm.button(:value=>"Delete").click
  AssignmentsList.new(@browser)
end

#duplicate_assignment(assignment_name) ⇒ Object

Clicks on the Duplicate link for the Assignment specified. Then instantiates the AssignmentsList page class.



53
54
55
56
57
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 53

def duplicate_assignment(assignment_name)
  index = assignments_titles.index(assignment_name)
  frm.link(:text=>"Duplicate", :index=>index).click
  AssignmentsList.new(@browser)
end

#edit_assignment(assignment_name) ⇒ Object

Clicks the Edit link for the Assignment specified. Then it instantiates the AssignmentAdd page class.



34
35
36
37
38
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 34

def edit_assignment(assignment_name)
  index = assignments_titles.index(assignment_name)
  frm.link(:text=>"Edit", :index=>index).click
  AssignmentAdd.new(@browser)
end

#edit_assignment_id(id) ⇒ Object

Clicks the Edit link for the assignment with the specified id, then instantiates the AssignmentAdd page class.



27
28
29
30
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 27

def edit_assignment_id(id)
  frm.link(:href=>/#{Regexp.escape(id)}/).click
  AssignmentAdd.new(@browser)
end

#get_assignment_id(assignment_name) ⇒ Object

Gets the assignment id from the href of the specified Assignment link.



61
62
63
64
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 61

def get_assignment_id(assignment_name)
  frm.link(:text=>/#{Regexp.escape(assignment_name)}/).href =~ /(?<=\/a\/\S{36}\/).+(?=&pan)/
  return $~.to_s
end

#grade(assignment_name) ⇒ Object

Clicks the Grade link for the specified Assignment, then instantiates the AssignmentSubmissionList page class.



120
121
122
123
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 120

def grade(assignment_name)
  frm.table(:class=>"listHier lines nolines").row(:text=>/#{Regexp.escape(assignment_name)}/).link(:text=>"Grade").click
  AssignmentSubmissionList.new(@browser)
end

#open_assignment(assignment_name) ⇒ Object

Opens the specified assignment for viewing

Instantiates the student view or instructor/admin view based on the landing page attributes



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 90

def open_assignment(assignment_name)
  frm.link(:text=>assignment_name).click
  if frm.div(:class=>"portletBody").p(:class=>"instruction").exist? && frm.div(:class=>"portletBody").p(:class=>"instruction").text == "Add attachment(s), then choose the appropriate button at the bottom."
    AssignmentStudent.new(@browser)
  elsif frm.div(:class=>"portletBody").h3.text=="Assignment - In progress"
    AssignmentStudent.new(@browser)
  elsif frm.div(:class=>"portletBody").h3.text=="Viewing assignment..." || frm.div(:class=>"portletBody").h3.text.include?("Submitted") || frm.button(:value=>"Back to list").exist?
    AssignmentsPreview.new(@browser)
  else
    frm.frame(:id, "Assignment.view_submission_text___Frame").td(:id, "xEditingArea").wait_until_present
    AssignmentStudent.new(@browser)
  end
end

#permissionsObject

Clicks the Permissions button, then instantiates the AssignmentsPermissions page class.



68
69
70
71
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 68

def permissions
  frm.link(:text=>"Permissions").click
  AssignmentsPermissions.new(@browser)
end

#reorderObject

Clicks the Reorder button, then instantiates the AssignmentsReorder page class.



81
82
83
84
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 81

def reorder
  frm().link(:text=>"Reorder").click
  AssignmentsReorder.new(@browser)
end

#status_of(assignment_name) ⇒ Object

Gets the contents of the status column for the specified assignment



106
107
108
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 106

def status_of(assignment_name)
  frm.table(:class=>/listHier lines/).row(:text=>/#{Regexp.escape(assignment_name)}/).td(:headers=>"status").text
end

#view_submissions_for(assignment_name) ⇒ Object

Clicks the View Submissions link for the specified Assignment, then instantiates the AssignmentSubmissionList page class.



113
114
115
116
# File 'lib/kuali-sakai-common-lib/assignments.rb', line 113

def view_submissions_for(assignment_name)
  frm.table(:class=>"listHier lines nolines").row(:text=>/#{Regexp.escape(assignment_name)}/).link(:text=>"View Submissions").click
  AssignmentSubmissionList.new(@browser)
end