spec: refactor selenium specs

refactored to use click_option
refactored to use have_class and have_attribute
refactored do end

Change-Id: I6b3a921152347a5057263d727ccdc00ba9fd21ea
Reviewed-on: https://gerrit.instructure.com/17495
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jake Sorce <jake@instructure.com>
QA-Review: Jake Sorce <jake@instructure.com>
This commit is contained in:
Kyle Rosenbaum 2013-02-06 13:28:45 -07:00 committed by Jake Sorce
parent 870c613690
commit 2a7e6f1842
10 changed files with 21 additions and 23 deletions

View File

@ -4,15 +4,14 @@ describe "account" do
it_should_behave_like "in-process server selenium tests"
before (:each) do
course_with_admin_logged_in
course_with_admin_logged_in
end
describe "authentication configs" do
it "should allow setting up a secondary ldap server" do
get "/accounts/#{Account.default.id}/account_authorization_configs"
f('#add_auth_select').
find_element(:css, 'option[value="ldap"]').click
click_option('#add_auth_select', 'ldap', :value)
ldap_div = f('#ldap_div')
ldap_form = f('form.ldap_form')
ldap_div.should be_displayed
@ -109,8 +108,7 @@ describe "account" do
it "should be able to set login labels for delegated auth accounts" do
get "/accounts/#{Account.default.id}/account_authorization_configs"
f('#add_auth_select').
find_element(:css, 'option[value="cas"]').click
click_option('#add_auth_select', 'cas', :value)
f("#account_authorization_config_0_login_handle_name").should be_displayed
f("#account_authorization_config_0_auth_base").send_keys("cas.example.com")

View File

@ -25,14 +25,14 @@ describe "external tool assignments" do
keep_trying_until do
fj('#context_external_tools_select td.tools .tool:first-child:visible').click
sleep 2 # wait for javascript to execute
f('#context_external_tools_select input#external_tool_create_url').attribute('value').should == @t1.url
f('#context_external_tools_select input#external_tool_create_url').should have_attribute('value', @t1.url)
end
keep_trying_until do
ff('#context_external_tools_select td.tools .tool')[1].click
f('#context_external_tools_select input#external_tool_create_url').attribute('value').should == @t2.url
f('#context_external_tools_select input#external_tool_create_url').should have_attribute('value', @t2.url)
end
fj('.add_item_button:visible').click
f('#assignment_external_tool_tag_attributes_url').attribute('value').should == @t2.url
f('#assignment_external_tool_tag_attributes_url').should have_attribute('value', @t2.url)
submit_form('form.new_assignment')
wait_for_ajax_requests
@ -54,9 +54,9 @@ describe "external tool assignments" do
f('#context_external_tools_select').should_not be_displayed
f('#assignment_external_tool_tag_attributes_url').click
ff('#context_external_tools_select td.tools .tool')[0].click
f('#context_external_tools_select input#external_tool_create_url').attribute('value').should == @t1.url
f('#context_external_tools_select input#external_tool_create_url').should have_attribute('value', @t1.url)
fj('.add_item_button:visible').click
f('#assignment_external_tool_tag_attributes_url').attribute('value').should == @t1.url
f('#assignment_external_tool_tag_attributes_url').should have_attribute('value', @t1.url)
submit_form('form.edit_assignment')
wait_for_ajax_requests

View File

@ -195,7 +195,7 @@ describe "assignment rubrics" do
f('.rubric_total').should include_text "5"
f('.save_rubric_button').click
wait_for_ajaximations
f('.grading_value').attribute(:value).should == "5"
f('.grading_value').should have_attribute(:value, '5')
end
def mark_rubric_for_grading(rubric, expect_confirmation)

View File

@ -544,7 +544,7 @@ describe "context_modules" do
driver.execute_script("$('#context_module_item_#{tag.id} .indent_item_link').hover().click()")
wait_for_ajaximations
f("#context_module_item_#{tag.id}").attribute(:class).should include("indent_1")
f("#context_module_item_#{tag.id}").should have_class('indent_1')
tag.reload
tag.indent.should == 1
@ -558,7 +558,7 @@ describe "context_modules" do
click_option("#content_tag_indent_select", "Indent 1 Level")
submit_form("#edit_item_form")
wait_for_ajaximations
f("#context_module_item_#{tag.id}").attribute(:class).should include("indent_1")
f("#context_module_item_#{tag.id}").should have_class('indent_1')
tag.reload
tag.indent.should == 1

View File

@ -22,9 +22,9 @@ describe "conversations sent filter" do
get "/conversations/sent"
conversations = get_conversations
conversations.first.attribute('data-id').should == @c1.conversation_id.to_s
conversations.first.should have_attribute('data-id', @c1.conversation_id.to_s)
conversations.first.should include_text('yay i sent this')
conversations.last.attribute('data-id').should == @c2.conversation_id.to_s
conversations.last.should have_attribute('data-id', @c2.conversation_id.to_s)
conversations.last.should include_text('test')
end

View File

@ -95,8 +95,8 @@ describe "cross-listing" do
form.find_element(:css, "#course_id").send_keys([:control, 'a'], other_course.id.to_s, "\n")
keep_trying_until { f("#course_autocomplete_name").text != "Confirming Course ID \"#{other_course.id}\"..." }
f("#course_autocomplete_name").text.should == other_course.name
form.find_element(:css, "#course_autocomplete_id").attribute(:value).should ==(other_course.id.to_s)
form.find_element(:css, ".submit_button").attribute(:disabled).should == "false"
form.find_element(:css, "#course_autocomplete_id").should have_attribute(:value, other_course.id.to_s)
form.find_element(:css, ".submit_button").should have_attribute(:disable, 'false')
submit_form(form)
keep_trying_until { driver.current_url.match(/courses\/#{other_course.id}/) }

View File

@ -145,7 +145,7 @@ describe "edititing grades" do
end
set_value(grade_input, 3)
a1.send_keys(:tab)
wait_for_ajax_requests
wait_for_ajaximations
f(assignment_1_sel)['class'].should_not include 'dropped'
f(assignment_2_sel)['class'].should include 'dropped'
end

View File

@ -28,7 +28,7 @@ describe "manage groups" do
get "/courses/#{@course.id}/groups"
ff(".group_category").size.should == 3
ff(".group_category.student_organized").size.should == 1
f(".group_category.student_organized").attribute(:id).should == "category_#{group_category1.id}"
f(".group_category.student_organized").should have_attribute(:id, "category_#{group_category1.id}")
end
it "should show one li.category per category" do

View File

@ -52,7 +52,7 @@ describe "submissions" do
create_assignment_and_go_to_page 'media_recording'
f(".submit_assignment_link").click
f('#media_comment_submit_button').attribute('disabled').should == 'true'
f('#media_comment_submit_button').should have_attribute('disabled', 'true')
# leave so the "are you sure?!" message doesn't freeze up selenium
f('#section-tabs .home').click
driver.switch_to.alert.accept

View File

@ -195,7 +195,7 @@ describe "speed grader" do
f('#rubric_summary_container').should include_text(@rubric.title)
f('#rubric_summary_container .rubric_total').should include_text('8')
wait_for_ajaximations
f('#grade_container input').attribute(:value).should == "8"
f('#grade_container input').should have_attribute(:value, '8')
end
it "should create a comment on assignment" do
@ -433,7 +433,7 @@ describe "speed grader" do
wait_for_ajaximations
@submission.reload.score.should == 3
f("#grade_container input[type=text]").attribute(:value).should == '3'
f("#grade_container input[type=text]").should have_attribute(:value, '3')
f("#rubric_summary_container tr:nth-child(1) .editing").should be_displayed
f("#rubric_summary_container tr:nth-child(1) .ignoring").should_not be_displayed
f("#rubric_summary_container tr:nth-child(3) .editing").should_not be_displayed
@ -443,7 +443,7 @@ describe "speed grader" do
# check again that initial page load has the same data.
get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}"
wait_for_ajaximations
f("#grade_container input[type=text]").attribute(:value).should == '3'
f("#grade_container input[type=text]").should have_attribute(:value, '3')
f("#rubric_summary_container tr:nth-child(1) .editing").should be_displayed
f("#rubric_summary_container tr:nth-child(1) .ignoring").should_not be_displayed
f("#rubric_summary_container tr:nth-child(3) .editing").should_not be_displayed