Class: AssignmentsList

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

Overview

Page that appears when you first click the Assignments link

Instance Method Summary collapse

Methods inherited from AssignmentsBase

listview_elements, menu_elements

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

#assignment_href(name) ⇒ Object



232
233
234
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 232

def assignment_href(name)
  frm.link(:text=>/#{Regexp.escape(name)}/).href
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.



180
181
182
183
184
185
186
187
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 180

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.



238
239
240
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 238

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.



210
211
212
213
214
215
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 210

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.



219
220
221
222
223
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 219

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. next is the AssignmentAdd page class.



201
202
203
204
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 201

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

#edit_assignment_id(id) ⇒ Object

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



194
195
196
197
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 194

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.



227
228
229
230
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 227

def get_assignment_id(assignment_name)
  assignment_href(assignment_name) =~ /(?<=\/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.



263
264
265
266
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 263

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



243
244
245
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 243

def open_assignment(assignment_name)
  frm.link(:text=>assignment_name).click
end

#status_of(assignment_name) ⇒ Object

Gets the contents of the status column for the specified assignment



249
250
251
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 249

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.



256
257
258
259
# File 'lib/sakai-cle-test-api/page_objects/assignments.rb', line 256

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