fix error in selenium outcome spec and some selenium cleanup

Change-Id: If2e6327bf9c7ca3b70c46c34a638a9067b5f4c1f
Reviewed-on: https://gerrit.instructure.com/5911
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
Bryan Madsen 2011-09-28 16:18:14 -06:00
parent 051f9195d1
commit 28a73ac957
11 changed files with 81 additions and 57 deletions

View File

@ -38,7 +38,7 @@ def valid_outcome_data
{
:enable => '1',
:points_possible => 3,
:mastery_points => 4,
:mastery_points => 3,
:description => "Outcome row",
:ratings => {
'first_rating' =>

View File

@ -87,19 +87,20 @@ describe "Alerts" do
@alerts.should be_empty
end
it "should remove non-created alerts" do
it "should remove non-created alerts by clicking delete link" do
get "/accounts/#{@context.id}/settings"
driver.find_element(:css, '#tab-alerts-link').click
driver.find_element(:css, '.add_alert_link').click
alert = driver.find_element(:css, '.alert.new')
alert.find_element(:css, '.delete_link').click
wait_for_animations
keep_trying_until { find_with_jquery(".alert.new").blank? }
@alerts.should be_empty
end
it "should remove non-created alerts" do
it "should remove non-created alerts by clicking cancel button" do
get "/accounts/#{@context.id}/settings"
driver.find_element(:css, '#tab-alerts-link').click
@ -164,8 +165,8 @@ describe "Alerts" do
alert = driver.find_element(:css, '.alert.new')
alert.find_element(:css, 'input[name="repetition"][value="value"]').click
alert.find_element(:css, '.submit_button').click
wait_for_ajaximations
sleep 1 #need to wait for javascript to process
wait_for_animations
keep_trying_until { driver.find_elements(:css, '.error_box').length == 4 }
# clicking "do not repeat" should remove the number of days error
@ -179,7 +180,6 @@ describe "Alerts" do
alert.find_element(:css, '.criteria input[type="text"]').send_keys("abc")
alert.find_element(:css, '.submit_button').click
alert.find_element(:css, '.submit_button').click
keep_trying_until { driver.find_elements(:css, '.error_box').length == 2 }
end

View File

@ -51,10 +51,10 @@ describe "calendar selenium tests" do
wait_for_ajax_requests
#verify both assignments are visible
unless get_checkbox_state("#group_course_#{first_course.id}")
unless is_checked("#group_course_#{first_course.id}")
driver.find_element(:id, "group_course_#{first_course.id}").click
end
unless get_checkbox_state("#group_course_#{second_course.id}")
unless is_checked("#group_course_#{second_course.id}")
driver.find_element(:id, "group_course_#{second_course.id}").click
end
date_holder_id = "day_#{due_date.year}_#{due_date.strftime('%m')}_#{due_date.strftime('%d')}"

View File

@ -163,7 +163,7 @@ module SeleniumTestsHelperMethods
end
break if s
rescue Timeout::Error
# pass
puts "timeout error attempting to connect to forked webrick server"
end
sleep 1
end
@ -317,8 +317,8 @@ shared_examples_for "all selenium tests" do
driver.switch_to.window saved_window_handle
end
def get_checkbox_state(selector)
return driver.execute_script('return $("'+selector+'").attr("checked");')
def is_checked(selector)
return driver.execute_script('return $("'+selector+'").is(":checked")')
end
def find_option_value(selector_type, selector_css, option_text)
@ -362,15 +362,15 @@ shared_examples_for "all selenium tests" do
def stub_kaltura
# trick kaltura into being activated
Kaltura::ClientV3.stub!(:config).and_return({
:domain => 'kaltura.example.com',
:resource_domain => 'kaltura.example.com',
:partner_id => '100',
:subpartner_id => '10000',
:secret_key => 'fenwl1n23k4123lk4hl321jh4kl321j4kl32j14kl321',
:user_secret_key => '1234821hrj3k21hjk4j3kl21j4kl321j4kl3j21kl4j3k2l1',
:player_ui_conf => '1',
:kcw_ui_conf => '1',
:upload_ui_conf => '1'
'domain' => 'www.instructuremedia.com',
'resource_domain' => 'www.instructuremedia.com',
'partner_id' => '101',
'subpartner_id' => '10100',
'secret_key' => '3071bfe768e40ff6726ba2667c1e89d7',
'user_secret_key' => '9c95f13c01b0922a87242d0588c41d79',
'player_ui_conf' => '1727899',
'kcw_ui_conf' => '1727883',
'upload_ui_conf' => '1103'
})
end
@ -393,6 +393,22 @@ shared_examples_for "all selenium tests" do
JS
end
def check_image(element)
require 'open-uri'
element.should be_displayed
element.tag_name.should == 'img'
temp_file = open(element.attribute('src'))
temp_file.size.should > 0
end
def check_file(element)
require 'open-uri'
element.should be_displayed
element.tag_name.should == 'a'
temp_file = open(element.attribute('href'))
temp_file.size.should > 0
end
def assert_flash_notice_message(okay_message_regex)
keep_trying_until do
text = driver.find_element(:css, "#flash_notice_message").text
@ -451,22 +467,6 @@ def get_file(filename)
[filename, fullpath, data, @file]
end
def check_image(element)
require 'open-uri'
element.should be_displayed
element.tag_name.should == 'img'
temp_file = open(element.attribute('src'))
temp_file.size.should > 0
end
def check_file(element)
require 'open-uri'
element.should be_displayed
element.tag_name.should == 'a'
temp_file = open(element.attribute('href'))
temp_file.size.should > 0
end
shared_examples_for "in-process server selenium tests" do
it_should_behave_like "all selenium tests"
prepend_before(:all) do

View File

@ -101,16 +101,34 @@ shared_examples_for "dashboard selenium tests" do
assignment_menu.should include_text(assignment.title)
end
it "should display student groups in course menu" do
course_with_student_logged_in
@course.update_attributes(:start_at => 2.days.from_now, :conclude_at => 4.days.from_now, :restrict_enrollments_to_course_dates => false)
Enrollment.update_all(["created_at = ?", 1.minute.ago])
get "/"
course_menu = driver.find_element(:link, I18n.t('links.courses','Courses')).find_element(:xpath, '..')
driver.action.move_to(course_menu).perform
course_menu.should include_text(I18n.t('#menu.my_courses','My Courses'))
course_menu.should include_text(@course.name)
end
it "should display student groups in course menu" do
course_with_student_logged_in
group = Group.create!(:name=>"group1", :context => @course)
group.add_user(@user)
@course.update_attributes(:start_at => 2.days.from_now, :conclude_at => 4.days.from_now, :restrict_enrollments_to_course_dates => false)
Enrollment.update_all(["created_at = ?", 1.minute.ago])
get "/"
course_menu = driver.find_element(:link, I18n.t('links.courses_and_groups','Courses & Groups')).find_element(:xpath, '..')
driver.action.move_to(course_menu).perform
course_menu.should include_text(I18n.t('menu.current_groups','Current Groups'))
course_menu.should include_text(I18n.t('#menu.current_groups','Current Groups'))
course_menu.should include_text(group.name)
end

View File

@ -24,6 +24,7 @@ shared_examples_for "plugins selenium tests" do
Twitter.stub(:config_check).and_return(nil)
driver.find_element(:css, "button.save_button").click
wait_for_ajax_requests
keep_trying_until{ driver.find_element(:css, "#flash_notice_message").displayed? }
driver.find_element(:css, "#flash_notice_message").text.should match(/successfully updated/)
@ -48,6 +49,7 @@ shared_examples_for "plugins selenium tests" do
driver.find_element(:css, "#settings_name").send_keys("asdf")
driver.find_element(:css, "button.save_button").click
wait_for_ajax_requests
keep_trying_until{ driver.find_element(:css, "#flash_notice_message").displayed? }
driver.find_element(:css, "#flash_notice_message").text.should match(/successfully updated/)
@ -74,6 +76,7 @@ shared_examples_for "plugins selenium tests" do
GoogleDocs.stub(:config_check).and_return(nil)
driver.find_element(:css, "button.save_button").click
wait_for_ajax_requests
keep_trying_until{ driver.find_element(:css, "#flash_notice_message").displayed? }
driver.find_element(:css, "#flash_notice_message").text.should match(/successfully updated/)
@ -100,6 +103,7 @@ shared_examples_for "plugins selenium tests" do
LinkedIn.stub(:config_check).and_return(nil)
driver.find_element(:css, "button.save_button").click
wait_for_ajax_requests
keep_trying_until{ driver.find_element(:css, "#flash_notice_message").displayed? }
driver.find_element(:css, "#flash_notice_message").text.should match(/successfully updated/)
@ -128,6 +132,7 @@ shared_examples_for "plugins selenium tests" do
ScribdAPI.stub(:config_check).and_return(nil)
driver.find_element(:css, "button.save_button").click
wait_for_ajax_requests
keep_trying_until{ driver.find_element(:css, "#flash_notice_message").displayed? }
driver.find_element(:css, "#flash_notice_message").text.should match(/successfully updated/)
@ -154,6 +159,7 @@ shared_examples_for "plugins selenium tests" do
Tinychat.stub(:config_check).and_return(nil)
driver.find_element(:css, "button.save_button").click
wait_for_ajax_requests
keep_trying_until{ driver.find_element(:css, "#flash_notice_message").displayed? }
driver.find_element(:css, "#flash_notice_message").text.should match(/successfully updated/)
@ -163,6 +169,7 @@ shared_examples_for "plugins selenium tests" do
settings[:api_key].should == 'asdf'
settings[:secret_key].should == 'asdf'
end
end
describe "plugins Windows-Firefox-Tests" do

View File

@ -237,9 +237,7 @@ describe "manage_groups selenium tests" do
category = find_with_jquery(".group_category:visible")
category.find_elements(:css, ".group_blank .user_id_#{john.id}").should be_empty
group_div = category.find_element(:css, "#group_#{group.id}")
driver.action.move_to(group_div).perform
group_div.find_element(:css, ".delete_group_link").click
driver.execute_script("$('#group_#{group.id} .delete_group_link').hover().click()") #move_to occasionally breaks in the hudson build
confirm_dialog = driver.switch_to.alert
confirm_dialog.accept
wait_for_ajaximations

View File

@ -49,6 +49,7 @@ describe "learning outcome test" do
driver.find_element(:css, '#right-side a:last-child').click
driver.find_element(:css, '.add_rubric_link').click
driver.find_element(:css, '#rubric_new input[name="title"]').send_keys('New Rubric')
#edit first criterion
driver.execute_script('$(".links").show();')#couldn't get mouseover to work
edit_desc_img = driver.
@ -77,31 +78,31 @@ describe "learning outcome test" do
driver.find_element(:id, 'find_outcome_criterion_dialog').should be_displayed
outcome_div = driver.find_element(:css, '#find_outcome_criterion_dialog table tr td.right .outcome_' + @first_outcome.id.to_s)
outcome_div.find_element(:css, '.short_description').text.should == @first_outcome.short_description
outcome_div.find_element(:css, '.criterion_for_scoring').click
unless is_checked("#find_outcome_criterion_dialog .criterion_for_scoring")
driver.find_element(:css, "#find_outcome_criterion_dialog .criterion_for_scoring").click
end
outcome_div.find_element(:css, '.select_outcome_link').click
driver.find_element(:id, 'find_outcome_criterion_dialog').should_not be_displayed
driver.find_element(:css, '#criterion_3 .learning_outcome_flag').should be_displayed
driver.find_element(:css, '#criterion_3 td.points_form').should include_text('3 pts')
driver.find_element(:css, '#criterion_3 td.points_form').should include_text('3')
#add second outcome
driver.find_element(:css, '#rubric_new .find_outcome_link').click
driver.find_element(:css, '#find_outcome_criterion_dialog .outcomes_select:last-child').click
outcome_div = driver.find_element(:css, '#find_outcome_criterion_dialog table tr td.right .outcome_' + @second_outcome.id.to_s)
outcome_div.find_element(:css, '.select_outcome_link').click
driver.find_element(:id, 'find_outcome_criterion_dialog').should_not be_displayed
driver.find_element(:css, '#criterion_4 .learning_outcome_flag').should be_displayed
#save and check rubric
driver.find_element(:id, 'edit_rubric_form').submit
wait_for_ajax_requests
wait_for_animations
wait_for_ajaximations
driver.find_element(:css, '#rubrics .edit_rubric_link img').should be_displayed
find_all_with_jquery('#rubrics tr.criterion:visible').size.should == 4
driver.find_element(:css, '#left-side .outcomes').click
driver.find_element(:link, "Outcomes").click
driver.find_element(:css, '#right-side a:last-child').click
driver.find_element(:css, '#rubrics .details').should include_text('--')
driver.find_element(:css, '#rubrics .details').should include_text('14')
end
end

View File

@ -432,7 +432,7 @@ shared_examples_for "quiz selenium tests" do
end
#### Numerical Answer
it "should create a quiz question with a matching question" do
it "should create a quiz question with a numerical question" do
start_quiz_question
quiz = Quiz.last
@ -443,7 +443,7 @@ shared_examples_for "quiz selenium tests" do
tiny_frame = wait_for_tiny(question.find_element(:css, 'textarea.question_content'))
in_frame tiny_frame["id"] do
driver.find_element(:id, 'tinymce').send_keys('This is a matching question.')
driver.find_element(:id, 'tinymce').send_keys('This is a numerical question.')
end
answers = question.find_elements(:css, ".form_answers > .answer")

View File

@ -190,7 +190,7 @@ describe "speedgrader selenium tests" do
driver.find_element(:id, "audio_record_option").should be_displayed
}
driver.find_element(:id, "video_record_option").should be_displayed
driver.find_element(:css, '.ui-icon-closethick').click
find_with_jquery('.ui-icon-closethick:visible').click
driver.find_element(:id, "audio_record_option").should_not be_displayed
#check for file upload comment

View File

@ -483,9 +483,9 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
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 #upload_media_tab').click
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
driver.find_element(:css, '#ui-dialog-title-media_comment_dialog + a .ui-icon-closethick').click
find_with_jquery('.ui-icon-closethick:visible').click
driver.find_element(:id, 'media_comment_dialog').should_not be_displayed
end