spec: refactor selenium specs

test:
  1. refactored specs to use f aliases
  2. refactored some link usages
  3. refactored added helper methods

Change-Id: Iaad07a5e1173827cb22e3f67b80bc51666169914
Reviewed-on: https://gerrit.instructure.com/13322
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jake Sorce <jake@instructure.com>
This commit is contained in:
Shawn Meredith 2012-08-29 11:44:23 -06:00 committed by Jake Sorce
parent f4d4632071
commit 07b7c54ddf
44 changed files with 784 additions and 782 deletions

View File

@ -101,7 +101,7 @@ describe "account" do
Account.default.account_authorization_configs.create(:auth_type => 'cas')
get "/accounts/#{Account.default.id}/users"
driver.find_element(:css, ".add_user_link").click
f(".add_user_link").click
dialog = f("#add_user_dialog")
dialog.find_element(:id, "pseudonym_path").should be_displayed
dialog.find_element(:id, "pseudonym_unique_id").should be_displayed

View File

@ -52,7 +52,7 @@ describe "Alerts" do
edit.click
alert.find_element(:css, '.criteria .delete_item_link').click
wait_for_animations
keep_trying_until { find_all_with_jquery('.alert .criteria li').length == 1 }
keep_trying_until { ffj('.alert .criteria li').length == 1 }
submit.click
keep_trying_until{
@ -80,7 +80,7 @@ describe "Alerts" do
f('#tab-alerts-link').click
f("#edit_alert_#{alert.id} .delete_link").click
keep_trying_until { find_with_jquery("#edit_alert_#{alert.id}").blank? }
keep_trying_until { fj("#edit_alert_#{alert.id}").blank? }
@alerts.reload
@alerts.should be_empty
@ -108,7 +108,7 @@ describe "Alerts" do
wait_for_animations
f('.alert.new .cancel_button').click
wait_for_animations
keep_trying_until { find_all_with_jquery(".alert.new").should be_empty }
keep_trying_until { ffj(".alert.new").should be_empty }
@alerts.should be_empty
end
@ -121,7 +121,7 @@ describe "Alerts" do
alert = f('.alert.new')
link = alert.find_element(:css, '.add_recipient_link')
keep_trying_until { find_all_with_jquery('.alert.new .add_recipients_line select option').length > 1 }
keep_trying_until { ffj('.alert.new .add_recipients_line select option').length > 1 }
for i in 1..alert.find_elements(:css, '.add_recipients_line select option').length do
link.click
wait_for_animations
@ -136,18 +136,18 @@ describe "Alerts" do
f('#tab-alerts-link').click
alertElement = f("#edit_alert_#{alert.id}")
alertElement.find_element(:css, ".edit_link").click
find_with_jquery("#edit_alert_#{alert.id} .add_recipient_link:visible").should be_blank
fj("#edit_alert_#{alert.id} .add_recipient_link:visible").should be_blank
# Deleting a recipient should add it to the dropdown (which is now visible)
alertElement.find_element(:css, '.recipients .delete_item_link').click
wait_for_animations
find_with_jquery("#edit_alert_#{alert.id} .add_recipient_link").should be_displayed
fj("#edit_alert_#{alert.id} .add_recipient_link").should be_displayed
alertElement.find_elements(:css, '.add_recipients_line select option').length.should == 1
keep_trying_until { alertElement.find_elements(:css, '.recipients li').length == 2 }
# Do it again, with the same results
alertElement.find_element(:css, '.recipients .delete_item_link').click
find_with_jquery("#edit_alert_#{alert.id} .add_recipient_link").should be_displayed
fj("#edit_alert_#{alert.id} .add_recipient_link").should be_displayed
alertElement.find_elements(:css, '.add_recipients_line select option').length.should == 2
keep_trying_until { alertElement.find_elements(:css, '.recipients li').length == 1 }
@ -167,20 +167,20 @@ describe "Alerts" do
keep_trying_until do
submit_form('#new_alert')
wait_for_animations
find_all_with_jquery('.error_box').length == 4
ffj('.error_box').length == 4
end
# clicking "do not repeat" should remove the number of days error
alert.find_element(:css, 'input[name="repetition"][value="none"]').click
keep_trying_until { find_all_with_jquery('.error_box').length == 3 }
keep_trying_until { ffj('.error_box').length == 3 }
# adding recipients and criterion make the errors go away
alert.find_element(:css, '.add_recipient_link').click
alert.find_element(:css, '.add_criterion_link').click
keep_trying_until { find_all_with_jquery('.error_box').length == 1 }
keep_trying_until { ffj('.error_box').length == 1 }
alert.find_element(:css, '.criteria input[type="text"]').send_keys("abc")
submit_form('#new_alert')
keep_trying_until { find_all_with_jquery('.error_box').length == 2 }
keep_trying_until { ffj('.error_box').length == 2 }
end
end

View File

@ -16,7 +16,7 @@ describe "content exports" do
Delayed::Job.last(:conditions => {:tag => 'ContentExport#export_course_without_send_later'})
@export = keep_trying_until { ContentExport.last }
@export.export_course_without_send_later
new_download_link = keep_trying_until { driver.find_element(:css, "div#export_files a") }
new_download_link = keep_trying_until { f("div#export_files a") }
url = new_download_link.attribute 'href'
url.should match(%r{/files/\d+/download\?verifier=})
end
@ -28,7 +28,7 @@ describe "content exports" do
it "should allow qti export downloads" do
run_export do
driver.find_element(:css, "input[value=qti]").click
f("input[value=qti]").click
end
@export.export_type.should == 'qti'
end

View File

@ -9,7 +9,7 @@ describe "course sections" do
end
def table_rows
table_rows = driver.find_elements(:css, '#enrollment_table tr')
table_rows = ff('#enrollment_table tr')
table_rows
end
@ -55,11 +55,11 @@ describe "course sections" do
edit_name = 'edited section name'
get "/courses/#{@course.id}/sections/#{@section.id}"
driver.find_element(:css, '.edit_section_link').click
edit_form = driver.find_element(:id, 'edit_section_form')
f('.edit_section_link').click
edit_form = f('#edit_section_form')
replace_content(edit_form.find_element(:id, 'course_section_name'), edit_name)
submit_form(edit_form)
wait_for_ajaximations
driver.find_element(:id, 'section_name').should include_text(edit_name)
f('#section_name').should include_text(edit_name)
end
end

View File

@ -69,34 +69,34 @@ describe "course settings" do
get "/courses/#{@course.id}/settings"
driver.find_element(:css, '.edit_course_link').click
course_form = driver.find_element(:id, 'course_form')
f('.edit_course_link').click
course_form = f('#course_form')
name_input = course_form.find_element(:id, 'course_name')
replace_content(name_input, course_name)
code_input = course_form.find_element(:id, 'course_course_code')
replace_content(code_input, course_code)
click_option('#course_locale', locale_text)
driver.find_element(:css, '.course_form_more_options_link').click
f('.course_form_more_options_link').click
wait_for_animations
driver.find_element(:css, '.course_form_more_options').should be_displayed
f('.course_form_more_options').should be_displayed
submit_form(course_form)
wait_for_ajaximations
driver.find_element(:css, '.course_info').should include_text(course_name)
driver.find_element(:css, '.course_code').should include_text(course_code)
driver.find_element(:css, '.locale').should include_text(locale_text)
f('.course_info').should include_text(course_name)
f('.course_code').should include_text(course_code)
f('.locale').should include_text(locale_text)
end
it "should add a section" do
section_name = 'new section'
get "/courses/#{@course.id}/settings#tab-sections"
section_input = driver.find_element(:id, 'course_section_name')
section_input = f('#course_section_name')
keep_trying_until { section_input.should be_displayed }
replace_content(section_input, section_name)
submit_form('#add_section_form')
wait_for_ajaximations
new_section = driver.find_elements(:css, 'ul#sections > .section')[1]
new_section = ff('#sections > .section')[1]
new_section.should include_text(section_name)
end
@ -104,14 +104,14 @@ describe "course settings" do
add_section('Delete Section')
get "/courses/#{@course.id}/settings#tab-sections"
driver.find_element(:css, '.section_link.delete_section_link').click
f('.section_link.delete_section_link').click
keep_trying_until do
driver.switch_to.alert.should_not be_nil
driver.switch_to.alert.accept
true
end
wait_for_ajaximations
driver.find_elements(:css, 'ul#sections > .section').count.should == 1
ff('#sections > .section').count.should == 1
end
it "should edit a section" do
@ -119,24 +119,24 @@ describe "course settings" do
add_section('Edit Section')
get "/courses/#{@course.id}/settings#tab-sections"
driver.find_element(:css, '.section_link.edit_section_link').click
section_input = driver.find_element(:id, 'course_section_name')
f('.section_link.edit_section_link').click
section_input = f('#course_section_name')
keep_trying_until { section_input.should be_displayed }
replace_content(section_input, edit_text)
section_input.send_keys(:return)
wait_for_ajaximations
driver.find_elements(:css, 'ul#sections > .section')[0].should include_text(edit_text)
ff('#sections > .section')[0].should include_text(edit_text)
end
it "should move a nav item to disabled" do
get "/courses/#{@course.id}/settings#tab-navigation"
disabled_div = driver.find_element(:id, 'nav_disabled_list')
announcements_nav = driver.find_element(:id, 'nav_edit_tab_id_14')
disabled_div = f('#nav_disabled_list')
announcements_nav = f('#nav_edit_tab_id_14')
driver.action.click_and_hold(announcements_nav).
move_to(disabled_div).
release(disabled_div).
perform
driver.find_element(:id, 'nav_disabled_list').should include_text(announcements_nav.text)
f('#nav_disabled_list').should include_text(announcements_nav.text)
end
end
@ -171,19 +171,20 @@ describe "course settings" do
add_section(section_name)
get "/courses/#{@course.id}/settings#tab-users"
add_button = driver.find_element(:css, '.add_users_link')
add_button = f('.add_users_link')
keep_trying_until { add_button.should be_displayed }
add_button.click
click_option('#course_section_id_holder > #course_section_id', section_name)
driver.find_element(:css, 'textarea.user_list').send_keys(user.name)
driver.find_element(:css, '.verify_syntax_button').click
f('#user_list_boxes .user_list').send_keys(user.name)
f('.verify_syntax_button').click
wait_for_ajax_requests
driver.find_element(:id, 'user_list_parsed').should include_text(user.name)
driver.find_element(:css, '.add_users_button').click
f('#user_list_parsed').should include_text(user.name)
f('.add_users_button').click
wait_for_ajax_requests
refresh_page #needed to update the student count on the next page
f("a[href='#tab-sections']").click
new_section = driver.find_elements(:css, 'ul#sections > .section')[1]
get "/courses/#{@course.id}/settings/#tab-sections"
new_section = ff('#sections > .section')[1]
new_section.find_element(:css, '.users_count').should include_text("1")
end
@ -366,7 +367,7 @@ describe "course settings" do
it "should not include student view student in the statistics count" do
@fake_student = @course.student_view_student
get "/courses/#{@course.id}/settings"
find_with_jquery('.summary tr:nth(1)').text.should match /Students:\s*None/
fj('.summary tr:nth(1)').text.should match /Students:\s*None/
end
end
end

View File

@ -17,14 +17,14 @@ describe "cross-listing" do
end
it "should allow cross-listing a section" do
driver.find_element(:css, '.crosslist_link').click
form = driver.find_element(:id, 'crosslist_course_form')
f('.crosslist_link').click
form = f('#crosslist_course_form')
submit_btn = form.find_element(:css, '.submit_button')
form.should_not be_nil
form.find_element(:css, '.submit_button').attribute(:disabled).should eql 'true'
course_id = form.find_element(:id, 'course_id')
course_name = driver.find_element(:id, 'course_autocomplete_name')
course_name = f('#course_autocomplete_name')
# crosslist a valid course
course_id.click
@ -40,23 +40,23 @@ describe "cross-listing" do
# verify teacher doesn't have de-crosslist privileges
get "/courses/#{@course2.id}/sections/#{@section.id}"
driver.find_elements(:css, '.uncrosslist_link').length.should eql 0
ff('.uncrosslist_link').length.should eql 0
# enroll teacher and de-crosslist
@course1.enroll_teacher(@user).accept
get "/courses/#{@course2.id}/sections/#{@section.id}"
driver.find_element(:css, '.uncrosslist_link').click
driver.find_element(:id, 'uncrosslist_form').should be_displayed
f('.uncrosslist_link').click
f('#uncrosslist_form').should be_displayed
submit_form('#uncrosslist_form')
wait_for_ajaximations
keep_trying_until { driver.current_url.should match /courses\/#{@course1.id}/ }
end
it "should not allow cross-listing an invalid section" do
driver.find_element(:css, '.crosslist_link').click
form = driver.find_element(:id, 'crosslist_course_form')
f('.crosslist_link').click
form = f('#crosslist_course_form')
course_id = form.find_element(:id, 'course_id')
course_name = driver.find_element(:id, 'course_autocomplete_name')
course_name = f('#course_autocomplete_name')
course_id.click
course_id.send_keys "-1\n"
keep_trying_until { course_name.text != 'Confirming Course ID "-1"...' }
@ -78,23 +78,23 @@ describe "cross-listing" do
# we visit the first course's section. the teacher is enrolled in this
# section. we're going to crosslist it.
get "/courses/#{course.id}/sections/#{section.id}"
driver.find_element(:css, ".crosslist_link").click
form = driver.find_element(:css, "#crosslist_course_form")
f(".crosslist_link").click
form = f("#crosslist_course_form")
form.find_element(:css, ".submit_button").attribute(:disabled).should eql("true")
form.should_not be_nil
# let's try and crosslist an invalid course
form.find_element(:css, "#course_id").click
form.find_element(:css, "#course_id").send_keys("-1\n")
keep_trying_until { driver.find_element(:css, "#course_autocomplete_name").text != "Confirming Course ID \"-1\"..." }
driver.find_element(:css, "#course_autocomplete_name").text.should eql("Course ID \"-1\" not authorized for cross-listing")
keep_trying_until { f("#course_autocomplete_name").text != "Confirming Course ID \"-1\"..." }
f("#course_autocomplete_name").text.should eql("Course ID \"-1\" not authorized for cross-listing")
# k, let's crosslist to the other course
form.find_element(:css, "#course_id").click
form.find_element(:css, "#course_id").clear
form.find_element(:css, "#course_id").send_keys([:control, 'a'], other_course.id.to_s, "\n")
keep_trying_until { driver.find_element(:css, "#course_autocomplete_name").text != "Confirming Course ID \"#{other_course.id}\"..." }
driver.find_element(:css, "#course_autocomplete_name").text.should eql(other_course.name)
keep_trying_until { f("#course_autocomplete_name").text != "Confirming Course ID \"#{other_course.id}\"..." }
f("#course_autocomplete_name").text.should eql(other_course.name)
form.find_element(:css, "#course_autocomplete_id").attribute(:value).should eql(other_course.id.to_s)
form.find_element(:css, ".submit_button").attribute(:disabled).should eql("false")
submit_form(form)
@ -104,13 +104,13 @@ describe "cross-listing" do
# they were enrolled in got moved). they don't have the rights to
# uncrosslist.
get "/courses/#{other_course.id}/sections/#{section.id}"
driver.find_elements(:css, ".uncrosslist_link").length.should eql(0)
ff(".uncrosslist_link").length.should eql(0)
# enroll, and make sure the teacher can uncrosslist.
course.enroll_teacher(@user).accept
get "/courses/#{other_course.id}/sections/#{section.id}"
driver.find_element(:css, ".uncrosslist_link").click
driver.find_element(:css, "#uncrosslist_form").displayed?.should eql(true)
f(".uncrosslist_link").click
f("#uncrosslist_form").should be_displayed
submit_form("#uncrosslist_form")
keep_trying_until { driver.current_url.match(/courses\/#{course.id}/) }
end

View File

@ -16,16 +16,16 @@ describe "dashboard" do
items.first.hidden.should == false
get url
find_all_with_jquery("div.communication_message.announcement").size.should == 1
ffj(".communication_message.announcement").size.should == 1
# force the element to be visible so we can click it -- webdriver has a
# hover() event but it only works on Windows so far
driver.execute_script("$('div.communication_message.announcement .disable_item_link').css('visibility', 'visible')")
driver.find_element(:css, "div.communication_message.announcement .disable_item_link").click
keep_trying_until { find_all_with_jquery("div.communication_message.announcement").size.should == 0 }
f(".communication_message.announcement .disable_item_link").click
keep_trying_until { ffj(".communication_message.announcement").size.should == 0 }
# should still be gone on reload
get url
find_all_with_jquery("div.communication_message.announcement").size.should == 0
ffj(".communication_message.announcement").size.should == 0
@user.recent_stream_items.size.should == 0
items.first.reload.hidden.should == true
@ -48,8 +48,8 @@ describe "dashboard" do
items.size.should == 1
get "/"
find_all_with_jquery("div.communication_message.conversation").size.should == 1
find_all_with_jquery("div.communication_message.conversation .communication_sub_message:visible").size.should == 3 # two messages, plus add message form
ffj(".communication_message.conversation").size.should == 1
ffj(".communication_message.conversation .communication_sub_message:visible").size.should == 3 # two messages, plus add message form
end
it "should allow replying to conversation stream items" do
@ -57,11 +57,11 @@ describe "dashboard" do
c.add_message('test')
get "/"
driver.find_element(:css, ".reply_message .textarea").click
driver.find_element(:css, "textarea[name='body']").send_keys("hey there")
f(".reply_message .textarea").click
f("textarea[name='body']").send_keys("hey there")
submit_form(".communication_sub_message")
wait_for_ajax_requests
messages = find_all_with_jquery(".communication_message.conversation .communication_sub_message:visible")
messages = ffj(".communication_message.conversation .communication_sub_message:visible")
# messages[-1] is the reply form
messages[-2].text.should =~ /hey there/
@ -84,18 +84,18 @@ describe "dashboard" do
@appointment_group.update_attributes(:new_appointments => [[Time.now.utc + 2.hour, Time.now.utc + 3.hour]])
get "/"
ffj(".topic_message div.communication_message.dashboard_notification").size.should == 3
ffj(".topic_message .communication_message.dashboard_notification").size.should == 3
# appointment group publish and update notifications
ffj("div.communication_message.message_appointment_group_#{@appointment_group.id}").size.should == 2
ffj(".communication_message.message_appointment_group_#{@appointment_group.id}").size.should == 2
# signup notification
ffj("div.communication_message.message_group_#{@group.id}").size.should == 1
ffj(".communication_message.message_group_#{@group.id}").size.should == 1
end
it "should display assignment in to do list" do
due_date = Time.now.utc + 2.days
@assignment = assignment_model({:due_at => due_date, :course => @course})
get "/"
driver.find_element(:css, '.events_list .event a').should include_text(@assignment.title)
f('.events_list .event a').should include_text(@assignment.title)
# use jQuery to get the text since selenium can't figure it out when the elements aren't displayed
driver.execute_script("return $('.event a .tooltip_text').text()").should match(@course.short_name)
end
@ -120,7 +120,7 @@ describe "dashboard" do
# No "To Do" list shown
f('.right-side-list.to-do-list').should be_nil
coming_up_list = driver.find_element(:css, '.right-side-list.events')
coming_up_list = f('.right-side-list.events')
2.times { |i| check_list_text(coming_up_list, names[i]) }
end
@ -133,10 +133,10 @@ describe "dashboard" do
get "/"
find_all_with_jquery(".to-do-list li:visible").size.should == 5 + 1 # +1 is the see more link
driver.find_element(:css, ".more_link").click
ffj(".to-do-list li:visible").size.should == 5 + 1 # +1 is the see more link
f(".more_link").click
wait_for_animations
find_all_with_jquery(".to-do-list li:visible").size.should == 20
ffj(".to-do-list li:visible").size.should == 20
end
it "should display assignments to do in to do list and assignments menu for a student" do
@ -150,12 +150,12 @@ describe "dashboard" do
get "/"
#verify assignment changed notice is in messages
driver.find_element(:css, '#topic_list .topic_message').should include_text('Assignment Due Date Changed')
f('#topic_list .topic_message').should include_text('Assignment Due Date Changed')
#verify assignment is in to do list
driver.find_element(:css, '.to-do-list > li').should include_text(assignment.submission_action_string)
f('.to-do-list > li').should include_text(assignment.submission_action_string)
#verify assignment is in drop down
assignment_menu = driver.find_element(:id, 'assignments_menu_item')
assignment_menu = f('#assignments_menu_item')
driver.action.move_to(assignment_menu).perform
assignment_menu.should include_text("To Turn In")
assignment_menu.should include_text(assignment.title)
@ -167,7 +167,7 @@ describe "dashboard" do
get "/"
course_menu = driver.find_element(:id, 'courses_menu_item')
course_menu = f('#courses_menu_item')
driver.action.move_to(course_menu).perform
course_menu.should include_text('My Courses')
@ -183,7 +183,7 @@ describe "dashboard" do
get "/"
course_menu = driver.find_element(:id, 'courses_menu_item')
course_menu = f('#courses_menu_item')
driver.action.move_to(course_menu).perform
course_menu.should include_text('Current Groups')
@ -202,7 +202,7 @@ describe "dashboard" do
get "/"
find_with_jquery('#topic_list .topic_message:last-child .header_title').should include_text(@conference.title)
fj('#topic_list .topic_message:last-child .header_title').should include_text(@conference.title)
end
it "should display calendar events in the coming up list" do
@ -213,7 +213,7 @@ describe "dashboard" do
:end_at => 10.minutes.from_now
})
get "/"
driver.find_element(:css, 'div.events_list .event a').should include_text(@event.title)
f('div.events_list .event a').should include_text(@event.title)
end
it "should display quiz submissions with essay questions as submitted in coming up list" do
@ -241,12 +241,12 @@ describe "dashboard" do
@context = @course
announcement_model({:title => "hey all read this k", :message => "announcement"})
get "/"
driver.find_element(:css, '.topic_message .add_entry_link').click
f('.topic_message .add_entry_link').click
driver.find_element(:name, 'discussion_entry[plaintext_message]').send_keys('first comment')
submit_form('.add_sub_message_form')
wait_for_ajax_requests
wait_for_animations
driver.find_element(:css, '.topic_message .subcontent').should include_text('first comment')
f('.topic_message .subcontent').should include_text('first comment')
end
it "should create an announcement for the first course that is not visible in the second course" do
@ -268,11 +268,11 @@ describe "dashboard" do
get "/"
driver.find_element(:id, 'no_topics_message').should_not include_text('No Recent Messages')
f('#no_topics_message').should_not include_text('No Recent Messages')
get "/courses/#{@second_course.id}"
driver.find_element(:id, 'no_topics_message').should include_text('No Recent Messages')
f('#no_topics_message').should include_text('No Recent Messages')
end
it "should validate the functionality of soft concluded courses in dropdown" do
@ -284,8 +284,8 @@ describe "dashboard" do
c1.save!
get "/"
driver.action.move_to(driver.find_element(:id, 'courses_menu_item')).perform
course_menu = driver.find_element(:id, 'menu_enrollments')
driver.action.move_to(f('#courses_menu_item')).perform
course_menu = f('#menu_enrollments')
course_menu.should be_displayed
course_menu.should_not include_text(c1.name)
end
@ -307,7 +307,7 @@ describe "dashboard" do
c1.reload
get "/courses"
driver.find_element(:css, '.past_enrollments').should include_text(c1.name)
f('.past_enrollments').should include_text(c1.name)
end
it "should display assignment to grade in to do list and assignments menu for a teacher" do
@ -320,10 +320,10 @@ describe "dashboard" do
get "/"
#verify assignment is in to do list
driver.find_element(:css, '.to-do-list > li').should include_text('Grade ' + assignment.title)
f('.to-do-list > li').should include_text('Grade ' + assignment.title)
#verify assignment is in drop down
assignment_menu = driver.find_element(:id, 'assignments_menu_item')
assignment_menu = f('#assignments_menu_item')
driver.action.move_to(assignment_menu).perform
assignment_menu.should include_text("To Grade")
assignment_menu.should include_text(assignment.title)
@ -366,7 +366,7 @@ describe "dashboard" do
get "/"
course_menu = driver.find_element(:id, 'courses_menu_item')
course_menu = f('#courses_menu_item')
driver.action.move_to(course_menu).perform
course_menu.should include_text('My Courses')
course_menu.should include_text('Customize')
@ -378,7 +378,7 @@ describe "dashboard" do
get "/"
course_menu = driver.find_element(:id, 'courses_menu_item')
course_menu = f('#courses_menu_item')
driver.action.move_to(course_menu).perform
course_menu.should include_text('My Courses')
course_menu.should include_text('Customize')
@ -394,7 +394,7 @@ describe "dashboard" do
get "/"
course_menu = driver.find_element(:id, 'courses_menu_item')
course_menu = f('#courses_menu_item')
driver.action.move_to(course_menu).perform
course_menu.should include_text('My Courses')
course_menu.should include_text('Customize')
@ -410,7 +410,7 @@ describe "dashboard" do
# be enough.
UsersController.before_filter { sleep 1; true }
course_menu = driver.find_element(:id, 'courses_menu_item')
course_menu = f('#courses_menu_item')
driver.execute_script(%{$("#menu li.menu-item:first").trigger('mouseenter')})
sleep 0.4 # there's a fixed 300ms delay before the menu will display

View File

@ -15,16 +15,17 @@ describe "default plugins" do
Twitter.stubs(:config_check).returns("Bad check")
get "/plugins/twitter"
driver.find_element(:css, "#plugin_setting_disabled").click
f("#plugin_setting_disabled").click
driver.find_element(:css, "#settings_api_key").send_keys("asdf")
driver.find_element(:css, "#settings_secret_key").send_keys("asdf")
driver.find_element(:css, "button.save_button").click
f("#settings_api_key").send_keys("asdf")
f("#settings_secret_key").send_keys("asdf")
submit_form('#new_plugin_setting')
assert_flash_error_message /There was an error/
Twitter.stubs(:config_check).returns(nil)
driver.find_element(:css, "button.save_button").click
submit_form('#new_plugin_setting')
wait_for_ajax_requests
assert_flash_notice_message /successfully updated/
@ -39,17 +40,18 @@ describe "default plugins" do
settings = Canvas::Plugin.find(:etherpad).try(:settings)
settings.should be_nil
get "/plugins/etherpad"
get "/plugins/etherpad"
driver.find_element(:css, "#plugin_setting_disabled").click
f("#plugin_setting_disabled").click
driver.find_element(:css, "#settings_domain").send_keys("asdf")
driver.find_element(:css, "button.save_button").click
f("#settings_domain").send_keys("asdf")
submit_form('#new_plugin_setting')
assert_flash_error_message /There was an error/
driver.find_element(:css, "#settings_name").send_keys("asdf")
driver.find_element(:css, "button.save_button").click
f("#settings_name").send_keys("asdf")
submit_form('#new_plugin_setting')
wait_for_ajax_requests
assert_flash_notice_message /successfully updated/
@ -67,16 +69,16 @@ describe "default plugins" do
GoogleDocs.stubs(:config_check).returns("Bad check")
get "/plugins/google_docs"
driver.find_element(:css, "#plugin_setting_disabled").click
f("#plugin_setting_disabled").click
driver.find_element(:css, "#settings_api_key").send_keys("asdf")
driver.find_element(:css, "#settings_secret_key").send_keys("asdf")
driver.find_element(:css, "button.save_button").click
f("#settings_api_key").send_keys("asdf")
f("#settings_secret_key").send_keys("asdf")
submit_form('#new_plugin_setting')
assert_flash_error_message /There was an error/
GoogleDocs.stubs(:config_check).returns(nil)
driver.find_element(:css, "button.save_button").click
submit_form('#new_plugin_setting')
wait_for_ajax_requests
assert_flash_notice_message /successfully updated/
@ -94,16 +96,16 @@ describe "default plugins" do
LinkedIn.stubs(:config_check).returns("Bad check")
get "/plugins/linked_in"
driver.find_element(:css, "#plugin_setting_disabled").click
f("#plugin_setting_disabled").click
driver.find_element(:css, "#settings_api_key").send_keys("asdf")
driver.find_element(:css, "#settings_secret_key").send_keys("asdf")
driver.find_element(:css, "button.save_button").click
f("#settings_api_key").send_keys("asdf")
f("#settings_secret_key").send_keys("asdf")
submit_form('#new_plugin_setting')
assert_flash_error_message /There was an error/
LinkedIn.stubs(:config_check).returns(nil)
driver.find_element(:css, "button.save_button").click
submit_form('#new_plugin_setting')
wait_for_ajax_requests
assert_flash_notice_message /successfully updated/
@ -121,18 +123,18 @@ describe "default plugins" do
ScribdAPI.stubs(:config_check).returns("Bad check")
get "/plugins/scribd"
driver.find_element(:css, "#plugin_setting_disabled").click
f("#plugin_setting_disabled").click
driver.find_element(:css, "#settings_api_key").send_keys("asdf")
driver.find_element(:css, "#settings_secret_key").send_keys("asdf")
f("#settings_api_key").send_keys("asdf")
f("#settings_secret_key").send_keys("asdf")
keep_trying_until {
driver.find_element(:css, "button.save_button").click
submit_form('#new_plugin_setting')
wait_for_ajaximations
assert_flash_error_message /There was an error/
}
ScribdAPI.stubs(:config_check).returns(nil)
driver.find_element(:css, "button.save_button").click
submit_form('#new_plugin_setting')
wait_for_ajax_requests
assert_flash_notice_message /successfully updated/
@ -150,16 +152,16 @@ describe "default plugins" do
Tinychat.stubs(:config_check).returns("Bad check")
get "/plugins/tinychat"
driver.find_element(:css, "#plugin_setting_disabled").click
f("#plugin_setting_disabled").click
driver.find_element(:css, "#settings_api_key").send_keys("asdf")
driver.find_element(:css, "#settings_secret_key").send_keys("asdf")
driver.find_element(:css, "button.save_button").click
f("#settings_api_key").send_keys("asdf")
f("#settings_secret_key").send_keys("asdf")
submit_form('#new_plugin_setting')
assert_flash_error_message /There was an error/
Tinychat.stubs(:config_check).returns(nil)
driver.find_element(:css, "button.save_button").click
submit_form('#new_plugin_setting')
wait_for_ajax_requests
assert_flash_notice_message /successfully updated/

View File

@ -68,25 +68,25 @@ describe "enhanceable_content" do
get "/courses/#{@course.id}/wiki/#{page.url}"
dialog = driver.find_element(:css, ".enhanceable_content.dialog")
dialog = f(".enhanceable_content.dialog")
# need to wait for the content to get enhanced (it happens in instructure.js in a setTimeout of 1000 ms)
keep_trying_until {
driver.find_element(:css, "#link1").click
f("#link1").click
dialog.should be_displayed
dialog.should have_class('ui-dialog')
}
driver.find_element(:css, ".ui-dialog .ui-dialog-titlebar-close").click
f(".ui-dialog .ui-dialog-titlebar-close").click
dialog.should_not be_displayed
driver.find_element(:css, ".enhanceable_content.draggable").should have_class('ui-draggable')
driver.find_element(:css, ".enhanceable_content.resizable").should have_class('ui-resizable')
f(".enhanceable_content.draggable").should have_class('ui-draggable')
f(".enhanceable_content.resizable").should have_class('ui-resizable')
ul = driver.find_element(:css, ".enhanceable_content.sortable")
ul = f(".enhanceable_content.sortable")
ul.should be_displayed
ul.should have_class('ui-sortable')
accordion = driver.find_element(:css, ".enhanceable_content.accordion")
accordion = f(".enhanceable_content.accordion")
accordion.should have_class('ui-accordion')
headers = accordion.find_elements(:css, ".ui-accordion-header")
headers.length.should eql(3)
@ -103,7 +103,7 @@ describe "enhanceable_content" do
divs[1].should be_displayed
tabs = driver.find_element(:css, ".enhanceable_content.tabs")
tabs = f(".enhanceable_content.tabs")
tabs.should have_class('ui-tabs')
headers = tabs.find_elements(:css, ".ui-tabs-nav li")
headers.length.should eql(3)

View File

@ -67,7 +67,7 @@ describe "eportfolios" do
f("#section_list_manage .add_section_link").click
f("#section_list input").send_keys("test section name", :return)
wait_for_ajax_requests
find_with_jquery("#section_list li:last-child .name").text.should eql "test section name"
fj("#section_list li:last-child .name").text.should eql "test section name"
end
it "should edit ePortfolio settings" do

View File

@ -8,20 +8,20 @@ describe "equation editor" do
course_with_teacher_logged_in
get "/courses/#{@course.id}/quizzes"
driver.find_element(:css, '.new-quiz-link').click
f('.new-quiz-link').click
def save_question_and_wait
submit_form('.question_form')
wait_for_ajaximations
end
wait_for_tiny(driver.find_element(:css, "#quiz_description"))
wait_for_tiny(f("#quiz_description"))
new_question_link = driver.find_element(:css, '.add_question_link')
new_question_link = f('.add_question_link')
2.times do |time|
new_question_link.click
questions = find_all_with_jquery(".question_holder:visible")
questions = ffj(".question_holder:visible")
questions.length.should eql(time + 1)
question = questions[time]
@ -30,7 +30,7 @@ describe "equation editor" do
equation_editor = keep_trying_until do
question.find_element(:css, '.mce_instructure_equation').click
sleep 1
equation_editor = find_with_jquery("#instructure_equation_prompt:visible")
equation_editor = fj("#instructure_equation_prompt:visible")
equation_editor.should_not be_nil
equation_editor
end
@ -40,7 +40,7 @@ describe "equation editor" do
save_question_and_wait
question.find_elements(:css, 'img.equation_image').size.should == 1
driver.find_element(:css, "#right-side .points_possible").text.should eql((time + 1).to_s)
f("#right-side .points_possible").text.should eql((time + 1).to_s)
end
end
end

View File

@ -31,11 +31,11 @@ describe "editing external tools" do
tool_elem = f("#external_tool_#{tool.id}")
tool_elem.find_element(:css, ".edit_tool_link").click
f("#external_tools_dialog").should be_displayed
replace_content(f("#external_tool_name"),"new tool (updated)")
replace_content(f("#external_tool_consumer_key"),"key (updated)")
replace_content(f("#external_tool_shared_secret"),"secret (updated)")
replace_content(f("#external_tool_name"), "new tool (updated)")
replace_content(f("#external_tool_consumer_key"), "key (updated)")
replace_content(f("#external_tool_shared_secret"), "secret (updated)")
replace_content(f("#external_tool_domain"), "example2.com")
replace_content(f("#external_tool_custom_fields_string"),"a=9\nb=8")
replace_content(f("#external_tool_custom_fields_string"), "a=9\nb=8")
f("#external_tools_dialog .save_button").click
wait_for_ajax_requests
f("#external_tools_dialog").should_not be_displayed
@ -74,7 +74,7 @@ describe "editing external tools" do
it "should not list external tools that don't have a url, domain, or resource_selection configured" do
@module = @course.context_modules.create!(:name => "module")
@tool1 = @course.context_external_tools.create!(:name => "First Tool", :url => "http://www.example.com", :consumer_key => "key", :shared_secret => "secret")
@tool2 = @course.context_external_tools.new(:name => "Another Tool", :consumer_key => "key", :shared_secret => "secret")
@tool2.settings[:editor_button] = {:url => "http://www.example.com", :icon_url => "http://www.example.com", :selection_width => 100, :selection_height => 100}.with_indifferent_access
@ -87,11 +87,11 @@ describe "editing external tools" do
keep_trying_until { driver.execute_script("return window.modules.refreshed == true") }
driver.find_element(:css, "#context_module_#{@module.id} .add_module_item_link").click
driver.find_element(:css, "#add_module_item_select option[value='context_external_tool']").click
keep_trying_until { driver.find_elements(:css, "#context_external_tools_select .tool .name").length > 0 }
names = driver.find_elements(:css, "#context_external_tools_select .tool .name").map(&:text)
f("#context_module_#{@module.id} .add_module_item_link").click
f("#add_module_item_select option[value='context_external_tool']").click
keep_trying_until { ff("#context_external_tools_select .tool .name").length > 0 }
names = ff("#context_external_tools_select .tool .name").map(&:text)
names.should be_include(@tool1.name)
names.should_not be_include(@tool2.name)
names.should be_include(@tool3.name)
@ -167,7 +167,7 @@ describe "editing external tools" do
tools[1].find_element(:css, ".name").text.should match(/not bob/)
tools[1].click
f("#external_tool_create_url").should have_value "https://www.example.com"
f("#external_tool_create_title").should have_value"not bob"
f("#external_tool_create_title").should have_value "not bob"
tools[0].click
keep_trying_until { f("#resource_selection_dialog").should be_displayed }
@ -213,7 +213,7 @@ describe "editing external tools" do
tools[0].click
keep_trying_until {f("#resource_selection_dialog").should be_displayed }
keep_trying_until { f("#resource_selection_dialog").should be_displayed }
expect_fired_alert do
in_frame('resource_selection_iframe') do
@ -229,7 +229,7 @@ describe "editing external tools" do
f("#external_tool_create_title").should have_value ""
tools[0].click
keep_trying_until {f("#resource_selection_dialog").should be_displayed }
keep_trying_until { f("#resource_selection_dialog").should be_displayed }
expect_fired_alert do
in_frame('resource_selection_iframe') do
@ -272,7 +272,7 @@ describe "editing external tools" do
f("#external_tool_create_title").should have_value "not bob"
tools[0].click
keep_trying_until {f("#resource_selection_dialog").should be_displayed }
keep_trying_until { f("#resource_selection_dialog").should be_displayed }
in_frame('resource_selection_iframe') do
keep_trying_until { ff("#basic_lti_link").length > 0 }
ff(".link").length.should eql 4

View File

@ -35,10 +35,10 @@ shared_examples_for "file uploads selenium tests" do
keep_trying_until { fj("#choose_migration_system").should be_displayed }
click_option('#choose_migration_system', 'common_cartridge_importer', :value)
driver.find_element(:css, '#config_options').find_element(:name, 'export_file').send_keys(fullpath)
f('#config_options').find_element(:name, 'export_file').send_keys(fullpath)
submit_form('#config_options')
wait_for_ajax_requests
keep_trying_until { driver.find_element(:id, 'file_uploaded').should be_displayed }
keep_trying_until { f('#file_uploaded').should be_displayed }
ContentMigration.for_context(@course).count.should == 1
cm = ContentMigration.for_context(@course).first
@ -68,13 +68,13 @@ shared_examples_for "file uploads selenium tests" do
driver.find_element(:name, 'attachments[0][uploaded_data]').send_keys(fullpath)
submit_form('#submit_online_upload_form')
keep_trying_until { driver.page_source =~ /Download #{Regexp.quote(filename)}<\/a>/ }
link = driver.find_element(:css, "div.details a.forward")
link = f(".details a.forward")
link.text.should eql("Submission Details")
expect_new_page_load { link.click }
keep_trying_until { driver.page_source =~ /Submission Details<\/h2>/ }
in_frame('preview_frame') do
driver.find_element(:css, '.centered-block .ui-listview .comment_attachment_link').click
f('.centered-block .ui-listview .comment_attachment_link').click
wait_for_ajax_requests
keep_trying_until { driver.page_source =~ /#{Regexp.quote(data)}/ }
end
@ -111,16 +111,16 @@ describe "file uploads local tests" do
JS
wait_for_ajax_requests
driver.find_element(:css, '#tree1 .folder').text.should eql("course files")
driver.find_element(:css, '#tree1 .folder .sign').click
f('#tree1 .folder').text.should eql("course files")
f('#tree1 .folder .sign').click
# work around bizarre bug where the click above doesn't register the first time
# when testing firefox on windows xp WITHOUT firebug installed. (works with firebug enabled!)
sign = find_with_jquery("#tree1 .folder .sign.minus")
sign = fj("#tree1 .folder .sign.minus")
sign.click if sign != nil
wait_for_ajax_requests
files = driver.find_elements(:css, '#tree1 .folder .file')
files = ff('#tree1 .folder .file')
if first_time
files.should be_empty
else
@ -129,9 +129,10 @@ describe "file uploads local tests" do
first_time = false
# upload the file
driver.find_element(:css, '.upload_new_file_link').click
driver.find_element(:id, 'attachment_uploaded_data').send_keys(fullpath)
driver.find_element(:css, '#sidebar_upload_file_form button').click
f('.upload_new_file_link').click
f('#attachment_uploaded_data').send_keys(fullpath)
submit_form('#sidebar_upload_file_form')
"sidebar_upload_file_form"
wait_for_ajax_requests
keep_trying_until { driver.execute_script("return $('#tree1 .leaf:contains(#{filename})').length") > 0 }

View File

@ -5,12 +5,12 @@ describe "google analytics" do
it "should not include tracking script if not asked to" do
get "/"
find_with_jquery('script[src$="google-analytics.com/ga.js"]').should be_nil
fj('script[src$="google-analytics.com/ga.js"]').should be_nil
end
it "should include tracking script if google_analytics_key is configured" do
Setting.set('google_analytics_key', 'testing123')
get "/"
find_with_jquery('script[src$="google-analytics.com/ga.js"]').should_not be_nil
fj('script[src$="google-analytics.com/ga.js"]').should_not be_nil
end
end

View File

@ -115,14 +115,14 @@ describe "grade exchange course settings tab" do
@course.save!
get "/courses/#{@course.id}/settings"
driver.find_element(:css, "a#tab-grade-publishing-link").click
f("#tab-grade-publishing-link").click
wait_for_ajaximations
driver.find_element(:css, "#publish_grades_messages").text.should == "Unpublished - 6"
f("#publish_grades_messages").text.should == "Unpublished - 6"
driver.execute_script "window.confirm = function(msg) { return true; }"
driver.find_element(:css, "#publish_grades_link").click
f("#publish_grades_link").click
wait_for_ajaximations
driver.find_element(:css, "#publish_grades_messages").text.should == (wait_for_success ? "Publishing - 6" : "Published - 6")
f("#publish_grades_messages").text.should == (wait_for_success ? "Publishing - 6" : "Published - 6")
server_thread.join
post_lines.should == [
@ -156,6 +156,6 @@ describe "grade exchange course settings tab" do
"#{getenroll("S4", "S1").id},error,Invalid user",
"#{Enrollment.find_by_user_id_and_course_section_id(@stud5.user.id, getsection("S3").id).id},error,Invalid user",
"#{Enrollment.find_by_user_id_and_course_section_id(@stud6.user.id, @sec4.id).id},error,")
keep_trying_until { driver.find_element(:css, "#publish_grades_messages").text.strip.split("\n").to_set == "Error: Invalid user - 2\nPublished - 2\nPublished: Grade modified - 1\nError - 1".split("\n").to_set }
keep_trying_until { f("#publish_grades_messages").text.strip.split("\n").to_set == "Error: Invalid user - 2\nPublished - 2\nPublished: Grade modified - 1\nError - 1".split("\n").to_set }
end
end

View File

@ -31,15 +31,14 @@ describe "group weights" do
end
group_weight_input = f("#assignment_group_#{assignment_group.id}_weight")
set_value(group_weight_input, weight_number)
save_button = find_with_jquery('.ui-dialog-buttonset .ui-button:contains("Save")')
save_button.click
fj('.ui-button:contains("Save")').click
wait_for_ajaximations
@course.reload.group_weighting_scheme.should == 'percent'
end
def validate_group_weight_text(assignment_groups, weight_numbers)
assignment_groups.each_with_index do |ag, i|
heading = find_with_jquery(".slick-column-name:contains('#{ag.name}') .assignment-points-possible")
heading = fj(".slick-column-name:contains('#{ag.name}') .assignment-points-possible")
heading.should include_text("#{weight_numbers[i]}% of grade")
end
end

View File

@ -17,18 +17,18 @@ describe "gradebooks" do
@student2 = @student
@assignment = assignment_model(
{
:course => @course,
:name => 'first assignment',
:due_at => nil,
:points_possible => 10,
:submission_types => 'online_text_entry,online_upload'
}
{
:course => @course,
:name => 'first assignment',
:due_at => nil,
:points_possible => 10,
:submission_types => 'online_text_entry,online_upload'
}
)
end
def switch_to_section(section_name="All")
driver.find_element(:id, "gradebook_options").click
f("#gradebook_options").click
driver.execute_script("$('#instructure_dropdown_list .option:last').click()")
click_option("#section-to-show", section_name)
@ -41,12 +41,12 @@ describe "gradebooks" do
wait_for_ajaximations
switch_to_section(@section1.display_name)
student_cell = driver.find_element(:id, "student_#{@student1.id}")
student_cell = f("#student_#{@student1.id}")
student_cell.should include_text @student1.sortable_name
student_cell.should include_text @section1.display_name
switch_to_section(@section2.display_name)
student_cell = driver.find_element(:id, "student_#{@student2.id}")
student_cell = f("#student_#{@student2.id}")
student_cell.should include_text @student2.sortable_name
student_cell.should include_text @section2.display_name
end
@ -57,19 +57,19 @@ describe "gradebooks" do
get "/courses/#{@course.id}/gradebook"
wait_for_ajaximations
student_cell = driver.find_element(:id, "student_#{@student1.id}")
student_cell = f("#student_#{@student1.id}")
student_cell.should include_text @student1.sortable_name
student_cell.should include_text @section1.display_name
student_cell.should include_text @section2.display_name
switch_to_section(@section1.display_name)
student_cell = driver.find_element(:id, "student_#{@student1.id}")
student_cell = f("#student_#{@student1.id}")
student_cell.should include_text @student1.sortable_name
student_cell.should include_text @section1.display_name
student_cell.should include_text @section2.display_name
switch_to_section(@section2.display_name)
student_cell = driver.find_element(:id, "student_#{@student1.id}")
student_cell = f("#student_#{@student1.id}")
student_cell.should include_text @student1.sortable_name
student_cell.should include_text @section1.display_name
student_cell.should include_text @section2.display_name
@ -84,14 +84,14 @@ describe "gradebooks" do
get "/courses/#{@course.id}/gradebook"
wait_for_ajaximations
ffj('img.turnitin:visible').size.should eql 2
ffj('.turnitin:visible').size.should eql 2
# now create a ton of students so that the data loads via ajax
100.times { |i| student_in_course(:active_all => true, :name => "other guy #{i}") }
get "/courses/#{@course.id}/gradebook"
wait_for_ajaximations
ffj('img.turnitin:visible').size.should eql 2
ffj('.turnitin:visible').size.should eql 2
end
it "should include student view student for grading" do

View File

@ -2,13 +2,13 @@ require File.expand_path(File.dirname(__FILE__) + '/common')
describe "grading standards" do
it_should_behave_like "in-process server selenium tests"
it "should allow creating/deleting grading standards" do
course_with_teacher_logged_in
get "/courses/#{@course.id}/grading_standards"
driver.find_element(:css, ".add_standard_link").click
standard = driver.find_element(:css, "#grading_standard_new")
f(".add_standard_link").click
standard = f("#grading_standard_new")
standard.should_not be_nil
standard.attribute(:class).should match(/editing/)
standard.find_elements(:css, ".delete_row_link").select(&:displayed?).each_with_index do |link, i|
@ -23,42 +23,42 @@ describe "grading standards" do
keep_trying_until { !standard.attribute(:class).match(/editing/) }
standard.find_elements(:css, ".grading_standard_row").select(&:displayed?).length.should eql(6)
standard.find_element(:css, ".standard_title .title").text.should eql("New Standard")
id = standard.attribute(:id)
standard.find_element(:css, ".delete_grading_standard_link").click
driver.switch_to.alert.accept
driver.switch_to.default_content
keep_trying_until { !(driver.find_element(:css, "##{id}") rescue nil) }
keep_trying_until { !(f("##{id}") rescue nil) }
end
it "should allow setting a grading standard for an assignment" do
skip_if_ie("Out of memory")
course_with_teacher_logged_in
@assignment = @course.assignments.create!(:title => "new assignment")
@standard = @course.grading_standards.create!(:title => "some standard", :standard_data => {:a => {:name => 'A', :value => '95'}, :b => {:name => 'B', :value => '80'}, :f => {:name => 'F', :value => ''}})
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
driver.find_element(:css, ".edit_full_assignment_link").click
form = driver.find_element(:css, "#edit_assignment_form")
f(".edit_full_assignment_link").click
form = f("#edit_assignment_form")
form.find_element(:css, ".more_options_link").click
form.find_element(:css, ".grading_type option[value='letter_grade']").click
form.find_element(:css, ".edit_letter_grades_link").displayed?.should be_true
form.find_element(:css, ".edit_letter_grades_link").click
dialog = driver.find_element(:css, "#edit_letter_grades_form")
dialog = f("#edit_letter_grades_form")
dialog.find_elements(:css, ".grading_standard_row").select(&:displayed?).length.should eql(12)
dialog.find_elements(:css, ".grading_standard_row").select(&:displayed?).map{|e| e.find_element(:css, ".name").text }.should eql(["A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "F"])
dialog.find_elements(:css, ".grading_standard_row").select(&:displayed?).map { |e| e.find_element(:css, ".name").text }.should eql(["A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "F"])
dialog.find_element(:css, ".find_grading_standard_link").click
keep_trying_until { driver.find_element(:css, ".find_grading_standard").attribute(:class).match(/loaded/) }
keep_trying_until { f(".find_grading_standard").should have_class("loaded") }
dialog.find_element(:css, ".find_grading_standard").displayed?.should be_true
dialog.find_element(:css, ".display_grading_standard").displayed?.should be_false
dialog.find_element(:css, ".cancel_find_grading_standard_link").click
dialog.find_element(:css, ".find_grading_standard").displayed?.should be_false
dialog.find_element(:css, ".display_grading_standard").displayed?.should be_true
dialog.find_element(:css, ".find_grading_standard_link").click
dialog.find_elements(:css, ".grading_standard_select .title")[-1].text.should eql(@standard.title)
dialog.find_elements(:css, ".grading_standard_select")[-1].click
dialog.find_element(:css, "#grading_standard_brief_#{@standard.id}").displayed?.should be_true
@ -68,27 +68,27 @@ describe "grading standards" do
dialog.find_element(:css, ".standard_title .title").text.should eql(@standard.title)
sleep 2
end
it "should allow setting a grading standard for a course" do
course_with_teacher_logged_in
@standard = @course.grading_standards.create!(:title => "some standard", :standard_data => {:a => {:name => 'A', :value => '95'}, :b => {:name => 'B', :value => '80'}, :f => {:name => 'F', :value => ''}})
get "/courses/#{@course.id}/details#tab-details"
driver.find_element(:css, ".edit_course_link").click
form = driver.find_element(:css, "#course_form")
f(".edit_course_link").click
form = f("#course_form")
form.find_element(:css, "#course_grading_standard_enabled").click
is_checked('#course_form #course_grading_standard_enabled').should be_true
form.find_element(:css, ".edit_letter_grades_link").displayed?.should be_true
form.find_element(:css, ".edit_letter_grades_link").click
dialog = driver.find_element(:css, "#edit_letter_grades_form")
dialog = f("#edit_letter_grades_form")
dialog.find_elements(:css, ".grading_standard_row").select(&:displayed?).length.should eql(12)
dialog.find_elements(:css, ".grading_standard_row").select(&:displayed?).map{|e| e.find_element(:css, ".name").text }.should eql(["A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "F"])
dialog.find_elements(:css, ".grading_standard_row").select(&:displayed?).map { |e| e.find_element(:css, ".name").text }.should eql(["A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "F"])
dialog.find_element(:css, ".find_grading_standard_link").click
keep_trying_until { driver.find_element(:css, ".find_grading_standard").attribute(:class).match(/loaded/) }
keep_trying_until { f(".find_grading_standard").should have_class("loaded") }
dialog.find_elements(:css, ".grading_standard_select .title")[-1].text.should eql(@standard.title)
dialog.find_elements(:css, ".grading_standard_select")[-1].click
(standard_brief = dialog.find_element(:css, "#grading_standard_brief_#{@standard.id}")).displayed?.should be_true
@ -110,7 +110,7 @@ describe "grading standards" do
driver.switch_to.alert.accept
driver.switch_to.default_content
keep_trying_until { !dialog.displayed? }
is_checked('#course_form #course_grading_standard_enabled').should be_false
end
@ -125,21 +125,21 @@ describe "grading standards" do
get "/courses/#{@course.id}/grades/#{student.id}"
grading_scheme = driver.execute_script "return grading_scheme"
grading_scheme[2][0].should == 'B+'
driver.find_element(:css, '#right-side .final_grade .grade').text.should == '89.9'
driver.find_element(:css, '#final_letter_grade_text').text.should == 'B+'
f('#right-side .final_grade .grade').text.should == '89.9'
f('#final_letter_grade_text').text.should == 'B+'
end
it "should allow editing the standard again without reloading the page" do
user_session(account_admin_user)
@standard = Account.default.grading_standards.create!(:title => "some standard", :standard_data => {:a => {:name => 'A', :value => '95'}, :b => {:name => 'B', :value => '80'}, :f => {:name => 'F', :value => ''}})
get("/accounts/#{Account.default.id}/grading_standards")
std = keep_trying_until { driver.find_element(:css, "#grading_standard_#{@standard.id}") }
std = keep_trying_until { f("#grading_standard_#{@standard.id}") }
std.find_element(:css, ".edit_grading_standard_link").click
std.find_element(:css, "button.save_button").click
wait_for_ajax_requests
std = keep_trying_until { driver.find_element(:css, "#grading_standard_#{@standard.id}") }
std = keep_trying_until { f("#grading_standard_#{@standard.id}") }
std.find_element(:css, ".edit_grading_standard_link").click
std.find_element(:css, "button.save_button").click
std.find_element(:css, "button.save_button")
wait_for_ajax_requests
@standard.reload.data.length.should == 3
end

View File

@ -12,7 +12,7 @@ describe "groups" do
get "/courses/#{@course.id}/groups"
group_div = driver.find_element(:css, "#group_#{g1.id}")
group_div = f("#group_#{g1.id}")
group_div.find_element(:css, ".name").text.should == "some group"
group_div.find_element(:css, ".management a").click
@ -28,7 +28,7 @@ describe "groups" do
get "/courses/#{@course.id}/groups"
group_div = driver.find_element(:css, "#group_#{g1.id}")
group_div = f("#group_#{g1.id}")
group_div.find_element(:css, ".name").text.should == "my group"
group_div.find_element(:css, ".management a").click
@ -44,7 +44,7 @@ describe "groups" do
get "/courses/#{@course.id}/groups"
driver.find_elements(:css, "#group_#{g1.id}").should be_empty
ff("#group_#{g1.id}").should be_empty
end
it "should allow a student to create a group" do
@ -54,16 +54,16 @@ describe "groups" do
get "/courses/#{@course.id}/groups"
driver.find_element(:css, ".add_group_link").click
f(".add_group_link").click
wait_for_animations
driver.find_element(:id, "group_name").send_keys("My Group")
driver.find_elements(:css, "#group_join_level option").length.should == 2
driver.find_element(:id, "invitees_#{@student.id}").click
f("#group_name").send_keys("My Group")
ff("#group_join_level option").length.should == 2
f("#invitees_#{@student.id}").click
submit_form('#add_group_form')
wait_for_ajax_requests
new_group_el = find_with_jquery(".group:visible")
new_group_el = fj(".group:visible")
members_link = new_group_el.find_element(:css, ".members_count")
members_link.should include_text "2"
members_link.click

View File

@ -7,9 +7,9 @@ describe "help dialog" do
it "should work with no logged in user" do
Setting.set('show_feedback_link', 'true')
get "/logout"
driver.find_element(:css, '#footer .help_dialog_trigger').click
f('#footer .help_dialog_trigger').click
wait_for_ajaximations
driver.find_element(:css, "#help-dialog-options").should be_displayed
f("#help-dialog-options").should be_displayed
end
end
@ -21,16 +21,16 @@ describe "help dialog" do
it "should show the Help dialog when 'help' is clicked and feedback is enabled" do
get "/dashboard"
element_exists("#help-dialog").should be_false
driver.find_elements(:css, '.help_dialog_trigger').length.should == 0
ff('.help_dialog_trigger').length.should == 0
Setting.set('show_feedback_link', 'true')
get "/dashboard"
driver.find_elements(:css, '.help_dialog_trigger').length.should == 2
ff('.help_dialog_trigger').length.should == 2
element_exists("#help-dialog").should be_false
driver.find_element(:css, '.help_dialog_trigger').click
f('.help_dialog_trigger').click
wait_for_ajaximations
driver.find_element(:css, "#help-dialog").should be_displayed
driver.find_element(:css, "#help-dialog a[href='#teacher_feedback']").should be_displayed
f("#help-dialog").should be_displayed
f("#help-dialog a[href='#teacher_feedback']").should be_displayed
support_url = 'http://example.com/support'
Account.default.update_attribute(:settings, {:support_url => support_url})
@ -44,31 +44,31 @@ describe "help dialog" do
support_url = 'http://example.com/support'
Account.default.update_attribute(:settings, {:support_url => support_url})
get "/dashboard"
link = driver.find_element(:css, '.support_url')
link = f('.support_url')
link['href'].should == support_url
link['class'].should_not match 'help_dialog_trigger'
# if show_feedback_link is true hijack clicks on the footer help link to show help dialog
Setting.set('show_feedback_link', 'true')
get "/dashboard"
driver.find_element(:css, "#footer-links a[href='#{support_url}']").click
f("#footer-links a[href='#{support_url}']").click
wait_for_ajaximations
driver.find_element(:css, "#help-dialog").should be_displayed
f("#help-dialog").should be_displayed
end
it "should allow sending the teacher a message" do
Setting.set('show_feedback_link', 'true')
get "/courses/#{@course.id}"
element_exists("#help-dialog").should be_false
trigger = driver.find_element(:css, '.help_dialog_trigger')
trigger = f('.help_dialog_trigger')
trigger.should be_displayed
trigger.click
wait_for_ajaximations
driver.find_element(:css, "#help-dialog").should be_displayed
teacher_feedback_link = driver.find_element(:css, "#help-dialog a[href='#teacher_feedback']")
f("#help-dialog").should be_displayed
teacher_feedback_link = f("#help-dialog a[href='#teacher_feedback']")
teacher_feedback_link.should be_displayed
teacher_feedback_link.click
feedback_form = driver.find_element(:css, "#help-dialog #teacher_feedback")
feedback_form = f("#help-dialog #teacher_feedback")
feedback_form.find_element(:css, '[name="recipients[]"]')['value'].should == "course_#{@course.id}_admins"
feedback_form.find_element(:css, '[name="body"]').send_keys('test message')
submit_form(feedback_form)
@ -82,12 +82,12 @@ describe "help dialog" do
it "should allow submitting a ticket" do
Setting.set('show_feedback_link', 'true')
get "/dashboard"
driver.find_element(:css, '.help_dialog_trigger').click
f('.help_dialog_trigger').click
wait_for_ajaximations
create_ticket_link = driver.find_element(:css, "#help-dialog a[href='#create_ticket']")
create_ticket_link = f("#help-dialog a[href='#create_ticket']")
create_ticket_link.should be_displayed
create_ticket_link.click
create_ticket_form = driver.find_element(:css, "#help-dialog #create_ticket")
create_ticket_form = f("#help-dialog #create_ticket")
create_ticket_form.find_element(:css, 'input[name="error[subject]"]').send_keys('test subject')
create_ticket_form.find_element(:css, 'textarea[name="error[comments]"]').send_keys('test comments')
severity = 'blocks_what_i_need_to_do'
@ -111,9 +111,9 @@ describe "help dialog" do
it "should not show the 'Message teacher' button if not a student" do
Setting.set('show_feedback_link', 'true')
get "/dashboard"
driver.find_element(:css, '.help_dialog_trigger').click
f('.help_dialog_trigger').click
wait_for_ajaximations
driver.find_element(:css, "#help-dialog").should be_displayed
f("#help-dialog").should be_displayed
element_exists("#help-dialog a[href='#teacher_feedback']").should be_false
end
@ -123,19 +123,19 @@ describe "help dialog" do
get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}"
wait_for_ajaximations
driver.find_elements(:css, '.help_dialog_trigger').length.should == 0
ff('.help_dialog_trigger').length.should == 0
Setting.set('show_feedback_link', 'true')
get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}"
wait_for_ajaximations
trigger = driver.find_element(:css, '#gradebook_header .help_dialog_trigger')
trigger = f('#gradebook_header .help_dialog_trigger')
make_full_screen
trigger.location_once_scrolled_into_view
trigger.should be_displayed
trigger.click
wait_for_ajaximations
driver.find_element(:css, "#help-dialog").should be_displayed
driver.find_element(:css, "#help-dialog a[href='#create_ticket']").should be_displayed
f("#help-dialog").should be_displayed
f("#help-dialog a[href='#create_ticket']").should be_displayed
end
end
end

View File

@ -10,7 +10,7 @@ describe "jquery" do
get('/logout')
driver.execute_script("$(document.body).append('<input type=\"checkbox\" checked=\"checked\" id=\"checkbox_test\">')")
checkbox = driver.find_element(:id, 'checkbox_test')
checkbox = f('#checkbox_test')
driver.execute_script("return $('#checkbox_test').attr('checked');").should eql('checked')
checkbox.click

View File

@ -12,7 +12,7 @@ describe "jquery ui" do
driver.execute_script(<<-JS).should == true
return $('<div />').dialog().dialog('option', 'modal');
JS
driver.find_element(:css, ".ui-widget-overlay").should be_displayed
f(".ui-widget-overlay").should be_displayed
# make sure that hiding then showing the same dialog again, it still looks modal
driver.execute_script(<<-JS).should == true
@ -22,27 +22,27 @@ describe "jquery ui" do
.dialog('open')
.dialog('option', 'modal');
JS
driver.find_element(:css, ".ui-widget-overlay").should be_displayed
f(".ui-widget-overlay").should be_displayed
end
context "calendar widget" do
it "should let you replace content by selecting and typing instead of appending" do
get "/courses/#{@course.id}/assignments"
driver.find_element(:css, "a.add_assignment_link").click
f(".add_assignment_link").click
wait_for_animations
driver.find_element(:css, ".ui-datepicker-trigger").click
f(".ui-datepicker-trigger").click
wait_for_animations
driver.find_element(:css, ".ui-datepicker-time-hour").send_keys("12")
driver.find_element(:css, ".ui-datepicker-time-minute").send_keys("00")
driver.find_element(:css, ".ui-datepicker-ok").click
f(".ui-datepicker-time-hour").send_keys("12")
f(".ui-datepicker-time-minute").send_keys("00")
f(".ui-datepicker-ok").click
driver.find_element(:css, ".ui-datepicker-trigger").click
f(".ui-datepicker-trigger").click
wait_for_animations
driver.execute_script("$('#ui-datepicker-time-hour').select();")
driver.find_element(:id, "ui-datepicker-time-hour").send_keys('5')
driver.find_element(:id, "ui-datepicker-time-hour").attribute('value').should == "5"
f("#ui-datepicker-time-hour").send_keys('5')
f("#ui-datepicker-time-hour").attribute('value').should == "5"
end
end

View File

@ -13,14 +13,14 @@ describe "links" do
end
def find_link(link_css)
link_section = driver.find_element(:id, 'section-tabs')
link_section = f('#section-tabs')
link_element = link_section.find_element(:css, link_css)
link_element
end
it "should navigate user to home page after home link is clicked" do
expect_new_page_load { driver.find_element(:link, 'Home').click }
driver.find_element(:id, 'breadcrumbs').should include_text('Unnamed')
f('#breadcrumbs').should include_text('Unnamed')
end
it "should navigate user to announcements page after announcements link is clicked" do
@ -90,7 +90,7 @@ describe "links" do
end
def find_dashboard_link(link_holder_css, link_text)
link_section = driver.find_element(:css, link_holder_css)
link_section = f(link_holder_css)
link_element = link_section.find_element(:link, link_text)
link_element
end
@ -111,21 +111,21 @@ describe "links" do
describe "left side links" do
it "should navigate user to main page after canvas logo link is clicked" do
driver.find_element(:id, 'header-logo')
expect_new_page_load { driver.find_element(:id, 'header-logo').click }
driver.current_url.should == driver.find_element(:id, 'header-logo').attribute('href')
f('#header-logo')
expect_new_page_load { f('#header-logo').click }
driver.current_url.should == f('#header-logo').attribute('href')
end
it "should navigate user to assignments page after assignments link is clicked" do
validate_link(driver.find_element(:css, '#assignments_menu_item a'), 'Assignments')
validate_link(f('#assignments_menu_item a'), 'Assignments')
end
it "should navigate user to gradebook page after grades link is clicked" do
validate_link(driver.find_element(:css, '#grades_menu_item a'), 'Gradebook')
validate_link(f('#grades_menu_item a'), 'Gradebook')
end
it "should navigate user to the calendar page after calender link is clicked" do
validate_link(driver.find_element(:css, '#calendar_menu_item a'), 'My Calendar')
validate_link(f('#calendar_menu_item a'), 'My Calendar')
end
end
end

View File

@ -13,7 +13,7 @@ describe "manage groups" do
group_categories = create_categories @course
create_new_set_groups(@course.account, group_categories[0], group_categories[1], group_categories[1], group_categories[2])
get "/courses/#{@course.id}/groups"
group_divs = find_all_with_jquery("div.group_category")
group_divs = ffj(".group_category")
group_divs.size.should == 4 # three groups + blank
ids = group_divs.map { |div| div.attribute(:id) }
group_categories.each { |category| ids.should include("category_#{category.id}") }
@ -26,9 +26,9 @@ describe "manage groups" do
group_category2 = @course.group_categories.create(:name => "Other Groups")
create_new_set_groups(@course.account, group_category1, group_category1, group_category2)
get "/courses/#{@course.id}/groups"
find_all_with_jquery("div.group_category").size.should == 3
find_all_with_jquery("div.group_category.student_organized").size.should == 1
find_with_jquery("div.group_category.student_organized").attribute(:id).
ffj(".group_category").size.should == 3
ffj(".group_category.student_organized").size.should == 1
fj(".group_category.student_organized").attribute(:id).
should == "category_#{group_category1.id}"
end
@ -37,7 +37,7 @@ describe "manage groups" do
group_categories= create_categories @course
create_new_set_groups(@course.account, group_categories[0], group_categories[1], group_categories[1], group_categories[2])
get "/courses/#{@course.id}/groups"
group_divs = find_all_with_jquery("li.category")
group_divs = ffj("li.category")
group_divs.size.should == 3 # three groups, no blank on this one
labels = group_divs.map { |div| div.find_element(:css, "a").text }
group_categories.each { |category| labels.should include category.name }
@ -51,9 +51,9 @@ describe "manage groups" do
@course.groups.create(:name => "Group 2", :group_category => group_category1)
@course.groups.create(:name => "Group 3", :group_category => group_category2)
get "/courses/#{@course.id}/groups"
find_all_with_jquery("li.category").size.should == 2
find_all_with_jquery("li.category.student_organized").size.should == 1
find_with_jquery("li.category.student_organized a").text.should == group_category1.name
ffj("li.category").size.should == 2
ffj("li.category.student_organized").size.should == 1
fj("li.category.student_organized a").text.should == group_category1.name
end
it "should add new categories at the end of the tabs" do
@ -61,11 +61,11 @@ describe "manage groups" do
group_category = @course.group_categories.create(:name => "Existing Category")
@course.groups.create(:name => "Group 1", :group_category => group_category)
get "/courses/#{@course.id}/groups"
driver.find_elements(:css, "#category_list li").size.should == 1
ff("#category_list li").size.should == 1
# submit new category form
add_category(@course, 'New Category')
driver.find_elements(:css, "#category_list li").size.should == 2
driver.find_elements(:css, "#category_list li a").last.text.should == "New Category"
ff("#category_list li").size.should == 2
ff("#category_list li a").last.text.should == "New Category"
end
it "should keep the student organized category after any new categories" do
@ -74,26 +74,26 @@ describe "manage groups" do
@course.groups.create(:name => "Group 1", :group_category => group_category)
get "/courses/#{@course.id}/groups"
driver.find_elements(:css, "#category_list li").size.should == 1
ff("#category_list li").size.should == 1
# submit new category form
add_category(@course, 'New Category')
driver.find_elements(:css, "#category_list li").size.should == 2
driver.find_elements(:css, "#category_list li a").first.text.should eql "New Category"
driver.find_elements(:css, "#category_list li a").last.text.should eql group_category.name
ff("#category_list li").size.should == 2
ff("#category_list li a").first.text.should eql "New Category"
ff("#category_list li a").last.text.should eql group_category.name
end
it "should remove tab and sidebar entries for deleted category" do
groups_student_enrollment 3
group_category = @course.group_categories.create(:name => "Some Category")
get "/courses/#{@course.id}/groups"
find_with_jquery("#category_#{group_category.id}").should be_displayed
find_with_jquery("#sidebar_category_#{group_category.id}").should be_displayed
find_with_jquery("#category_#{group_category.id} .delete_category_link").click
fj("#category_#{group_category.id}").should be_displayed
fj("#sidebar_category_#{group_category.id}").should be_displayed
fj("#category_#{group_category.id} .delete_category_link").click
confirm_dialog = driver.switch_to.alert
confirm_dialog.accept
keep_trying_until do
find_with_jquery("#category_#{group_category.id}").should be_nil
find_with_jquery("#sidebar_category_#{group_category.id}").should be_nil
fj("#category_#{group_category.id}").should be_nil
fj("#sidebar_category_#{group_category.id}").should be_nil
end
end
@ -102,14 +102,14 @@ describe "manage groups" do
group_category = @course.group_categories.create(:name => "Existing Category")
group = @course.groups.create(:name => "Group 1", :group_category => group_category)
get "/courses/#{@course.id}/groups"
find_with_jquery("#sidebar_category_#{group_category.id}").should be_displayed
find_with_jquery("#sidebar_category_#{group_category.id} #sidebar_group_#{group.id}").should be_displayed
fj("#sidebar_category_#{group_category.id}").should be_displayed
fj("#sidebar_category_#{group_category.id} #sidebar_group_#{group.id}").should be_displayed
# submit new category form
new_category = add_category(@course, 'New Category', :group_count => '1')
new_category.groups.size.should == 1
new_group = new_category.groups.first
find_with_jquery("#sidebar_category_#{new_category.id}").should be_displayed
find_with_jquery("#sidebar_category_#{new_category.id} #sidebar_group_#{new_group.id}").should be_displayed
fj("#sidebar_category_#{new_category.id}").should be_displayed
fj("#sidebar_category_#{new_category.id} #sidebar_group_#{new_group.id}").should be_displayed
end
it "should honor enable_self_signup when adding a category" do
@ -143,13 +143,12 @@ describe "manage groups" do
group_category = @course.group_categories.create(:name => "Existing Category")
group = @course.groups.create(:name => "Group 1", :group_category => group_category)
get "/courses/#{@course.id}/groups"
find_with_jquery("#category_#{group_category.id} #group_#{group.id}").should be_displayed
fj("#category_#{group_category.id} #group_#{group.id}").should be_displayed
# submit new category form
driver.execute_script("$('#group_#{group.id} .edit_group_link').hover().click()") #move_to occasionally breaks in the hudson build
form = driver.find_element(:css, "#edit_group_form")
form.find_element(:css, "input[type=text]").clear
form.find_element(:css, "input[type=text]").send_keys("New Name")
form = f("#edit_group_form")
replace_content(form.find_element(:css, "input[type=text]"), "New Name")
submit_form(form)
find_with_jquery("#category_#{group_category.id} #group_#{group.id}").should be_displayed
fj("#category_#{group_category.id} #group_#{group.id}").should be_displayed
end
end

View File

@ -11,10 +11,10 @@ describe "manage groups students" do
it "should click on the self signup help link " do
@student = @course.enroll_student(user_model(:name => "John Doe")).user
get "/courses/#{@course.id}/groups"
driver.find_element(:css, ".add_category_link").click
form = driver.find_element(:css, "#add_category_form")
f(".add_category_link").click
form = f("#add_category_form")
form.find_element(:css, ".self_signup_help_link").click
driver.find_element(:id, "self_signup_help_dialog").should be_displayed
f("#self_signup_help_dialog").should be_displayed
end
it "should move students from a deleted group back to unassigned" do
@ -25,7 +25,7 @@ describe "manage groups students" do
group.add_user student
get "/courses/#{@course.id}/groups"
category = find_with_jquery(".group_category:visible")
category = fj(".group_category:visible")
category.find_elements(:css, ".group_blank .user_id_#{student.id}").should be_empty
driver.execute_script("$('#group_#{group.id} .delete_group_link').hover().click()") #move_to occasionally breaks in the hudson build
@ -51,11 +51,11 @@ describe "manage groups students" do
get "/courses/#{@course.id}/groups"
wait_for_ajaximations
sections = driver.find_element(:css, ".user_id_#{@student.id} .section_code")
sections = f(".user_id_#{@student.id} .section_code")
sections.should include_text(@course.default_section.name)
sections.should include_text(@other_section.name)
driver.find_element(:css, "#category_#{gc1.id} .group_blank .user_count").should include_text("1")
f("#category_#{gc1.id} .group_blank .user_count").should include_text("1")
end
it "should not show sections for students when managing from an account" do
@ -89,14 +89,14 @@ describe "manage groups students" do
get "/courses/#{@course.id}/groups"
wait_for_ajaximations
category = driver.find_element(:css, ".group_category")
category = f(".group_category")
unassigned_div = category.find_element(:css, ".group_blank")
unassigned_div.find_element(:css, ".user_count").should include_text(students_count.to_s)
unassigned_div.find_elements(:css, ".student").length.should == 15
# 15 comes from window.contextGroups.autoLoadGroupThreshold
driver.find_element(:css, ".next_page").click
f(".next_page").click
wait_for_ajaximations
unassigned_div.find_element(:css, ".user_count").should include_text(students_count.to_s)
@ -110,7 +110,7 @@ describe "manage groups students" do
get "/courses/#{@course.id}/groups"
wait_for_ajaximations
find_all_with_jquery(".group_category:visible .user_id_#{@fake_student.id}").should be_empty
ffj(".group_category:visible .user_id_#{@fake_student.id}").should be_empty
end
it "should not include student view student in the unassigned student list at the account level" do
@ -122,7 +122,7 @@ describe "manage groups students" do
get "/accounts/#{@account.id}/groups"
wait_for_ajaximations
find_all_with_jquery(".group_category:visible .user_id_#{@fake_student.id}").should be_empty
ffj(".group_category:visible .user_id_#{@fake_student.id}").should be_empty
end
context "dragging a user between groups" do
@ -132,7 +132,7 @@ describe "manage groups students" do
group_category = @course.group_categories.create(:name => "Other Groups")
groups = add_groups_in_category group_category, 2
get "/courses/#{@course.id}/groups"
category = driver.find_element(:css, ".group_category")
category = f(".group_category")
unassigned_div = category.find_element(:css, ".group_blank")
group1_div = category.find_element(:css, "#group_#{groups[0].id}")
group2_div = category.find_element(:css, "#group_#{groups[1].id}")
@ -165,7 +165,7 @@ describe "manage groups students" do
groups = add_groups_in_category group_category, 2
get "/courses/#{@course.id}/groups"
category = driver.find_element(:css, ".group_category")
category = f(".group_category")
unassigned_div = category.find_element(:css, ".group_blank")
group1_div = category.find_element(:css, "#group_#{groups[0].id}")
group2_div = category.find_element(:css, "#group_#{groups[1].id}")
@ -205,7 +205,7 @@ describe "manage groups students" do
groups = add_groups_in_category group_category, 3
get "/courses/#{@course.id}/groups"
wait_for_ajaximations
category_div = driver.find_element(:css, ".group_category")
category_div = f(".group_category")
group1_div = category_div.find_element(:css, "#group_#{groups[0].id}")
group2_div = category_div.find_element(:css, "#group_#{groups[1].id}")
group3_div = category_div.find_element(:css, "#group_#{groups[2].id}")
@ -255,22 +255,22 @@ describe "manage groups students" do
simulate_group_drag(@students[0].id, "blank", group.id)
wait_for_ajaximations
driver.find_element(:css, ".unassigned_members_pagination .next_page").click
f(".unassigned_members_pagination .next_page").click
wait_for_ajaximations
driver.find_elements(:css, ".group_blank .student").length.should == 15
ff(".group_blank .student").length.should == 15
end
end
context "assign_students_link" do
def assign_students(category)
assign_students = find_with_jquery("#category_#{category.id} .assign_students_link:visible")
assign_students = fj("#category_#{category.id} .assign_students_link:visible")
assign_students.should_not be_nil
assign_students.click
confirm_dialog = driver.switch_to.alert
confirm_dialog.accept
wait_for_ajax_requests
keep_trying_until { driver.find_element(:css, '.right_side .group .user_count').text.should eql '0 students' }
keep_trying_until { f('.right_side .group .user_count').text.should eql '0 students' }
end
before (:each) do
@ -282,21 +282,21 @@ describe "manage groups students" do
it "should be visible iff category is not restricted self signup" do
skip_if_ie("Element must not be hidden, disabled or read-only line 378")
new_category = add_category(@course, "Unrestricted Self-Signup Category", :enable_self_signup => true, :restrict_self_signup => false)
find_with_jquery("#category_#{new_category.id} .assign_students_link:visible").should_not be_nil
fj("#category_#{new_category.id} .assign_students_link:visible").should_not be_nil
edit_category(:restrict_self_signup => true)
find_with_jquery("#category_#{new_category.id} .assign_students_link:visible").should be_nil
fj("#category_#{new_category.id} .assign_students_link:visible").should be_nil
new_category = add_category(@course, "Restricted Self-Signup Category", :enable_self_signup => true, :restrict_self_signup => true)
find_with_jquery("#category_#{new_category.id} .assign_students_link:visible").should be_nil
fj("#category_#{new_category.id} .assign_students_link:visible").should be_nil
edit_category(:restrict_self_signup => false)
find_with_jquery("#category_#{new_category.id} .assign_students_link:visible").should_not be_nil
fj("#category_#{new_category.id} .assign_students_link:visible").should_not be_nil
end
it "should assign students in DB and in UI" do
expected_display_name = 'Doe, John'
keep_trying_until { driver.find_element(:css, '.right_side .student_list .student .name').should include_text(expected_display_name) }
keep_trying_until { f('.right_side .student_list .student .name').should include_text(expected_display_name) }
@student.groups.should be_empty
assign_students(@category)
@ -305,14 +305,14 @@ describe "manage groups students" do
keep_trying_until { @student.groups.size.should == 1 }
group = @student.groups.first
driver.find_element(:css, '.right_side .student_list').should_not include_text(expected_display_name)
group_element = find_with_jquery("#category_#{@category.id} #group_#{group.id} .user_id_#{@student.id}")
f('.right_side .student_list').should_not include_text(expected_display_name)
group_element = fj("#category_#{@category.id} #group_#{group.id} .user_id_#{@student.id}")
group_element.should_not be_nil
group_element.should include_text(expected_display_name)
end
it "should give 'Assigning Students...' visual feedback" do
assign_students = find_with_jquery("#category_#{@category.id} .assign_students_link:visible")
assign_students = fj("#category_#{@category.id} .assign_students_link:visible")
assign_students.should_not be_nil
assign_students.click
# Do some magic to make sure the next ajax request doesn't complete until we're ready for it to
@ -321,7 +321,7 @@ describe "manage groups students" do
GroupsController.before_filter { lock.lock; lock.unlock; true }
confirm_dialog = driver.switch_to.alert
confirm_dialog.accept
loading = find_with_jquery("#category_#{@category.id} .group_blank .loading_members:visible")
loading = fj("#category_#{@category.id} .group_blank .loading_members:visible")
loading.text.should == 'Assigning Students...'
lock.unlock
GroupsController.filter_chain.pop
@ -349,23 +349,23 @@ describe "manage groups students" do
it "should add multiple groups and be sure they are all deleted" do
add_groups_in_category @courses_group_category
get "/courses/#{@course.id}/groups"
delete = driver.find_element(:css, ".delete_category_link")
delete = f(".delete_category_link")
delete.click
confirm_dialog = driver.switch_to.alert
confirm_dialog.accept
wait_for_ajaximations
driver.find_elements(:css, ".left_side .group").should be_empty
ff(".left_side .group").should be_empty
@course.group_categories.all.count.should eql 0
end
it "should edit an individual group" do
get "/courses/#{@course.id}/groups"
group = add_group_to_category @courses_group_category, "group 1"
driver.find_element(:css, "#group_#{group.id}").click
driver.find_element(:css, "#group_#{group.id} .edit_group_link").click
f("#group_#{group.id}").click
f("#group_#{group.id} .edit_group_link").click
name = "new group 1"
driver.find_element(:css, "#group_name").send_keys(name)
driver.find_element(:css, "#group_#{group.id} .button").click
f("#group_name").send_keys(name)
submit_form("#edit_group_form")
wait_for_ajaximations
new_group = @course.groups.find_by_name(name)
group.should_not be_nil
@ -374,12 +374,12 @@ describe "manage groups students" do
it "should delete an individual group" do
get "/courses/#{@course.id}/groups"
group = add_group_to_category @courses_group_category, "group 1"
driver.find_element(:css, "#group_#{group.id}").click
driver.find_element(:css, "#group_#{group.id} .delete_group_link").click
f("#group_#{group.id}").click
f("#group_#{group.id} .delete_group_link").click
confirm_dialog = driver.switch_to.alert
confirm_dialog.accept
wait_for_ajaximations
driver.find_elements(:css, ".left_side .group").should be_empty
ff(".left_side .group").should be_empty
@course.group_categories.last.groups.last.workflow_state =='deleted'
end
end

View File

@ -35,9 +35,9 @@ describe "oauth2 flow" do
it "should show the confirmation dialog after logging in" do
get "/login/oauth2/auth?response_type=code&client_id=#{@client_id}&redirect_uri=urn:ietf:wg:oauth:2.0:oob"
driver.current_url.should match(%r{/login$})
user_element = driver.find_element(:css, '#pseudonym_session_unique_id')
user_element = f('#pseudonym_session_unique_id')
user_element.send_keys("nobody@example.com")
password_element = driver.find_element(:css, '#pseudonym_session_password')
password_element = f('#pseudonym_session_password')
password_element.send_keys("asdfasdf")
password_element.submit
f('#modal-box').text.should match(%r{Specs is requesting access to your account})

View File

@ -7,18 +7,18 @@ describe "people" do
def add_user(option_text, username, user_list_selector)
click_option('#enrollment_type', option_text)
driver.find_element(:css, 'textarea.user_list').send_keys(username)
find_with_jquery('.verify_syntax_button').click
f('textarea.user_list').send_keys(username)
fj('.verify_syntax_button').click
wait_for_ajax_requests
driver.find_element(:id, 'user_list_parsed').should include_text(username)
driver.find_element(:css, '.add_users_button').click
f('#user_list_parsed').should include_text(username)
f('.add_users_button').click
wait_for_ajaximations
driver.find_element(:css, user_list_selector).should include_text(username)
f(user_list_selector).should include_text(username)
end
def open_student_group_dialog
driver.find_element(:css, '.add_category_link').click
dialog = find_with_jquery('.ui-dialog:visible')
f('.add_category_link').click
dialog = fj('.ui-dialog:visible')
dialog.should be_displayed
dialog
end
@ -26,12 +26,12 @@ describe "people" do
def create_student_group(group_text = "new student group")
expect_new_page_load { driver.find_element(:link, 'View User Groups').click }
open_student_group_dialog
inputs = find_all_with_jquery('input:visible')
inputs = ffj('input:visible')
inputs[0].clear
inputs[0].send_keys(group_text)
submit_form('#add_category_form')
wait_for_ajaximations
driver.find_element(:css, '#category_list').should include_text(group_text)
f('#category_list').should include_text(group_text)
end
def enroll_student(student)
@ -91,20 +91,20 @@ describe "people" do
end
it "should validate the main page" do
users = driver.find_elements(:css, '.user_name')
users = ff('.user_name')
users[0].text.should == @teacher.name
users[1].text.should == @student_1.name
end
it "should navigate to registered services on profile page" do
driver.find_element(:link, I18n.t('links.view_services', 'View Registered Services')).click
driver.find_element(:link, I18n.t('links.link_service', 'Link web services to my account')).click
driver.find_element(:id, 'unregistered_services').should be_displayed
driver.find_element(:link, 'View Registered Services').click
driver.find_element(:link, 'Link web services to my account').click
f('#unregistered_services').should be_displayed
end
it "should add a teacher, ta, student, and observer" do
expect_new_page_load { driver.find_element(:link, 'Manage Users').click }
add_users_button = driver.find_element(:css, '.add_users_link')
add_users_button = f('.add_users_link')
add_users_button.click
add_user('Teachers', @test_teacher.name, 'ul.user_list.teacher_enrollments')
add_user("Students", @student_2.name, 'ul.user_list.student_enrollments')
@ -119,8 +119,8 @@ describe "people" do
it "should test self sign up help functionality" do
expect_new_page_load { driver.find_element(:link, 'View User Groups').click }
open_student_group_dialog
find_with_jquery('a.self_signup_help_link:visible').click
help_dialog = driver.find_element(:css, '#self_signup_help_dialog')
fj('.self_signup_help_link:visible').click
help_dialog = f('#self_signup_help_dialog')
help_dialog.should be_displayed
end
@ -140,7 +140,7 @@ describe "people" do
dialog.find_element(:css, '#category_create_group_count').send_keys(group_count)
submit_form('#add_category_form')
wait_for_ajaximations
driver.find_elements(:css, '.left_side .group_name').count.should == group_count.to_i
ff('.left_side .group_name').count.should == group_count.to_i
end
it "should test group structure functionality" do
@ -153,23 +153,23 @@ describe "people" do
dialog.find_element(:css, '#category_split_group_count').send_keys(group_count)
submit_form('#add_category_form')
wait_for_ajaximations
driver.find_elements(:css, '.left_side .group_name').count.should == group_count.to_i
ff('.left_side .group_name').count.should == group_count.to_i
end
it "should edit a student group" do
new_group_name = "new group edit name"
create_student_group
driver.find_element(:css, '.edit_category_link').click
edit_form = driver.find_element(:css, '#edit_category_form')
f('.edit_category_link').click
edit_form = f('#edit_category_form')
edit_form.find_element(:css, 'input#category_name').send_keys(new_group_name)
submit_form(edit_form)
wait_for_ajaximations
find_with_jquery("h3.category_name").text.should == new_group_name
fj(".category_name").text.should == new_group_name
end
it "should delete a student group" do
create_student_group
driver.find_element(:css, '.delete_category_link').click
f('.delete_category_link').click
keep_trying_until do
driver.switch_to.alert.should_not be_nil
driver.switch_to.alert.accept
@ -177,7 +177,7 @@ describe "people" do
end
wait_for_ajaximations
refresh_page
driver.find_element(:css, '#no_groups_message').should be_displayed
f('#no_groups_message').should be_displayed
end
it "should randomly assign students" do
@ -192,11 +192,11 @@ describe "people" do
submit_form('#add_category_form')
wait_for_ajaximations
group_count.times do
driver.find_element(:css, '.add_group_link').click
driver.find_element(:css, '.button-container > .small-button').click
f('.add_group_link').click
f('.button-container > .small-button').click
wait_for_ajaximations
end
driver.find_element(:css, '.assign_students_link').click
f('.assign_students_link').click
keep_trying_until do
driver.switch_to.alert.should_not be_nil
driver.switch_to.alert.accept
@ -204,16 +204,16 @@ describe "people" do
end
wait_for_ajax_requests
assert_flash_notice_message /Students assigned to groups/
driver.find_element(:css, '.right_side .user_count').text.should == expected_student_count
f('.right_side .user_count').text.should == expected_student_count
end
it "should test prior enrollment functionality" do
expect_new_page_load { driver.find_element(:link, 'Manage Users').click }
expect_new_page_load { driver.find_element(:link, 'End this Course').click }
expect_new_page_load { driver.find_element(:css, '.button-container > .big-button').click }
expect_new_page_load { f('.button-container .big-button').click }
get "/courses/#{@course.id}/users"
expect_new_page_load { driver.find_element(:link, 'View Prior Enrollments').click }
driver.find_element(:css, '#users').should include_text(@student_1.name)
f('#users').should include_text(@student_1.name)
end
def link_to_student(enrollment, student)
@ -292,7 +292,7 @@ describe "people" do
pending('bug 7106 - do not allow TA to edit teachers name') do
teacher_enrollment = teacher_in_course(:name => 'teacher@example.com')
get "/courses/#{@course.id}/users/#{teacher_enrollment.user.id}"
driver.find_element(:css, '.edit_user_link').should_not be_displayed
f('.edit_user_link').should_not be_displayed
end
end
end

View File

@ -8,7 +8,8 @@ describe "plugins ui" do
get '/plugins/etherpad'
is_checked('#plugin_setting_disabled').should be_true
expect_new_page_load { driver.find_element(:css, "button.save_button").click }
expect_new_page_load { submit_form("#new_plugin_setting") }
PluginSetting.all.count.should == 1
PluginSetting.first.tap do |ps|
ps.name.should == "etherpad"
@ -20,8 +21,8 @@ describe "plugins ui" do
truncate_table PluginSetting
get '/plugins/etherpad'
is_checked('#plugin_setting_disabled').should be_true
driver.find_element(:css, '#plugin_setting_disabled').click
expect_new_page_load { driver.find_element(:css, "button.save_button").click }
f('#plugin_setting_disabled').click
expect_new_page_load { submit_form("#new_plugin_setting") }
PluginSetting.all.count.should == 1
PluginSetting.first.tap do |ps|
ps.name.should == "etherpad"

View File

@ -6,28 +6,28 @@ describe "profile" do
it_should_behave_like "in-process server selenium tests"
def click_edit
driver.find_element(:css, '.edit_profile_link').click
edit_form = driver.find_element(:id, 'update_profile_form')
f('.edit_profile_link').click
edit_form = f('#update_profile_form')
keep_trying_until { edit_form.should be_displayed }
edit_form
end
def add_skype_service
driver.find_element(:css, '#unregistered_service_skype > a').click
skype_dialog = driver.find_element(:id, 'unregistered_service_skype_dialog')
f('#unregistered_service_skype > a').click
skype_dialog = f('#unregistered_service_skype_dialog')
skype_dialog.find_element(:id, 'user_service_user_name').send_keys("jakesorce")
driver.find_element(:css, '#unregistered_service_skype_dialog .button').click
submit_dialog('#unregistered_service_skype_dialog', '.button')
wait_for_ajaximations
driver.find_element(:id, 'registered_services').should include_text("Skype")
f('#registered_services').should include_text("Skype")
end
def generate_access_token(purpose = 'testing', close_dialog = false)
driver.find_element(:css, '.add_access_token_link').click
access_token_form = driver.find_element(:id, 'access_token_form')
f('.add_access_token_link').click
access_token_form = f('#access_token_form')
access_token_form.find_element(:id, 'access_token_purpose').send_keys(purpose)
submit_form(access_token_form)
wait_for_ajax_requests
details_dialog = driver.find_element(:id, 'token_details_dialog')
details_dialog = f('#token_details_dialog')
details_dialog.should be_displayed
if close_dialog
close_visible_dialog
@ -51,7 +51,7 @@ describe "profile" do
# check to see if error box popped up
errorboxes = ff('.error_text')
errorboxes.length.should > 1
errorboxes.any? {|errorbox| errorbox.text =~ /Invalid old password for the login/}.should be_true
errorboxes.any? { |errorbox| errorbox.text =~ /Invalid old password for the login/ }.should be_true
end
it "should change the password" do
@ -107,11 +107,11 @@ describe "profile" do
it "should change default email address" do
channel = @user.communication_channels.create!(:path_type => 'email',
:path => 'walter_white@example.com')
:path => 'walter_white@example.com')
channel.confirm!
get '/profile/settings'
row = f("#channel_#{channel.id}")
row = f("#channel_#{channel.id}")
link = f("#channel_#{channel.id} td:first-child a")
link.click
wait_for_ajaximations
@ -120,8 +120,8 @@ describe "profile" do
it "should display file uploader link on files page" do
get "/profile/settings"
expect_new_page_load { driver.find_element(:css, '#left-side .files').click }
driver.find_element(:id, 'file_swf-button').should be_displayed
expect_new_page_load { f('#left-side .files').click }
f('#file_swf-button').should be_displayed
end
it "should edit full name" do
@ -131,7 +131,7 @@ describe "profile" do
edit_form.find_element(:id, 'user_name').send_keys(new_user_name)
submit_form(edit_form)
wait_for_ajaximations
keep_trying_until { driver.find_element(:css, '.full_name').text.should == new_user_name }
keep_trying_until { f('.full_name').text.should == new_user_name }
end
it "should edit display name and validate" do
@ -142,7 +142,7 @@ describe "profile" do
submit_form(edit_form)
wait_for_ajaximations
refresh_page
keep_trying_until { driver.find_element(:css, '#topbar li.user_name').text.should == new_display_name }
keep_trying_until { f('#topbar li.user_name').text.should == new_display_name }
end
it "should change the language" do
@ -150,7 +150,7 @@ describe "profile" do
edit_form = click_edit
click_option('#user_locale', 'Español')
expect_new_page_load { submit_form(edit_form) }
driver.find_element(:css, '.profile_table').should include_text('Nombre')
f('.profile_table').should include_text('Nombre')
end
it "should change the language even if you can't update your name" do
@ -163,20 +163,20 @@ describe "profile" do
edit_form.find_elements(:id, 'user_short_name').first.should be_nil
click_option('#user_locale', 'Español')
expect_new_page_load { submit_form(edit_form) }
driver.find_element(:css, '.profile_table').should include_text('Nombre')
f('.profile_table').should include_text('Nombre')
end
it "should add another contact method - sms" do
test_cell_number = '8017121011'
get "/profile/settings"
driver.find_element(:css, '.add_contact_link').click
register_form = driver.find_element(:id, 'register_sms_number')
f('.add_contact_link').click
register_form = f('#register_sms_number')
register_form.find_element(:css, '.sms_number').send_keys(test_cell_number)
click_option('select.user_selected.carrier', 'AT&T')
submit_form(register_form)
wait_for_ajaximations
close_visible_dialog
keep_trying_until { driver.find_element(:css, '.other_channels .path').should include_text(test_cell_number) }
keep_trying_until { f('.other_channels .path').should include_text(test_cell_number) }
end
it "should register a service" do
@ -189,11 +189,11 @@ describe "profile" do
add_skype_service
#had to use add class because tests were failing inconsistently in aws
driver.execute_script("$('.service').addClass('service-hover')")
driver.find_element(:css, '.delete_service_link').click
f('.delete_service_link').click
driver.switch_to.alert.should_not be_nil
driver.switch_to.alert.accept
wait_for_ajaximations
driver.find_element(:id, 'unregistered_services').should include_text("Skype")
f('#unregistered_services').should include_text("Skype")
end
it "should toggle service visibility" do
@ -201,11 +201,11 @@ describe "profile" do
add_skype_service
initial_state = @user.show_user_services
driver.find_element(:id, 'show_user_services').click
f('#show_user_services').click
wait_for_ajaximations
@user.reload.show_user_services.should_not eql initial_state
driver.find_element(:id, 'show_user_services').click
f('#show_user_services').click
wait_for_ajaximations
@user.reload.show_user_services.should eql initial_state
end
@ -217,8 +217,8 @@ describe "profile" do
it "should test canceling creating a new access token" do
get "/profile/settings"
driver.find_element(:css, '.add_access_token_link').click
access_token_form = driver.find_element(:id, 'access_token_form')
f('.add_access_token_link').click
access_token_form = f('#access_token_form')
access_token_form.find_element(:css, '.cancel_button').click
access_token_form.should_not be_displayed
end
@ -227,19 +227,19 @@ describe "profile" do
get "/profile/settings"
generate_access_token('testing', true)
#had to use :visible because it was failing saying element wasn't visible
find_with_jquery('#access_tokens .show_token_link:visible').click
driver.find_element(:id, 'token_details_dialog').should be_displayed
fj('#access_tokens .show_token_link:visible').click
f('#token_details_dialog').should be_displayed
end
it "should delete an access token" do
get "/profile/settings"
generate_access_token('testing', true)
#had to use :visible because it was failing saying element wasn't visible
find_with_jquery("#access_tokens .delete_key_link:visible").click
fj("#access_tokens .delete_key_link:visible").click
driver.switch_to.alert.should_not be_nil
driver.switch_to.alert.accept
wait_for_ajaximations
driver.find_element(:id, 'access_tokens').should_not be_displayed
f('#access_tokens').should_not be_displayed
end
it "should set the birthdate" do
@ -262,9 +262,9 @@ describe "profile" do
click_option('#user_birthdate_3i', '2')
submit_form(edit_form)
wait_for_ajaximations
edit_form.should be_displayed # not dismissed
edit_form.should be_displayed # not dismissed
@user.reload
@user.birthdate.should be_nil # no default year assumed
@user.birthdate.should be_nil # no default year assumed
end
it "should not allow the birthdate to be un-set" do

View File

@ -11,7 +11,7 @@ describe "quizzes question banks" do
bank = AssessmentQuestionBank.create!(:context => @course)
get "/courses/#{@course.id}/question_banks/#{bank.id}"
driver.find_element(:css, '.add_question_link').click
f('.add_question_link').click
wait_for_animations
expect { create_multiple_choice_question }.to change(AssessmentQuestion, :count).by(1)
@ -25,13 +25,13 @@ describe "quizzes question banks" do
harder.question_data[:points_possible] = 15
harder.save!
get "/courses/#{@course.id}/quizzes/#{quiz.id}/edit"
find_questions_link = driver.find_element(:css, '.find_question_link')
find_questions_link = f('.find_question_link')
keep_trying_until {
find_questions_link.click
driver.find_element(:css, ".select_all_link")
f(".select_all_link")
}.click
submit_dialog("div#find_question_dialog")
keep_trying_until { find_with_jquery("#quiz_display_points_possible .points_possible").text.should == "17" }
keep_trying_until { fj("#quiz_display_points_possible .points_possible").text.should == "17" }
end
it "should allow you to use inherited question banks" do
@ -45,23 +45,23 @@ describe "quizzes question banks" do
get "/courses/#{@course.id}/quizzes/#{quiz.id}/edit"
keep_trying_until {
driver.find_element(:css, '.find_question_link').click
driver.find_element(:id, 'find_question_dialog').should be_displayed
f('.find_question_link').click
f('#find_question_dialog').should be_displayed
wait_for_ajaximations
driver.find_element(:css, ".select_all_link").should be_displayed
f(".select_all_link").should be_displayed
}
driver.find_element(:css, ".select_all_link").click
f(".select_all_link").click
submit_dialog("div#find_question_dialog")
keep_trying_until { find_with_jquery("#quiz_display_points_possible .points_possible").text.should == "1" }
keep_trying_until { fj("#quiz_display_points_possible .points_possible").text.should == "1" }
driver.find_element(:css, ".add_question_group_link").click
driver.find_element(:css, '.find_bank_link').click
f(".add_question_group_link").click
f('.find_bank_link').click
keep_trying_until {
find_with_jquery("#find_bank_dialog .bank:visible")
fj("#find_bank_dialog .bank:visible")
}.click
submit_dialog("#find_bank_dialog")
submit_form(".quiz_group_form")
keep_trying_until { find_with_jquery("#quiz_display_points_possible .points_possible").text.should == "2" }
keep_trying_until { fj("#quiz_display_points_possible .points_possible").text.should == "2" }
end
it "should allow you to use bookmarked question banks" do
@ -76,23 +76,23 @@ describe "quizzes question banks" do
get "/courses/#{@course.id}/quizzes/#{quiz.id}/edit"
keep_trying_until {
driver.find_element(:css, '.find_question_link').click
driver.find_element(:id, 'find_question_dialog').should be_displayed
f('.find_question_link').click
f('#find_question_dialog').should be_displayed
wait_for_ajaximations
driver.find_element(:css, ".select_all_link").should be_displayed
f(".select_all_link").should be_displayed
}
driver.find_element(:css, ".select_all_link").click
f(".select_all_link").click
submit_dialog("div#find_question_dialog")
keep_trying_until { find_with_jquery("#quiz_display_points_possible .points_possible").text.should == "1" }
keep_trying_until { fj("#quiz_display_points_possible .points_possible").text.should == "1" }
driver.find_element(:css, ".add_question_group_link").click
driver.find_element(:css, ".find_bank_link").click
f(".add_question_group_link").click
f(".find_bank_link").click
keep_trying_until {
find_with_jquery("#find_bank_dialog .bank:visible")
fj("#find_bank_dialog .bank:visible")
}.click
submit_dialog("#find_bank_dialog")
submit_form(".quiz_group_form")
keep_trying_until { find_with_jquery("#quiz_display_points_possible .points_possible").text.should == "2" }
keep_trying_until { fj("#quiz_display_points_possible .points_possible").text.should == "2" }
end
it "should check permissions when retrieving question banks" do
@ -111,21 +111,21 @@ describe "quizzes question banks" do
get "/courses/#{@course.id}/quizzes/#{quiz.id}/edit"
keep_trying_until {
driver.find_element(:css, '.find_question_link').click
driver.find_element(:id, 'find_question_dialog').should be_displayed
f('.find_question_link').click
f('#find_question_dialog').should be_displayed
wait_for_ajaximations
driver.find_element(:css, ".select_all_link").should be_displayed
f(".select_all_link").should be_displayed
}
find_all_with_jquery("#find_question_dialog .bank:visible").size.should eql 1
ffj("#find_question_dialog .bank:visible").size.should eql 1
close_visible_dialog
keep_trying_until {
driver.find_element(:css, '.add_question_group_link').click
driver.find_element(:css, '.find_bank_link').should be_displayed
f('.add_question_group_link').click
f('.find_bank_link').should be_displayed
}
driver.find_element(:css, ".find_bank_link").click
f(".find_bank_link").click
wait_for_ajaximations
find_all_with_jquery("#find_bank_dialog .bank:visible").size.should eql 1
ffj("#find_bank_dialog .bank:visible").size.should eql 1
end
it "should import questions from a question bank" do
@ -133,11 +133,11 @@ describe "quizzes question banks" do
get "/courses/#{@course.id}/quizzes/new"
driver.find_element(:css, '.add_question_group_link').click
group_form = driver.find_element(:css, '#group_top_new .quiz_group_form')
f('.add_question_group_link').click
group_form = f('#group_top_new .quiz_group_form')
group_form.find_element(:name, 'quiz_group[name]').send_keys('new group')
replace_content(group_form.find_element(:name, 'quiz_group[question_points]'), '2')
submit_form(group_form)
driver.find_element(:css, '#questions .group_top .group_display.name').should include_text('new group')
f('#questions .group_top .group_display.name').should include_text('new group')
end
end

View File

@ -14,7 +14,7 @@ describe "quizzes question creation" do
create_multiple_choice_question
quiz.reload
question_data = quiz.quiz_questions[0].question_data
driver.find_element(:id, "question_#{quiz.quiz_questions[0].id}").should be_displayed
f("#question_#{quiz.quiz_questions[0].id}").should be_displayed
question_data[:answers].length.should == 4
question_data[:answers][0][:text].should == "Correct Answer"
@ -38,7 +38,7 @@ describe "quizzes question creation" do
quiz = @last_quiz
create_true_false_question
quiz.reload
driver.find_element(:id, "question_#{quiz.quiz_questions[0].id}").should be_displayed
f("#question_#{quiz.quiz_questions[0].id}").should be_displayed
end
it "should create a quiz question with a fill in the blank question" do
@ -46,14 +46,14 @@ describe "quizzes question creation" do
quiz = @last_quiz
create_fill_in_the_blank_question
quiz.reload
driver.find_element(:id, "question_#{quiz.quiz_questions[0].id}").should be_displayed
f("#question_#{quiz.quiz_questions[0].id}").should be_displayed
end
it "should create a quiz question with a fill in multiple blanks question" do
skip_if_ie('Out of memory')
quiz = @last_quiz
question = find_with_jquery(".question_form:visible")
question = fj(".question_form:visible")
click_option('.question_form:visible .question_type', 'Fill In Multiple Blanks')
replace_content(question.find_element(:css, "input[name='question_points']"), '4')
@ -84,9 +84,9 @@ describe "quizzes question creation" do
submit_form(question)
wait_for_ajax_requests
driver.find_element(:id, 'show_question_details').click
f('#show_question_details').click
quiz.reload
finished_question = driver.find_element(:id, "question_#{quiz.quiz_questions[0].id}")
finished_question = f("#question_#{quiz.quiz_questions[0].id}")
finished_question.should be_displayed
#check select box on finished question
@ -101,7 +101,7 @@ describe "quizzes question creation" do
skip_if_ie('Out of memory')
quiz = @last_quiz
question = find_with_jquery(".question_form:visible")
question = fj(".question_form:visible")
click_option('.question_form:visible .question_type', 'Multiple Answers')
type_in_tiny '.question:visible textarea.question_content', 'This is a multiple answer question.'
@ -115,8 +115,8 @@ describe "quizzes question creation" do
submit_form(question)
wait_for_ajax_requests
driver.find_element(:id, 'show_question_details').click
finished_question = driver.find_element(:id, "question_#{quiz.quiz_questions[0].id}")
f('#show_question_details').click
finished_question = f("#question_#{quiz.quiz_questions[0].id}")
finished_question.should be_displayed
finished_question.find_elements(:css, '.answer.correct_answer').length.should == 2
end
@ -125,7 +125,7 @@ describe "quizzes question creation" do
skip_if_ie('Out of memory')
quiz = @last_quiz
question = find_with_jquery(".question_form:visible")
question = fj(".question_form:visible")
click_option('.question_form:visible .question_type', 'Multiple Dropdowns')
type_in_tiny '.question:visible textarea.question_content', 'Roses are [color1], violets are [color2]'
@ -154,9 +154,9 @@ describe "quizzes question creation" do
submit_form(question)
wait_for_ajax_requests
driver.find_element(:id, 'show_question_details').click
f('#show_question_details').click
quiz.reload
finished_question = driver.find_element(:id, "question_#{quiz.quiz_questions[0].id}")
finished_question = f("#question_#{quiz.quiz_questions[0].id}")
finished_question.should be_displayed
#check select box on finished question
@ -171,7 +171,7 @@ describe "quizzes question creation" do
skip_if_ie('Out of memory')
quiz = @last_quiz
question = find_with_jquery(".question_form:visible")
question = fj(".question_form:visible")
click_option('.question_form:visible .question_type', 'Matching')
type_in_tiny '.question:visible textarea.question_content', 'This is a matching question.'
@ -186,9 +186,9 @@ describe "quizzes question creation" do
submit_form(question)
wait_for_ajax_requests
driver.find_element(:id, 'show_question_details').click
f('#show_question_details').click
quiz.reload
finished_question = driver.find_element(:id, "question_#{quiz.quiz_questions[0].id}")
finished_question = f("#question_#{quiz.quiz_questions[0].id}")
finished_question.should be_displayed
first_answer = finished_question.find_element(:css, '.answer_match')
@ -204,7 +204,7 @@ describe "quizzes question creation" do
click_option('.question_form:visible .question_type', 'Numerical Answer')
type_in_tiny '.question:visible textarea.question_content', 'This is a numerical question.'
quiz_form = driver.find_element(:css, '.question_form')
quiz_form = f('.question_form')
answers = quiz_form.find_elements(:css, ".form_answers > .answer")
replace_content(answers[0].find_element(:name, 'answer_exact'), 5)
replace_content(answers[0].find_element(:name, 'answer_error_margin'), 2)
@ -214,9 +214,9 @@ describe "quizzes question creation" do
submit_form(quiz_form)
wait_for_ajaximations
driver.find_element(:id, 'show_question_details').click
f('#show_question_details').click
quiz.reload
finished_question = driver.find_element(:id, "question_#{quiz.quiz_questions[0].id}")
finished_question = f("#question_#{quiz.quiz_questions[0].id}")
finished_question.should be_displayed
end
@ -225,38 +225,38 @@ describe "quizzes question creation" do
skip_if_ie('Out of memory')
quiz = @last_quiz
question = find_with_jquery(".question_form:visible")
question = fj(".question_form:visible")
click_option('.question_form:visible .question_type', 'Formula Question')
type_in_tiny '.question_form:visible textarea.question_content', 'If [x] + [y] is a whole number, then this is a formula question.'
find_with_jquery('button.recompute_variables').click
find_with_jquery('.supercalc:visible').send_keys('x + y')
find_with_jquery('button.save_formula_button').click
fj('button.recompute_variables').click
fj('.supercalc:visible').send_keys('x + y')
fj('button.save_formula_button').click
# normally it's capped at 200 (to keep the yaml from getting crazy big)...
# since selenium tests take forever, let's make the limit much lower
driver.execute_script("window.maxCombinations = 10")
find_with_jquery('.combination_count:visible').send_keys('20') # over the limit
button = find_with_jquery('button.compute_combinations:visible')
fj('.combination_count:visible').send_keys('20') # over the limit
button = fj('button.compute_combinations:visible')
button.click
find_with_jquery('.combination_count:visible').attribute(:value).should eql "10"
fj('.combination_count:visible').attribute(:value).should eql "10"
keep_trying_until {
button.text == 'Generate'
}
find_all_with_jquery('table.combinations:visible tr').size.should eql 11 # plus header row
ffj('table.combinations:visible tr').size.should eql 11 # plus header row
submit_form(question)
wait_for_ajax_requests
quiz.reload
driver.find_element(:id, "question_#{quiz.quiz_questions[0].id}").should be_displayed
f("#question_#{quiz.quiz_questions[0].id}").should be_displayed
end
it "should create a quiz question with an essay question" do
skip_if_ie('Out of memory')
quiz = @last_quiz
question = find_with_jquery(".question_form:visible")
question = fj(".question_form:visible")
click_option('.question_form:visible .question_type', 'Essay Question')
type_in_tiny '.question:visible textarea.question_content', 'This is an essay question.'
@ -264,7 +264,7 @@ describe "quizzes question creation" do
wait_for_ajax_requests
quiz.reload
finished_question = driver.find_element(:id, "question_#{quiz.quiz_questions[0].id}")
finished_question = f("#question_#{quiz.quiz_questions[0].id}")
finished_question.should_not be_nil
finished_question.find_element(:css, '.text').should include_text('This is an essay question.')
end
@ -273,7 +273,7 @@ describe "quizzes question creation" do
skip_if_ie('Out of memory')
quiz = @last_quiz
question = find_with_jquery(".question_form:visible")
question = fj(".question_form:visible")
click_option('.question_form:visible .question_type', 'Text (no question)')
type_in_tiny '.question_form:visible textarea.question_content', 'This is a text question.'
@ -281,7 +281,7 @@ describe "quizzes question creation" do
wait_for_ajax_requests
quiz.reload
finished_question = driver.find_element(:id, "question_#{quiz.quiz_questions[0].id}")
finished_question = f("#question_#{quiz.quiz_questions[0].id}")
finished_question.should_not be_nil
finished_question.find_element(:css, '.text').should include_text('This is a text question.')
end
@ -290,17 +290,17 @@ describe "quizzes question creation" do
quiz = @last_quiz
create_multiple_choice_question
driver.find_element(:css, '.add_question_link').click
f('.add_question_link').click
create_true_false_question
driver.find_element(:css, '.add_question_link').click
f('.add_question_link').click
create_fill_in_the_blank_question
quiz.reload
refresh_page #making sure the quizzes load up from the database
3.times do |i|
driver.find_element(:id, "question_#{quiz.quiz_questions[i].id}").should be_displayed
f("#question_#{quiz.quiz_questions[i].id}").should be_displayed
end
questions = driver.find_elements(:css, '.display_question')
questions = ff('.display_question')
questions[0].should have_class("multiple_choice_question")
questions[1].should have_class("true_false_question")
questions[2].should have_class("short_answer_question")
@ -367,11 +367,11 @@ describe "quizzes question creation" do
edit_first_question
click_option('.question_form:visible .question_type', question_type) if question_type
driver.execute_script "$('.answer').addClass('hover');"
find_with_jquery('.edit_html:visible').click
fj('.edit_html:visible').click
end
def close_first_html_answer
driver.find_element(:css, '.edit-html-done').click
f('.edit-html-done').click
end
it "should allow HTML answers for multiple choice" do
@ -392,7 +392,7 @@ describe "quizzes question creation" do
def check_for_no_edit_button(option)
click_option('.question_form:visible .question_type', option)
driver.execute_script "$('.answer').addClass('hover');"
find_with_jquery('.edit_html:visible').should be_nil
fj('.edit_html:visible').should be_nil
end
it "should not show the edit html button for question types besides multiple choice and multiple answers" do
@ -424,7 +424,7 @@ describe "quizzes question creation" do
# add text to regular input
edit_first_question
input = find_with_jquery 'input[name=answer_text]:visible'
input = fj('input[name=answer_text]:visible')
input.click
input.send_keys 'ohai'
submit_form('.question_form')

View File

@ -19,7 +19,7 @@ describe "quizzes questions" do
hover_and_click(".edit_question_link")
wait_for_animations
question = find_with_jquery(".question_form:visible")
question = fj(".question_form:visible")
click_option('.question_form:visible .question_type', 'Multiple Choice')
replace_content(question.find_element(:css, 'input[name="question_name"]'), 'edited question')
@ -35,14 +35,14 @@ describe "quizzes questions" do
answers.length.should eql(3)
# check that the wiki sidebar shows up
driver.find_element(:css, '#quiz_options_holder .link_to_content_link').click
driver.find_element(:css, '#editor_tabs h4').should include_text("Insert Content into the Page")
driver.find_element(:css, '#quiz_content_links .quiz_options_link').click
f('#quiz_options_holder .link_to_content_link').click
f('#editor_tabs h4').should include_text("Insert Content into the Page")
f('#quiz_content_links .quiz_options_link').click
submit_form(question)
question = driver.find_element(:css, "#question_#{quest1.id}")
question = f("#question_#{quest1.id}")
question.find_element(:css, ".question_name").text.should == 'edited question'
driver.find_element(:id, 'show_question_details').click
f('#show_question_details').click
question.find_elements(:css, '.answers .answer').length.should == 3
end
@ -51,20 +51,20 @@ describe "quizzes questions" do
get "/courses/#{@course.id}/quizzes/new"
driver.find_elements(:css, "#question_form_template option.missing_word").length.should == 1
ff("#question_form_template option.missing_word").length.should == 1
keep_trying_until {
driver.find_element(:css, ".add_question .add_question_link").click
driver.find_elements(:css, "#questions .question_holder").length > 0
f(".add_question .add_question_link").click
ff("#questions .question_holder").length > 0
}
driver.find_elements(:css, "#questions .question_holder option.missing_word").length.should == 0
ff("#questions .question_holder option.missing_word").length.should == 0
end
it "should reorder questions with drag and drop" do
quiz_with_new_questions
# ensure they are in the right order
names = driver.find_elements(:css, '.question_name')
names = ff('.question_name')
names[0].text.should == 'first question'
names[1].text.should == 'second question'
@ -76,7 +76,7 @@ describe "quizzes questions" do
JS
# verify they were swapped
names = driver.find_elements(:css, '.question_name')
names = ff('.question_name')
names[0].text.should == 'second question'
names[1].text.should == 'first question'
end
@ -85,14 +85,14 @@ describe "quizzes questions" do
skip_if_ie('Out of memory')
quiz = start_quiz_question
question = find_with_jquery(".question_form:visible")
question = fj(".question_form:visible")
click_option('.question_form:visible .question_type', 'Text (no question)')
submit_form(question)
wait_for_ajax_requests
quiz.reload
show_el = driver.find_element(:id, 'show_question_details')
show_el = f('#show_question_details')
show_el.should_not be_displayed
end
@ -100,22 +100,22 @@ describe "quizzes questions" do
skip_if_ie('Out of memory')
quiz = start_quiz_question
question = find_with_jquery(".question_form:visible")
question = fj(".question_form:visible")
click_option('.question_form:visible .question_type', 'Essay Question')
submit_form(question)
wait_for_ajax_requests
quiz.reload
show_el = driver.find_element(:id, 'show_question_details')
show_el = f('#show_question_details')
show_el.should_not be_displayed
end
it "should show the display details when questions other than text or essay questions exist" do
skip_if_ie('Out of memory')
quiz = start_quiz_question
show_el = driver.find_element(:id, 'show_question_details')
question = find_with_jquery(".question_form:visible")
show_el = f('#show_question_details')
question = fj(".question_form:visible")
show_el.should_not be_displayed
@ -130,7 +130,7 @@ describe "quizzes questions" do
it "should calculate correct quiz question points total" do
skip_if_ie('Out of memory')
get "/courses/#{@course.id}/quizzes"
expect_new_page_load { driver.find_element(:css, '.new-quiz-link').click }
expect_new_page_load { f('.new-quiz-link').click }
@question_count = 0
@points_total = 0
@ -158,14 +158,14 @@ describe "quizzes questions" do
q.reload
get "/courses/#{@course.id}/quizzes/#{Quiz.last.id}"
find_with_jquery('.summary td:eq(2)').text.should == "99.75%"
fj('.summary td:eq(2)').text.should == "99.75%"
end
end
it "should round numeric questions the same when created and taking a quiz" do
skip_if_ie('Out of memory')
start_quiz_question
question = find_with_jquery(".question_form:visible")
question = fj(".question_form:visible")
click_option('.question_form:visible .question_type', 'Numerical Answer')
type_in_tiny '.question:visible textarea.question_content', 'This is a numerical question.'
@ -180,14 +180,14 @@ describe "quizzes questions" do
wait_for_ajax_requests
expect_new_page_load {
driver.find_element(:css, '.publish_quiz_button').click
f('.publish_quiz_button').click
}
expect_new_page_load {
driver.find_element(:link, 'Take the Quiz').click
}
input = driver.find_element(:css, 'input[type=text]')
input = f('input[type=text]')
input.click
input.send_keys('0.000675')
driver.execute_script <<-JS
@ -196,7 +196,7 @@ describe "quizzes questions" do
expect_new_page_load {
submit_form('#submit_quiz_form')
}
driver.find_element(:css, '.score_value').text.strip.should == '1'
f('.score_value').text.strip.should == '1'
end
context "select element behavior" do
@ -249,7 +249,7 @@ describe "quizzes questions" do
q.generate_quiz_data
q.save!
get "/courses/#{@course.id}/quizzes/#{q.id}/edit"
driver.find_element(:css, '.publish_quiz_button')
f('.publish_quiz_button')
get "/courses/#{@course.id}/quizzes/#{q.id}/take?user_id=#{@user.id}"
driver.find_element(:link, 'Take the Quiz').click
@ -259,7 +259,7 @@ describe "quizzes questions" do
after do
#This step is to prevent selenium from freezing when the dialog appears when leaving the page
keep_trying_until do
driver.find_element(:css, '#left-side .quizzes').click
f('#left-side .quizzes').click
confirm_dialog = driver.switch_to.alert
confirm_dialog.accept
true
@ -267,11 +267,11 @@ describe "quizzes questions" do
end
it "should selectmenu-ify select elements" do
select = driver.find_element(:css, '.question select')
select = f('.question select')
keep_trying_until { !select.displayed? }
driver.find_element(:css, 'a.ui-selectmenu').click
driver.find_elements(:css, '.ui-selectmenu-open li')[1].click
f('.ui-selectmenu').click
ff('.ui-selectmenu-open li')[1].click
select[:selectedIndex].should eql "1"
end
end

View File

@ -15,8 +15,8 @@ describe "quizzes" do
it "should allow a teacher to create a quiz from the quizzes tab directly" do
skip_if_ie('Out of memory')
get "/courses/#{@course.id}/quizzes"
expect_new_page_load { driver.find_element(:css, ".new-quiz-link").click }
driver.find_element(:css, ".save_quiz_button").click
expect_new_page_load { f(".new-quiz-link").click }
submit_form("#quiz_options_form")
wait_for_ajax_requests
assert_flash_notice_message /Quiz data saved/
end
@ -25,7 +25,7 @@ describe "quizzes" do
skip_if_ie('Out of memory')
get "/courses/#{@course.id}/quizzes"
expect_new_page_load {
driver.find_element(:css, '.new-quiz-link').click
f('.new-quiz-link').click
}
#check url
driver.current_url.should match %r{/courses/\d+/quizzes/(\d+)\/edit}
@ -34,26 +34,26 @@ describe "quizzes" do
quiz_id.should be > 0
#input name and description then save quiz
replace_content(driver.find_element(:css, '#quiz_options_form input#quiz_title'), 'new quiz')
replace_content(ff('#quiz_title')[1], 'new quiz')
test_text = "new description"
keep_trying_until { driver.find_element(:id, 'quiz_description_ifr').should be_displayed }
keep_trying_until { f('#quiz_description_ifr').should be_displayed }
type_in_tiny '#quiz_description', test_text
in_frame "quiz_description_ifr" do
driver.find_element(:id, 'tinymce').should include_text(test_text)
f('#tinymce').should include_text(test_text)
end
#add a question
driver.find_element(:css, '.add_question_link').click
f('.add_question_link').click
submit_form('.question_form')
wait_for_ajax_requests
#save the quiz
driver.find_element(:css, '.save_quiz_button').click
submit_form("#quiz_options_form")
wait_for_ajax_requests
#check quiz preview
driver.find_element(:link, 'Preview the Quiz').click
driver.find_element(:id, 'questions').should be_present
f('#questions').should be_present
end
it "should correctly hide form when cancelling quiz edit" do
@ -61,11 +61,11 @@ describe "quizzes" do
get "/courses/#{@course.id}/quizzes/new"
wait_for_tiny driver.find_element(:id, 'quiz_description')
driver.find_element(:css, ".add_question .add_question_link").click
driver.find_elements(:css, ".question_holder .question_form").length.should == 1
driver.find_element(:css, ".question_holder .question_form .cancel_link").click
driver.find_elements(:css, ".question_holder .question_form").length.should == 0
wait_for_tiny f('#quiz_description')
f(".add_question .add_question_link").click
ff(".question_holder .question_form").length.should == 1
f(".question_holder .question_form .cancel_link").click
ff(".question_holder .question_form").length.should == 0
end
it "should pop up calendar on top of #main" do
@ -87,17 +87,17 @@ describe "quizzes" do
wait_for_ajax_requests
test_text = "changed description"
keep_trying_until { driver.find_element(:id, 'quiz_description_ifr').should be_displayed }
keep_trying_until { f('#quiz_description_ifr').should be_displayed }
type_in_tiny '#quiz_description', test_text
in_frame "quiz_description_ifr" do
driver.find_element(:id, 'tinymce').text.include?(test_text).should be_true
f('#tinymce').text.include?(test_text).should be_true
end
driver.find_element(:css, '.save_quiz_button').click
submit_form("#quiz_options_form")
wait_for_ajax_requests
get "/courses/#{@course.id}/quizzes/#{q.id}"
driver.find_element(:css, '#main .description').should include_text(test_text)
f('#main .description').should include_text(test_text)
end
it "message students who... should do something" do
@ -112,17 +112,17 @@ describe "quizzes" do
get "/courses/#{@course.id}/quizzes/#{q.id}"
driver.find_element(:partial_link_text, "Message Students Who...").click
dialog = find_all_with_jquery("#message_students_dialog:visible")
dialog = ffj("#message_students_dialog:visible")
dialog.length.should eql(1)
dialog = dialog.first
click_option('.message_types', 'Have taken the quiz')
students = find_all_with_jquery(".student_list > .student:visible")
students = ffj(".student_list > .student:visible")
students.length.should eql(0)
click_option('.message_types', 'Have NOT taken the quiz')
students = find_all_with_jquery(".student_list > .student:visible")
students = ffj(".student_list > .student:visible")
students.length.should eql(1)
dialog.find_element(:css, 'textarea#body').send_keys('This is a test message.')
@ -138,12 +138,12 @@ describe "quizzes" do
it "should not duplicate unpublished quizzes each time you open the publish multiple quizzes dialog" do
5.times { @course.quizzes.create!(:title => "My Quiz") }
get "/courses/#{@course.id}/quizzes"
publish_multiple = driver.find_element(:css, '.publish_multiple_quizzes_link')
cancel = driver.find_element(:css, '#publish_multiple_quizzes_dialog .cancel_button')
publish_multiple = f('.publish_multiple_quizzes_link')
cancel = f('#publish_multiple_quizzes_dialog .cancel_button')
5.times do
publish_multiple.click
find_all_with_jquery('#publish_multiple_quizzes_dialog .quiz_item:not(.blank)').length.should == 5
ffj('#publish_multiple_quizzes_dialog .quiz_item:not(.blank)').length.should == 5
cancel.click
end
end
@ -153,8 +153,8 @@ describe "quizzes" do
get "/courses/#{@course.id}/quizzes/new"
driver.find_element(:css, '.add_question_group_link').click
group_form = driver.find_element(:css, '#questions .quiz_group_form')
f('.add_question_group_link').click
group_form = f('#questions .quiz_group_form')
group_form.find_element(:name, 'quiz_group[name]').send_keys('new group')
replace_content(group_form.find_element(:name, 'quiz_group[question_points]'), '3')
submit_form(group_form)
@ -167,8 +167,8 @@ describe "quizzes" do
get "/courses/#{@course.id}/quizzes/new"
driver.find_element(:css, '.add_question_group_link').click
group_form = driver.find_element(:css, '#questions .quiz_group_form')
f('.add_question_group_link').click
group_form = f('#questions .quiz_group_form')
group_form.find_element(:name, 'quiz_group[name]').send_keys('new group')
replace_content(group_form.find_element(:name, 'quiz_group[question_points]'), '3')
submit_form(group_form)
@ -227,11 +227,11 @@ describe "quizzes" do
get "/courses/#{@course.id}/quizzes/#{q.id}/moderate"
driver.find_element(:css, '.moderate_student_link').click
driver.find_element(:id, 'extension_extra_attempts').send_keys('2')
f('.moderate_student_link').click
f('#extension_extra_attempts').send_keys('2')
submit_form('#moderate_student_form')
wait_for_ajax_requests
driver.find_element(:css, '.attempts_left').text.should == '3'
f('.attempts_left').text.should == '3'
end
@ -240,7 +240,7 @@ describe "quizzes" do
quiz_with_new_questions
expect_new_page_load {
driver.find_element(:css, '.publish_quiz_button').click
f('.publish_quiz_button').click
}
wait_for_ajax_requests
@ -252,26 +252,25 @@ describe "quizzes" do
hover_and_click("#question_#{@quest1.id} .flag_question")
#click second answer
driver.find_element(:css, "#question_#{@quest2.id} .answers .answer:first-child input").click
f("#question_#{@quest2.id} .answers .answer:first-child input").click
submit_form('#submit_quiz_form')
#dismiss dialog and submit quiz
confirm_dialog = driver.switch_to.alert
confirm_dialog.dismiss
driver.find_element(:css, "#question_#{@quest1.id} .answers .answer:last-child input").click
f("#question_#{@quest1.id} .answers .answer:last-child input").click
expect_new_page_load {
submit_form('#submit_quiz_form')
}
driver.find_element(:id, 'quiz_title').text.should == @q.title
f('#quiz_title').text.should == @q.title
end
it "should indicate when it was last saved" do
skip_if_ie('Out of memory')
take_quiz do
indicator = driver.find_element(:css, '#last_saved_indicator')
indicator = f('#last_saved_indicator')
indicator.text.should == 'Not saved'
driver.find_element(:css, 'input[type=radio]').click
f('.answer .question_input').click
# too fast, this always fails
#indicator.text.should == 'Saving...'
@ -388,7 +387,7 @@ describe "quizzes" do
skip_if_ie('Out of memory')
@context = @course
bank = @course.assessment_question_banks.create!(:title=>'Test Bank')
bank = @course.assessment_question_banks.create!(:title => 'Test Bank')
q = quiz_model
a = AssessmentQuestion.create!
b = AssessmentQuestion.create!
@ -396,10 +395,10 @@ describe "quizzes" do
bank.assessment_questions << b
answers = {'answer_0' => {'id' => 1}, 'answer_1' => {'id' => 2}}
question = q.quiz_questions.create!(:question_data => {
:name => "first question",
'question_type' => 'multiple_choice_question',
'answers' => answers,
:points_possible => 1
:name => "first question",
'question_type' => 'multiple_choice_question',
'answers' => answers,
:points_possible => 1
}, :assessment_question => a)
q.generate_quiz_data
@ -409,8 +408,8 @@ describe "quizzes" do
get "/courses/#{@course.id}/quizzes/#{q.id}/take?user_id=#{@user.id}"
driver.find_element(:link_text, 'Take the Quiz').click
answer_one = driver.find_element(:id, "question_#{question.id}_answer_1")
answer_two = driver.find_element(:id, "question_#{question.id}_answer_2")
answer_one = f("#question_#{question.id}_answer_1")
answer_two = f("#question_#{question.id}_answer_2")
# force a save to create a submission
answer_one.click
@ -422,7 +421,7 @@ describe "quizzes" do
keep_trying_until do
assert_flash_notice_message /You have been given extra time on this attempt/
driver.find_element(:css, '.time_running').text.should match /^[19]{2}\sMinutes/
f('.time_running').text.should match /^[19]{2}\sMinutes/
end
#This step is to prevent selenium from freezing when the dialog appears when leaving the page
@ -435,7 +434,7 @@ describe "quizzes" do
skip_if_ie('Out of memory')
@context = @course
bank = @course.assessment_question_banks.create!(:title=>'Test Bank')
bank = @course.assessment_question_banks.create!(:title => 'Test Bank')
q = quiz_model
a = AssessmentQuestion.create!
b = AssessmentQuestion.create!
@ -443,10 +442,10 @@ describe "quizzes" do
bank.assessment_questions << b
answers = {'answer_0' => {'id' => 1}, 'answer_1' => {'id' => 2}}
question = q.quiz_questions.create!(:question_data => {
:name => "first question",
'question_type' => 'multiple_choice_question',
'answers' => answers,
:points_possible => 1
:name => "first question",
'question_type' => 'multiple_choice_question',
'answers' => answers,
:points_possible => 1
}, :assessment_question => a)
q.generate_quiz_data
@ -456,8 +455,8 @@ describe "quizzes" do
get "/courses/#{@course.id}/quizzes/#{q.id}/take?user_id=#{@user.id}"
driver.find_element(:link_text, 'Take the Quiz').click
answer_one = driver.find_element(:id, "question_#{question.id}_answer_1")
answer_two = driver.find_element(:id, "question_#{question.id}_answer_2")
answer_one = f("#question_#{question.id}_answer_1")
answer_two = f("#question_#{question.id}_answer_2")
# force a save to create a submission
answer_one.click
@ -472,7 +471,7 @@ describe "quizzes" do
keep_trying_until do
assert_flash_notice_message /You have been given extra time on this attempt/
driver.find_element(:css, '.time_running').text.should match /^[19]{2}\sMinutes/
f('.time_running').text.should match /^[19]{2}\sMinutes/
true
end
@ -490,7 +489,7 @@ describe "quizzes" do
driver.find_element(:link, "Quiz Statistics").click
driver.find_element(:css, '#content .question_name').should include_text("Question 1")
f('#content .question_name').should include_text("Question 1")
end
end
@ -545,6 +544,7 @@ describe "quizzes" do
describe "on individual quiz page" do
RESUME_TEXT = 'Resume Quiz'
def validate_resume_button_text(text)
f('#right-side .button').text.should == text
end

View File

@ -34,7 +34,7 @@ describe "course rubrics" do
wait_for_ajax_requests
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
find_all_with_jquery(".custom_ratings:visible").size.should eql(1)
ffj(".custom_ratings:visible").size.should eql(1)
end
end

View File

@ -222,7 +222,7 @@ describe "scheduler" do
f('[name="per_slot_option"]').click
f('[name="participant_visibility"]').click
f('[name="max_appointments_per_participant_option"]').click
driver.find_element(:css, '.ui-dialog-buttonset .ui-button').click
submit_dialog('.ui-dialog-buttonset', '.ui-button')
wait_for_ajaximations
# assert options are not checked
open_edit_dialog

View File

@ -8,7 +8,7 @@ describe "section tabs on the left side" do
%w{assignments quizzes settings}.each do |feature|
get "/courses/#{@course.id}/#{feature}"
js = "return $('#section-tabs .#{feature}').css('background-color')"
element_that_is_not_left_side = driver.find_element(:id, 'content')
element_that_is_not_left_side = f('#content')
# make sure to mouse off the link so the :hover and :focus styles do not apply
driver.action.move_to(element_that_is_not_left_side).perform
driver.execute_script(js).should eql('rgb(214, 236, 252)')

View File

@ -13,99 +13,99 @@ describe "sis imports ui" do
account_with_admin_logged_in
@account.update_attribute(:allow_sis_import, true)
get "/accounts/#{@account.id}/sis_import"
driver.find_element(:id, 'add_sis_stickiness').should_not be_displayed
driver.find_element(:id, 'clear_sis_stickiness').should_not be_displayed
driver.find_element(:id, 'override_sis_stickiness').should be_displayed
driver.find_element(:id, 'add_sis_stickiness').should be_enabled
driver.find_element(:id, 'clear_sis_stickiness').should be_enabled
driver.find_element(:id, 'override_sis_stickiness').should be_enabled
f('#add_sis_stickiness').should_not be_displayed
f('#clear_sis_stickiness').should_not be_displayed
f('#override_sis_stickiness').should be_displayed
f('#add_sis_stickiness').should be_enabled
f('#clear_sis_stickiness').should be_enabled
f('#override_sis_stickiness').should be_enabled
is_checked('#add_sis_stickiness').should be_false
is_checked('#clear_sis_stickiness').should be_false
driver.execute_script("return $('#override_sis_stickiness').attr('checked')").should be_false
is_checked('#override_sis_stickiness').should be_false
driver.find_element(:css, "#override_sis_stickiness").click
driver.find_element(:id, 'add_sis_stickiness').should be_displayed
driver.find_element(:id, 'clear_sis_stickiness').should be_displayed
driver.find_element(:id, 'override_sis_stickiness').should be_displayed
driver.find_element(:id, 'add_sis_stickiness').should be_enabled
driver.find_element(:id, 'clear_sis_stickiness').should be_enabled
driver.find_element(:id, 'override_sis_stickiness').should be_enabled
f("#override_sis_stickiness").click
f('#add_sis_stickiness').should be_displayed
f('#clear_sis_stickiness').should be_displayed
f('#override_sis_stickiness').should be_displayed
f('#add_sis_stickiness').should be_enabled
f('#clear_sis_stickiness').should be_enabled
f('#override_sis_stickiness').should be_enabled
is_checked('#add_sis_stickiness').should be_false
is_checked('#clear_sis_stickiness').should be_false
is_checked('#override_sis_stickiness').should be_true
driver.find_element(:css, "#override_sis_stickiness").click
f("#override_sis_stickiness").click
driver.find_element(:id, 'add_sis_stickiness').should_not be_displayed
driver.find_element(:id, 'clear_sis_stickiness').should_not be_displayed
driver.find_element(:id, 'override_sis_stickiness').should be_displayed
driver.find_element(:id, 'add_sis_stickiness').should be_enabled
driver.find_element(:id, 'clear_sis_stickiness').should be_enabled
driver.find_element(:id, 'override_sis_stickiness').should be_enabled
f('#add_sis_stickiness').should_not be_displayed
f('#clear_sis_stickiness').should_not be_displayed
f('#override_sis_stickiness').should be_displayed
f('#add_sis_stickiness').should be_enabled
f('#clear_sis_stickiness').should be_enabled
f('#override_sis_stickiness').should be_enabled
is_checked('#add_sis_stickiness').should be_false
is_checked('#clear_sis_stickiness').should be_false
is_checked('#override_sis_stickiness').should be_false
driver.find_element(:css, "#override_sis_stickiness").click
driver.find_element(:css, "#add_sis_stickiness").click
f("#override_sis_stickiness").click
f("#add_sis_stickiness").click
driver.find_element(:id, 'add_sis_stickiness').should be_displayed
driver.find_element(:id, 'clear_sis_stickiness').should be_displayed
driver.find_element(:id, 'override_sis_stickiness').should be_displayed
driver.find_element(:id, 'add_sis_stickiness').should be_enabled
driver.find_element(:id, 'clear_sis_stickiness').should_not be_enabled
driver.find_element(:id, 'override_sis_stickiness').should be_enabled
f('#add_sis_stickiness').should be_displayed
f('#clear_sis_stickiness').should be_displayed
f('#override_sis_stickiness').should be_displayed
f('#add_sis_stickiness').should be_enabled
f('#clear_sis_stickiness').should_not be_enabled
f('#override_sis_stickiness').should be_enabled
is_checked('#add_sis_stickiness').should be_true
is_checked('#clear_sis_stickiness').should be_false
is_checked('#override_sis_stickiness').should be_true
driver.find_element(:css, "#add_sis_stickiness").click
f("#add_sis_stickiness").click
driver.find_element(:id, 'add_sis_stickiness').should be_displayed
driver.find_element(:id, 'clear_sis_stickiness').should be_displayed
driver.find_element(:id, 'override_sis_stickiness').should be_displayed
driver.find_element(:id, 'add_sis_stickiness').should be_enabled
driver.find_element(:id, 'clear_sis_stickiness').should be_enabled
driver.find_element(:id, 'override_sis_stickiness').should be_enabled
f('#add_sis_stickiness').should be_displayed
f('#clear_sis_stickiness').should be_displayed
f('#override_sis_stickiness').should be_displayed
f('#add_sis_stickiness').should be_enabled
f('#clear_sis_stickiness').should be_enabled
f('#override_sis_stickiness').should be_enabled
is_checked('#add_sis_stickiness').should be_false
is_checked('#clear_sis_stickiness').should be_false
is_checked('#override_sis_stickiness').should be_true
driver.find_element(:css, "#clear_sis_stickiness").click
f("#clear_sis_stickiness").click
driver.find_element(:id, 'add_sis_stickiness').should be_displayed
driver.find_element(:id, 'clear_sis_stickiness').should be_displayed
driver.find_element(:id, 'override_sis_stickiness').should be_displayed
driver.find_element(:id, 'add_sis_stickiness').should_not be_enabled
driver.find_element(:id, 'clear_sis_stickiness').should be_enabled
driver.find_element(:id, 'override_sis_stickiness').should be_enabled
f('#add_sis_stickiness').should be_displayed
f('#clear_sis_stickiness').should be_displayed
f('#override_sis_stickiness').should be_displayed
f('#add_sis_stickiness').should_not be_enabled
f('#clear_sis_stickiness').should be_enabled
f('#override_sis_stickiness').should be_enabled
is_checked('#add_sis_stickiness').should be_false
is_checked('#clear_sis_stickiness').should be_true
is_checked('#override_sis_stickiness').should be_true
driver.find_element(:css, "#clear_sis_stickiness").click
f("#clear_sis_stickiness").click
driver.find_element(:id, 'add_sis_stickiness').should be_displayed
driver.find_element(:id, 'clear_sis_stickiness').should be_displayed
driver.find_element(:id, 'override_sis_stickiness').should be_displayed
driver.find_element(:id, 'add_sis_stickiness').should be_enabled
driver.find_element(:id, 'clear_sis_stickiness').should be_enabled
driver.find_element(:id, 'override_sis_stickiness').should be_enabled
f('#add_sis_stickiness').should be_displayed
f('#clear_sis_stickiness').should be_displayed
f('#override_sis_stickiness').should be_displayed
f('#add_sis_stickiness').should be_enabled
f('#clear_sis_stickiness').should be_enabled
f('#override_sis_stickiness').should be_enabled
is_checked('#add_sis_stickiness').should be_false
is_checked('#clear_sis_stickiness').should be_false
is_checked('#override_sis_stickiness').should be_true
driver.find_element(:css, "#clear_sis_stickiness").click
driver.find_element(:css, "#override_sis_stickiness").click
f("#clear_sis_stickiness").click
f("#override_sis_stickiness").click
driver.find_element(:id, 'add_sis_stickiness').should_not be_displayed
driver.find_element(:id, 'clear_sis_stickiness').should_not be_displayed
driver.find_element(:id, 'override_sis_stickiness').should be_displayed
f('#add_sis_stickiness').should_not be_displayed
f('#clear_sis_stickiness').should_not be_displayed
f('#override_sis_stickiness').should be_displayed
is_checked('#override_sis_stickiness').should be_false
driver.find_element(:css, "#override_sis_stickiness").click
driver.find_element(:css, "#clear_sis_stickiness").click
driver.find_element(:css, "#add_sis_stickiness").click
driver.find_element(:css, "#override_sis_stickiness").click
f("#override_sis_stickiness").click
f("#clear_sis_stickiness").click
f("#add_sis_stickiness").click
f("#override_sis_stickiness").click
driver.find_element(:id, 'add_sis_stickiness').should_not be_displayed
driver.find_element(:id, 'clear_sis_stickiness').should_not be_displayed
driver.find_element(:id, 'override_sis_stickiness').should be_displayed
f('#add_sis_stickiness').should_not be_displayed
f('#clear_sis_stickiness').should_not be_displayed
f('#override_sis_stickiness').should be_displayed
is_checked('#override_sis_stickiness').should be_false
end
@ -114,23 +114,23 @@ describe "sis imports ui" do
account_with_admin_logged_in
@account.update_attribute(:allow_sis_import, true)
get "/accounts/#{@account.id}/sis_import"
driver.find_element(:css, "#override_sis_stickiness").click
driver.find_element(:css, "#add_sis_stickiness").click
driver.find_element(:css, "#batch_mode").click
f("#override_sis_stickiness").click
f("#add_sis_stickiness").click
f("#batch_mode").click
submit_form('#sis_importer')
keep_trying_until { driver.find_element(:css, 'div.progress_bar_holder div.progress_message').should be_displayed }
keep_trying_until { f('.progress_bar_holder .progress_message').should be_displayed }
SisBatch.last.process_without_send_later
keep_trying_until { driver.find_element(:css, "div.sis_messages div.sis_error_message").text =~ /No SIS records were imported. The import failed with these messages:/ }
keep_trying_until { f(".sis_messages .sis_error_message").text =~ /No SIS records were imported. The import failed with these messages:/ }
SisBatch.last.batch_mode.should == true
SisBatch.last.options.should == {:override_sis_stickiness => true,
:add_sis_stickiness => true}
expect_new_page_load { get "/accounts/#{@account.id}/sis_import" }
driver.find_element(:css, "#override_sis_stickiness").click
f("#override_sis_stickiness").click
submit_form('#sis_importer')
keep_trying_until { driver.find_element(:css, 'div.progress_bar_holder div.progress_message').should be_displayed }
keep_trying_until { f('.progress_bar_holder .progress_message').should be_displayed }
SisBatch.last.process_without_send_later
keep_trying_until { driver.find_element(:css, "div.sis_messages div.sis_error_message").text =~ /No SIS records were imported. The import failed with these messages:/ }
keep_trying_until { f(".sis_messages .sis_error_message").text =~ /No SIS records were imported. The import failed with these messages:/ }
(!!SisBatch.last.batch_mode).should be_false
SisBatch.last.options.should == {:override_sis_stickiness => true}
end

View File

@ -19,7 +19,7 @@ describe "student interactions report" do
end
it "should have sortable columns, except the email header" do
ths = driver.find_elements(:css, ".report th")
ths = ff(".report th")
ths[0].attribute('class').should match(/header/)
ths[1].attribute('class').should match(/header/)
ths[2].attribute('class').should match(/header/)
@ -29,31 +29,31 @@ describe "student interactions report" do
end
it "should allow sorting by columns" do
ths = driver.find_elements(:css, ".report th")
trs = driver.find_elements(:css, ".report tbody tr")
ths = ff(".report th")
trs = ff(".report tbody tr")
ths[0].click
ths[0].attribute('class').should match(/headerSortDown/)
driver.find_elements(:css, ".report tbody tr").should == [trs[0], trs[1]]
ff(".report tbody tr").should == [trs[0], trs[1]]
ths[0].click
ths[0].attribute('class').should match(/headerSortUp/)
driver.find_elements(:css, ".report tbody tr").should == [trs[1], trs[0]]
ff(".report tbody tr").should == [trs[1], trs[0]]
ths[2].click
ths[2].attribute('class').should match(/headerSortDown/)
driver.find_elements(:css, ".report tbody tr").should == [trs[0], trs[1]]
ff(".report tbody tr").should == [trs[0], trs[1]]
ths[2].click
ths[2].attribute('class').should match(/headerSortUp/)
driver.find_elements(:css, ".report tbody tr").should == [trs[1], trs[0]]
ff(".report tbody tr").should == [trs[1], trs[0]]
ths[3].click
ths[3].attribute('class').should match(/headerSortDown/)
driver.find_elements(:css, ".report tbody tr").should == [trs[0], trs[1]]
ff(".report tbody tr").should == [trs[0], trs[1]]
ths[3].click
ths[3].attribute('class').should match(/headerSortUp/)
driver.find_elements(:css, ".report tbody tr").should == [trs[1], trs[0]]
ff(".report tbody tr").should == [trs[1], trs[0]]
ths[5].click
ths[5].attribute('class').should_not match(/header/)

View File

@ -29,20 +29,20 @@ describe "course syllabus" do
end
it "should confirm existing assignments and dates are correct" do
assignment_details = driver.find_elements(:css, 'td.name')
assignment_details = ff('td.name')
assignment_details[0].text.should == @assignment_1.title
assignment_details[1].text.should == @assignment_2.title
end
it "should edit the description" do
new_description = "new syllabus description"
driver.find_element(:css, '.edit_syllabus_link').click
edit_form = driver.find_element(:id, 'edit_course_syllabus_form')
wait_for_tiny(keep_trying_until { driver.find_element(:id, 'edit_course_syllabus_form') })
f('.edit_syllabus_link').click
edit_form = f('#edit_course_syllabus_form')
wait_for_tiny(keep_trying_until { f('#edit_course_syllabus_form') })
type_in_tiny('#course_syllabus_body', new_description)
submit_form(edit_form)
wait_for_ajaximations
driver.find_element(:id, 'course_syllabus').text.should == new_description
f('#course_syllabus').text.should == new_description
end
it "should validate Jump to Today works on the mini calendar" do

View File

@ -18,7 +18,7 @@ describe "user_content" do
it "should serve embed tags from a safefiles iframe" do
factory_with_protected_attributes(Announcement, :context => @course, :title => "hey all read this k", :message => message_body)
get "/"
name = driver.find_elements(:class_name, "user_content_iframe").first.attribute('name')
name = ff(".user_content_iframe").first.attribute('name')
in_frame(name) {
keep_trying_until {
driver.current_url.should match("/object_snippet")
@ -34,11 +34,11 @@ describe "user_content" do
e = factory_with_protected_attributes(CalendarEvent, :context => @course, :title => "super fun party", :description => message_body, :start_at => 5.minutes.ago, :end_at => 5.minutes.from_now)
get "/calendar"
driver.find_elements(:class_name, "user_content_iframe").size.should == 0
event_el = keep_trying_until { driver.find_element(:id, "event_calendar_event_#{e.id}") }
ff(".user_content_iframe").size.should == 0
event_el = keep_trying_until { f("#event_calendar_event_#{e.id}") }
event_el.find_element(:tag_name, 'a').click
wait_for_ajax_requests
name = keep_trying_until { driver.find_elements(:class_name, "user_content_iframe").first.attribute('name') }
name = keep_trying_until { ff(".user_content_iframe").first.attribute('name') }
in_frame(name) {
keep_trying_until {
driver.current_url.should match("/object_snippet")

View File

@ -14,14 +14,14 @@ describe "user selenium tests" do
get "/users/#{@user.id}"
pseudonym_form = f('#edit_pseudonym_form')
driver.find_element(:css, ".add_pseudonym_link").click
f(".add_pseudonym_link").click
pseudonym_form.find_element(:css, "#pseudonym_unique_id").send_keys('new_user')
pseudonym_form.find_element(:css, "#pseudonym_password").send_keys('qwerty1')
pseudonym_form.find_element(:css, "#pseudonym_password_confirmation").send_keys('qwerty1')
submit_form(pseudonym_form)
wait_for_ajaximations
new_login = driver.find_elements(:css, '.login').select { |e| e.attribute(:class) !~ /blank/ }.first
new_login = ff('.login').select { |e| e.attribute(:class) !~ /blank/ }.first
new_login.should_not be_nil
new_login.find_element(:css, '.account_name').text().should_not be_blank
pseudonym = Pseudonym.by_unique_id('new_user').first

View File

@ -5,11 +5,11 @@ describe "Wiki pages and Tiny WYSIWYG editor Files" do
def add_file_to_rce
wiki_page_tools_file_tree_setup
wait_for_tiny(keep_trying_until { driver.find_element(:css, "form#new_wiki_page") })
driver.find_element(:css, '.wiki_switch_views_link').click
wait_for_tiny(keep_trying_until { f("#new_wiki_page") })
f('.wiki_switch_views_link').click
wiki_page_body = clear_wiki_rce
driver.find_element(:css, '.wiki_switch_views_link').click
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
f('.wiki_switch_views_link').click
f('#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
root_folders = @tree1.find_elements(:css, 'li.folder')
root_folders.first.find_element(:css, '.sign.plus').click
wait_for_ajaximations
@ -17,9 +17,9 @@ describe "Wiki pages and Tiny WYSIWYG editor Files" do
root_folders.first.find_elements(:css, '.file.text span').first.click
in_frame "wiki_page_body_ifr" do
driver.find_element(:id, 'tinymce').should include_text('txt')
f('#tinymce').should include_text('txt')
end
driver.find_element(:css, '.wiki_switch_views_link').click
f('.wiki_switch_views_link').click
find_css_in_string(wiki_page_body[:value], '.instructure_file_link').should_not be_empty
submit_form('#new_wiki_page')
wait_for_ajax_requests
@ -53,7 +53,7 @@ describe "Wiki pages and Tiny WYSIWYG editor Files" do
it "should lazy load files" do
skip_if_ie('Out of memory')
wiki_page_tools_file_tree_setup
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
f('#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
root_folders = @tree1.find_elements(:css, 'li.folder')
root_folders.length.should == 1
@ -82,12 +82,12 @@ describe "Wiki pages and Tiny WYSIWYG editor Files" do
it "should lazy load directory structure for upload form" do
skip_if_ie('Out of memory')
wiki_page_tools_file_tree_setup
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
f('#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
select = driver.find_element(:css, '#sidebar_upload_file_form select#attachment_folder_id')
select = f('#attachment_folder_id')
select.find_elements(:css, 'option').length.should == 1
driver.find_element(:css, '.upload_new_file_link').click
f('.upload_new_file_link').click
keep_trying_until { select.find_elements(:css, 'option').length > 1 }
select.find_elements(:css, 'option').length.should == 3
end
@ -95,10 +95,10 @@ describe "Wiki pages and Tiny WYSIWYG editor Files" do
it "should be able to upload a file when nothing has been loaded" do
skip_if_ie('Out of memory')
wiki_page_tools_file_tree_setup
keep_trying_until { driver.find_element(:css, "form#new_wiki_page").should be_displayed }
driver.find_element(:css, '.wiki_switch_views_link').click
keep_trying_until { f("#new_wiki_page").should be_displayed }
f('.wiki_switch_views_link').click
clear_wiki_rce
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
f('#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
first_folder = @tree1.find_elements(:css, 'li.folder').first
first_folder.find_element(:css, '.sign.plus').click
wait_for_ajax_requests
@ -106,10 +106,10 @@ describe "Wiki pages and Tiny WYSIWYG editor Files" do
subfolder.find_element(:css, '.sign.plus').click
wait_for_ajax_requests
driver.find_element(:css, '.upload_new_file_link').click
f('.upload_new_file_link').click
wait_for_ajax_requests
#testing adding to a subfolder
select_element = driver.find_element(:id, 'attachment_folder_id')
select_element = f('#attachment_folder_id')
select_element.click
options = select_element.find_elements(:css, 'option')
for option in options
@ -120,18 +120,18 @@ describe "Wiki pages and Tiny WYSIWYG editor Files" do
end
wiki_page_tools_upload_file('#sidebar_upload_file_form', :text)
wait_for_ajaximations
keep_trying_until { driver.find_element(:css, '.file_list').should include_text('testfile') }
keep_trying_until { f('.file_list').should include_text('testfile') }
end
it "should show uploaded files in file tree and add them to the rce" do
skip_if_ie('Out of memory')
wiki_page_tools_file_tree_setup
wait_for_tiny(keep_trying_until { driver.find_element(:css, "form#new_wiki_page") })
driver.find_element(:css, '.wiki_switch_views_link').click
wait_for_tiny(keep_trying_until { f("#new_wiki_page") })
f('.wiki_switch_views_link').click
clear_wiki_rce
driver.find_element(:css, '.wiki_switch_views_link').click
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
driver.find_element(:css, '.upload_new_file_link').click
f('.wiki_switch_views_link').click
f('#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
f('.upload_new_file_link').click
root_folders = @tree1.find_elements(:css, 'li.folder')
root_folders.first.find_element(:css, '.sign.plus').click
@ -142,7 +142,7 @@ describe "Wiki pages and Tiny WYSIWYG editor Files" do
root_folders.first.find_elements(:css, '.file.text').length.should == 2
in_frame "wiki_page_body_ifr" do
driver.find_element(:id, 'tinymce').should include_text('txt')
f('#tinymce').should include_text('txt')
end
submit_form('#new_wiki_page')
@ -150,17 +150,17 @@ describe "Wiki pages and Tiny WYSIWYG editor Files" do
get "/courses/#{@course.id}/wiki" #can't just wait for the dom, for some reason it stays in edit mode
wait_for_ajax_requests
check_file(driver.find_element(:css, '#wiki_body .instructure_file_link_holder a'))
check_file(f('#wiki_body .instructure_file_link_holder a'))
end
it "should not show uploaded files in image list" do
skip_if_ie('Out of memory')
wiki_page_tools_file_tree_setup
wait_for_tiny(keep_trying_until { driver.find_element(:css, "form#new_wiki_page") })
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
driver.find_element(:css, '.upload_new_image_link').click
driver.find_element(:css, '.wiki_switch_views_link').click
wait_for_tiny(keep_trying_until { f("#new_wiki_page") })
f('#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
f('.upload_new_image_link').click
f('.wiki_switch_views_link').click
wiki_page_body = clear_wiki_rce
wait_for_ajaximations
keep_trying_until { @image_list.find_elements(:css, 'img.img').length.should == 2 }
@ -173,22 +173,22 @@ describe "Wiki pages and Tiny WYSIWYG editor Files" do
it "should be able to upload a file and add the file to the rce" do
add_file_to_rce
check_file(driver.find_element(:css, '#wiki_body .instructure_file_link_holder a'))
check_file(f('#wiki_body .instructure_file_link_holder a'))
end
it "should show files uploaded on the images tab in the file tree" do
skip_if_ie('Out of memory')
wiki_page_tools_file_tree_setup
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
f('#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
root_folders = @tree1.find_elements(:css, 'li.folder')
root_folders.first.find_element(:css, '.sign.plus').click
wait_for_ajaximations
root_folders.first.find_elements(:css, '.file.text').length.should == 1
wait_for_tiny(keep_trying_until { driver.find_element(:css, "form#new_wiki_page") })
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
driver.find_element(:css, '.upload_new_image_link').click
driver.find_element(:css, '.wiki_switch_views_link').click
wait_for_tiny(keep_trying_until { f("#new_wiki_page") })
f('#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
f('.upload_new_image_link').click
f('.wiki_switch_views_link').click
wiki_page_body = clear_wiki_rce
wait_for_ajaximations
keep_trying_until { @image_list.find_elements(:css, 'img.img').length.should == 2 }
@ -216,7 +216,7 @@ describe "Wiki pages and Tiny WYSIWYG editor Files" do
add_file_to_rce
login_as(@student.name)
get "/courses/#{@course.id}/wiki"
find_with_jquery('a[title="text_file.txt"]').should be_displayed
fj('a[title="text_file.txt"]').should be_displayed
#check_file would be good to do here but the src on the file in the wiki body is messed up
end
end

View File

@ -5,24 +5,24 @@ describe "Wiki pages and Tiny WYSIWYG editor Images" do
def add_flickr_image(el)
el.find_element(:css, '.mce_instructure_embed').click
driver.find_element(:css, '.flickr_search_link').click
driver.find_element(:css, '#image_search_form > input').send_keys('angel')
f('.flickr_search_link').click
f('#image_search_form > input').send_keys('angel')
submit_form('#image_search_form')
wait_for_ajax_requests
keep_trying_until { driver.find_element(:css, '.image_link').should be_displayed }
driver.find_element(:css, '.image_link').click
keep_trying_until { f('.image_link').should be_displayed }
f('.image_link').click
end
def add_image_to_rce
wait_for_tiny(keep_trying_until { driver.find_element(:css, "form#new_wiki_page") })
driver.find_element(:css, '.wiki_switch_views_link').click
wait_for_tiny(keep_trying_until { f("#new_wiki_page") })
f('.wiki_switch_views_link').click
clear_wiki_rce
driver.find_element(:css, '.wiki_switch_views_link').click
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
driver.find_element(:css, '.upload_new_image_link').click
f('.wiki_switch_views_link').click
f('#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
f('.upload_new_image_link').click
wiki_page_tools_upload_file('#sidebar_upload_image_form', :image)
in_frame "wiki_page_body_ifr" do
driver.find_element(:css, '#tinymce img').should be_displayed
f('#tinymce img').should be_displayed
end
submit_form('#new_wiki_page')
@ -58,11 +58,11 @@ describe "Wiki pages and Tiny WYSIWYG editor Images" do
skip_if_ie('Out of memory')
wiki_page_tools_file_tree_setup
@image_list.should_not have_class('initialized')
@image_list.find_elements(:css, 'img.img').length.should == 0
@image_list.find_elements(:css, '.img').length.should == 0
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
f('#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
wait_for_ajaximations
keep_trying_until { @image_list.find_elements(:css, 'img.img').length }.should == 2
keep_trying_until { @image_list.find_elements(:css, '.img').length }.should == 2
end
@ -77,9 +77,9 @@ describe "Wiki pages and Tiny WYSIWYG editor Images" do
get "/courses/#{new_course.id}/wiki"
f('#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
keep_trying_until do
images = ffj('#editor_tabs_4 .image_list img.img')
images = ffj('#editor_tabs_4 .image_list .img')
images.length.should == 2
#images.each { |i| i.attribute('complete').should == 'true' } - commented out because it is breaking with
images.each { |i| i.attribute('complete').should == 'true' }# - commented out because it is breaking with
#webdriver 2.22 and firefox 12
end
end
@ -95,64 +95,64 @@ describe "Wiki pages and Tiny WYSIWYG editor Images" do
image.save!
end
@image_list.should_not have_class('initialized')
@image_list.find_elements(:css, 'img.img').length.should == 0
@image_list.find_elements(:css, '.img').length.should == 0
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
f('#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
wait_for_ajaximations
keep_trying_until { @image_list.find_elements(:css, 'img.img').length }.should == 30
keep_trying_until { @image_list.find_elements(:css, '.img').length }.should == 30
driver.execute_script('image_list = $(".image_list")')
# scroll halfway down; it should load another 30
driver.execute_script('image_list.scrollTop(100)')
keep_trying_until { @image_list.find_elements(:css, 'img.img').length > 30 }
@image_list.find_elements(:css, 'img.img').length.should == 60
keep_trying_until { @image_list.find_elements(:css, '.img').length > 30 }
@image_list.find_elements(:css, '.img').length.should == 60
# scroll to the very bottom
driver.execute_script('image_list.scrollTop(image_list[0].scrollHeight - image_list.height())')
keep_trying_until { @image_list.find_elements(:css, 'img.img').length > 60 }
@image_list.find_elements(:css, 'img.img').length.should == 90
keep_trying_until { @image_list.find_elements(:css, '.img').length > 60 }
@image_list.find_elements(:css, '.img').length.should == 90
end
it "should show images uploaded on the files tab in the image list" do
skip_if_ie('Out of memory')
wiki_page_tools_file_tree_setup
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
f('#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
f('#editor_tabs .ui-tabs-nav li:nth-child(2) a').click
root_folders = @tree1.find_elements(:css, 'li.folder')
root_folders.first.find_element(:css, '.sign.plus').click
wait_for_ajaximations
root_folders.first.find_elements(:css, '.file.image').length.should == 2
wait_for_tiny(keep_trying_until { driver.find_element(:css, "form#new_wiki_page") })
driver.find_element(:css, '.upload_new_file_link').click
driver.find_element(:css, '.wiki_switch_views_link').click
wait_for_tiny(keep_trying_until { f("#new_wiki_page") })
f('.upload_new_file_link').click
f('.wiki_switch_views_link').click
wiki_page_body = clear_wiki_rce
@image_list.find_elements(:css, 'img.img').length.should == 2
@image_list.find_elements(:css, '.img').length.should == 2
wiki_page_tools_upload_file('#sidebar_upload_file_form', :image)
root_folders.first.find_elements(:css, '.file.image').length.should == 3
@image_list.find_elements(:css, 'img.img').length.should == 3
@image_list.find_elements(:css, '.img').length.should == 3
find_css_in_string(wiki_page_body[:value], '.instructure_file_link').should_not be_empty
end
it "should show uploaded images in image list and add the image to the rce" do
skip_if_ie('Out of memory')
wiki_page_tools_file_tree_setup
wait_for_tiny(keep_trying_until { driver.find_element(:css, "form#new_wiki_page") })
driver.find_element(:css, '.wiki_switch_views_link').click
wait_for_tiny(keep_trying_until { f("#new_wiki_page") })
f('.wiki_switch_views_link').click
clear_wiki_rce
driver.find_element(:css, '.wiki_switch_views_link').click
driver.find_element(:css, '#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
f('.wiki_switch_views_link').click
f('#editor_tabs .ui-tabs-nav li:nth-child(3) a').click
wait_for_ajax_requests
@image_list.find_elements(:css, 'img.img').length.should == 2
@image_list.find_elements(:css, '.img').length.should == 2
keep_trying_until do
driver.find_elements(:css, '#editor_tabs_4 .image_list img.img').first.click
ff('#editor_tabs_4 .image_list .img').first.click
in_frame "wiki_page_body_ifr" do
driver.find_element(:css, '#tinymce img').should be_displayed
f('#tinymce img').should be_displayed
end
true
end
@ -162,14 +162,14 @@ describe "Wiki pages and Tiny WYSIWYG editor Images" do
get "/courses/#{@course.id}/wiki" #can't just wait for the dom, for some reason it stays in edit mode
wait_for_ajax_requests
check_image(driver.find_element(:css, '#wiki_body img'))
check_image(f('#wiki_body img'))
end
it "should be able to upload an image and add the image to the rce" do
get "/courses/#{@course.id}/wiki"
add_image_to_rce
check_image(driver.find_element(:css, '#wiki_body img'))
check_image(f('#wiki_body img'))
end
it "should add image from flickr" do
@ -177,12 +177,12 @@ describe "Wiki pages and Tiny WYSIWYG editor Images" do
get "/courses/#{@course.id}/wiki"
#add image from flickr to rce
driver.find_element(:css, '.wiki_switch_views_link').click
f('.wiki_switch_views_link').click
clear_wiki_rce
driver.find_element(:css, '.wiki_switch_views_link').click
f('.wiki_switch_views_link').click
add_flickr_image(driver)
in_frame "wiki_page_body_ifr" do
driver.find_element(:css, '#tinymce img').should be_displayed
f('#tinymce img').should be_displayed
end
submit_form('#new_wiki_page')
@ -190,24 +190,24 @@ describe "Wiki pages and Tiny WYSIWYG editor Images" do
get "/courses/#{@course.id}/wiki" #can't just wait for the dom, for some reason it stays in edit mode
wait_for_ajax_requests
check_image(driver.find_element(:css, '#wiki_body img'))
check_image(f('#wiki_body img'))
end
it "should put flickr images into the right editor" do
skip_if_ie('Out of memory')
get "/courses/#{@course.id}/quizzes"
driver.find_element(:css, ".new-quiz-link").click
keep_trying_until { driver.find_element(:css, ".mce_instructure_embed").should be_displayed }
f(".new-quiz-link").click
keep_trying_until { f(".mce_instructure_embed").should be_displayed }
add_flickr_image(driver)
driver.find_element(:css, ".add_question_link").click
f(".add_question_link").click
wait_for_animations
add_flickr_image(driver.find_element(:id, "question_content_0_parent"))
add_flickr_image(f("#question_content_0_parent"))
in_frame "quiz_description_ifr" do
driver.find_element(:id, "tinymce").find_elements(:css, "a").length.should == 1
f("#tinymce").find_elements(:css, "a").length.should == 1
end
in_frame "question_content_0_ifr" do
driver.find_element(:id, "tinymce").find_elements(:css, "a").length.should == 1
f("#tinymce").find_elements(:css, "a").length.should == 1
end
end
end
@ -228,7 +228,7 @@ describe "Wiki pages and Tiny WYSIWYG editor Images" do
login_as(@student.name)
get "/courses/#{@course.id}/wiki"
find_with_jquery("img[src='/courses/#{@course.id}/files/#{@course.attachments.last.id}/preview']").should be_displayed
fj("img[src='/courses/#{@course.id}/files/#{@course.attachments.last.id}/preview']").should be_displayed
#check_image would be good to do here but the src on the image in the wiki body is messed up
end
end

View File

@ -11,20 +11,20 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
skip_if_ie('Out of memory')
wiki_page_tools_file_tree_setup
load_simulate_js
wait_for_tiny(keep_trying_until { driver.find_element(:css, "form#new_wiki_page") })
wait_for_tiny(keep_trying_until { f("#new_wiki_page") })
make_full_screen
# TODO: there's an issue where we can drag the box smaller than it's supposed to be on the first resize.
# Until we can track that down, first we do a fake drag to make sure the rest of the resizing machinery
# works.
drag_with_js('.editor_box_resizer', 0, -1)
resizer_to = 1 - driver.find_element(:class, 'editor_box_resizer').location.y
resizer_to = 1 - f('.editor_box_resizer').location.y
# drag the resizer way up to the top of the screen (to make the wysiwyg the shortest it will go)
keep_trying_until do
drag_with_js('.editor_box_resizer', 0, resizer_to)
sleep 3
driver.execute_script("return $('#wiki_page_body_ifr').height()").should eql(200)
end
driver.find_element(:class, 'editor_box_resizer').attribute('style').should be_blank
f('.editor_box_resizer').attribute('style').should be_blank
# now move it down 30px from 200px high
keep_trying_until do
@ -32,7 +32,7 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
true
end
driver.execute_script("return $('#wiki_page_body_ifr').height()").should be_close(230, 5)
driver.find_element(:class, 'editor_box_resizer').attribute('style').should be_blank
f('.editor_box_resizer').attribute('style').should be_blank
resize_screen_to_default
end
@ -40,21 +40,21 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
skip_if_ie('Out of memory')
get "/courses/#{@course.id}/wiki"
wait_for_tiny(keep_trying_until { driver.find_element(:css, "form#new_wiki_page") })
driver.find_element(:css, '.mceIcon.mce_bold').click
driver.find_element(:css, '.mceIcon.mce_italic').click
wait_for_tiny(keep_trying_until { f("#new_wiki_page") })
f('.mceIcon.mce_bold').click
f('.mceIcon.mce_italic').click
first_text = 'This is my text.'
type_in_tiny('#wiki_page_body', first_text)
in_frame "wiki_page_body_ifr" do
driver.find_element(:id, 'tinymce').should include_text(first_text)
f('#tinymce').should include_text(first_text)
end
#make sure each view uses the proper format
driver.find_element(:css, '.wiki_switch_views_link').click
f('.wiki_switch_views_link').click
driver.execute_script("return $('#wiki_page_body').val()").should include '<em><strong>'
driver.find_element(:css, '.wiki_switch_views_link').click
f('.wiki_switch_views_link').click
in_frame "wiki_page_body_ifr" do
driver.find_element(:id, 'tinymce').should_not include_text('<p>')
f('#tinymce').should_not include_text('<p>')
end
submit_form('#new_wiki_page')
@ -74,12 +74,12 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
get "/courses/#{@course.id}/wiki"
# add quiz to rce
accordion = driver.find_element(:css, '#editor_tabs #pages_accordion')
accordion = f('#pages_accordion')
accordion.find_element(:link, I18n.t('links_to.quizzes', 'Quizzes')).click
keep_trying_until { accordion.find_element(:link, quiz.title).should be_displayed }
accordion.find_element(:link, quiz.title).click
in_frame "wiki_page_body_ifr" do
driver.find_element(:id, 'tinymce').should include_text(quiz.title)
f('#tinymce').should include_text(quiz.title)
end
submit_form('#new_wiki_page')
@ -87,7 +87,7 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
get "/courses/#{@course.id}/wiki" #can't just wait for the dom, for some reason it stays in edit mode
wait_for_ajax_requests
driver.find_element(:css, '#wiki_body').find_element(:link, quiz.title).should be_displayed
f('#wiki_body').find_element(:link, quiz.title).should be_displayed
end
it "should add an assignment to the rce" do
@ -95,42 +95,41 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
@assignment = @course.assignments.create(:name => assignment_name)
get "/courses/#{@course.id}/wiki"
driver.find_element(:css, '.wiki_switch_views_link').click
f('.wiki_switch_views_link').click
clear_wiki_rce
driver.find_element(:css, '.wiki_switch_views_link').click
f('.wiki_switch_views_link').click
#check assigment accordion
accordion = driver.find_element(:css, '#editor_tabs #pages_accordion')
accordion = f('#pages_accordion')
accordion.find_element(:link, I18n.t('links_to.assignments', 'Assignments')).click
keep_trying_until { accordion.find_element(:link, assignment_name).should be_displayed }
accordion.find_element(:link, assignment_name).click
in_frame "wiki_page_body_ifr" do
driver.find_element(:id, 'tinymce').should include_text(assignment_name)
f('#tinymce').should include_text(assignment_name)
end
submit_form('#new_wiki_page')
wait_for_ajax_requests
get "/courses/#{@course.id}/wiki" #can't just wait for the dom, for some reason it stays in edit mode
wait_for_ajax_requests
driver.find_element(:css, '#wiki_body').find_element(:link, assignment_name).should be_displayed
f('#wiki_body').find_element(:css, "a[title='#{assignment_name}']").should be_displayed
end
it "should add an equation to the rce by using equation buttons" do
skip_if_ie('Out of memory')
get "/courses/#{@course.id}/wiki"
driver.find_element(:id, 'wiki_page_body_instructure_equation').click
f('#wiki_page_body_instructure_equation').click
wait_for_animations
driver.find_element(:id, 'instructure_equation_prompt').should be_displayed
misc_tab = driver.find_element(:css, '.mathquill-tab-bar > li:last-child a')
f('#instructure_equation_prompt').should be_displayed
misc_tab = f('.mathquill-tab-bar > li:last-child a')
driver.action.move_to(misc_tab).perform
driver.find_element(:css, '#Misc_tab li:nth-child(35) a').click
basic_tab = driver.find_element(:css, '.mathquill-tab-bar > li:first-child a')
f('#Misc_tab li:nth-child(35) a').click
basic_tab = f('.mathquill-tab-bar > li:first-child a')
driver.action.move_to(basic_tab).perform
driver.find_element(:css, '#Basic_tab li:nth-child(27) a').click
f('#Basic_tab li:nth-child(27) a').click
submit_form('#instructure_equation_prompt_form')
in_frame "wiki_page_body_ifr" do
driver.find_element(:css, '#tinymce img').should be_displayed
f('#tinymce img').should be_displayed
end
submit_form('#new_wiki_page')
@ -138,7 +137,7 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
get "/courses/#{@course.id}/wiki" #can't just wait for the dom, for some reason it stays in edit mode
wait_for_ajax_requests
check_image(driver.find_element(:css, '#wiki_body img'))
check_image(f('#wiki_body img'))
end
it "should add an equation to the rce by using the equation editor" do
@ -146,9 +145,9 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
get "/courses/#{@course.id}/wiki"
driver.find_element(:id, 'wiki_page_body_instructure_equation').click
f('#wiki_page_body_instructure_equation').click
wait_for_animations
driver.find_element(:id, 'instructure_equation_prompt').should be_displayed
f('#instructure_equation_prompt').should be_displayed
textarea = f('.mathquill-editor .textarea textarea')
3.times do
textarea.send_keys(:backspace)
@ -198,12 +197,12 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
stub_kaltura
get "/courses/#{@course.id}/wiki"
driver.find_element(:css, '.mce_instructure_record').click
keep_trying_until { driver.find_element(:id, 'record_media_tab').should be_displayed }
driver.find_element(:css, '#media_comment_dialog a[href="#upload_media_tab"]').click
driver.find_element(:css, '#media_comment_dialog #audio_upload').should be_displayed
f('.mce_instructure_record').click
keep_trying_until { f('#record_media_tab').should be_displayed }
f('#media_comment_dialog a[href="#upload_media_tab"]').click
f('#media_comment_dialog #audio_upload').should be_displayed
close_visible_dialog
driver.find_element(:id, 'media_comment_dialog').should_not be_displayed
f('#media_comment_dialog').should_not be_displayed
end
it "should handle table borders correctly" do
@ -219,21 +218,21 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
driver.execute_script("$('#wiki_page_body').editorBox('execute', 'mceInsertTable')")
# the iframe will be created with an id of mce_<some number>_ifr
table_iframe_id = keep_trying_until { driver.find_elements(:css, 'iframe').map { |f| f['id'] }.detect { |w| w =~ /mce_\d+_ifr/ } }
table_iframe_id = keep_trying_until { ff('iframe').map { |f| f['id'] }.detect { |w| w =~ /mce_\d+_ifr/ } }
table_iframe_id.should_not be_nil
in_frame(table_iframe_id) do
attributes.each do |attribute, value|
tab_to_show = attribute == :bordercolor ? 'advanced' : 'general'
keep_trying_until do
driver.execute_script "mcTabs.displayTab('#{tab_to_show}_tab', '#{tab_to_show}_panel')"
set_value(driver.find_element(:id, attribute), value)
set_value(f("##{attribute}"), value)
true
end
end
driver.find_element(:id, 'insert').click
f('#insert').click
end
in_frame "wiki_page_body_ifr" do
table = driver.find_element(:css, 'table')
table = f('#tinymce table')
attributes.each do |attribute, value|
(table[attribute].should == value.to_s) if (value && (attribute != :bordercolor))
end
@ -276,13 +275,13 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
web_address = "www.google.com"
def add_text_to_tiny(text)
driver.find_element(:css, '.wiki_switch_views_link').click
f('.wiki_switch_views_link').click
clear_wiki_rce
driver.find_element(:css, '.wiki_switch_views_link').click
f('.wiki_switch_views_link').click
type_in_tiny('#wiki_page_body', text)
in_frame "wiki_page_body_ifr" do
driver.find_element(:id, 'tinymce').send_keys(:return)
driver.find_element(:id, 'tinymce').should include_text(text)
f('#tinymce').send_keys(:return)
f('#tinymce').should include_text(text)
end
end
@ -295,14 +294,14 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
def validate_link
in_frame "wiki_page_body_ifr" do
link = driver.find_element(:css, '#tinymce a')
link = f('#tinymce a')
link.attribute('href').should == 'http://www.google.com/'
end
end
before(:each) do
get "/courses/#{@course.id}/wiki"
wait_for_tiny(keep_trying_until { driver.find_element(:css, "form#new_wiki_page") })
wait_for_tiny(keep_trying_until { f("#new_wiki_page") })
end
it "should type a web address and validate auto link plugin is working correctly" do