spec: use fj for find_with_jquery in selenium tests

Change-Id: I0c05958a048ab89be87cb3a8a847b21dc602fcb4
Reviewed-on: https://gerrit.instructure.com/9530
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jake Sorce <jake@instructure.com>
This commit is contained in:
Bryan Madsen 2012-03-21 09:52:35 -06:00 committed by Jake Sorce
parent a516c8d03f
commit c4c53a33cb
8 changed files with 33 additions and 20 deletions

View File

@ -98,12 +98,20 @@ module SeleniumTestsHelperMethods
end
# f means "find" this is a shortcut to finding elements
# if driver.find_element fails, then it'll try to find it with jquery
def f(selector, scope = nil)
begin
(scope || driver).find_element :css, selector
rescue
nil
end
end
# short for find with jquery
def fj(selector, scope = nil)
begin
find_with_jquery selector, scope
rescue
nil
end
end
@ -112,7 +120,16 @@ module SeleniumTestsHelperMethods
begin
(scope || driver).find_elements :css, selector
rescue
[]
end
end
# same as find with jquery but tries to find several elements instead of one
def ffj(selector, scope = nil)
begin
find_all_with_jquery selector, scope
rescue
[]
end
end
@ -739,7 +756,7 @@ shared_examples_for "all selenium tests" do
##
# returns true if a form validation error message is visible, false otherwise
def error_displayed?
f('.error_text:visible') != nil
fj('.error_text:visible') != nil
end
self.use_transactional_fixtures = false

View File

@ -70,7 +70,7 @@ shared_examples_for "conversations selenium tests" do
@elements = prev_elements
@level -= 1
@input.send_keys(:arrow_left) unless ff('.autocomplete_menu:visible .list').empty?
@input.send_keys(:arrow_left) unless ffj('.autocomplete_menu:visible .list').empty?
wait_for_animations
end

View File

@ -56,8 +56,8 @@ describe "conversations context filtering" do
it "should let you browse for filters" do
new_conversation
@browser = f("#context_tags_filter .browser:visible")
@input = f("#context_tags_filter input:visible")
@browser = fj("#context_tags_filter .browser:visible")
@input = fj("#context_tags_filter input:visible")
browse_menu
menu.should eql ["that course", "the course", "the group"]

View File

@ -18,8 +18,8 @@ describe "course settings tests" do
f('.find_grading_standard_link').click
wait_for_ajaximations
f('.grading_standard_select:visible a').click
f('button.select_grading_standard_link:visible').click
fj('.grading_standard_select:visible a').click
fj('button.select_grading_standard_link:visible').click
f('.done_button').click
f('#course_form').submit
wait_for_ajaximations

View File

@ -33,12 +33,9 @@ shared_examples_for "file uploads selenium tests" do
filename, fullpath, data = get_file("testfile5.zip")
driver.find_element(:css, '#choose_migration_system').
find_element(:css, 'option[value="common_cartridge_importer"]').click
driver.find_element(:css, '#config_options').
find_element(:name, 'export_file').send_keys(fullpath)
driver.find_element(:css, '#config_options').
find_element(:css, '.submit_button').click
click_option('#choose_migration_system', 'common_cartridge_importer', :value)
driver.find_element(:css, '#config_options').find_element(:name, 'export_file').send_keys(fullpath)
driver.find_element(:css, '#config_options').find_element(:css, '.submit_button').click
wait_for_ajax_requests
keep_trying_until { driver.find_element(:id, 'file_uploaded').should be_displayed }

View File

@ -84,13 +84,13 @@ describe "gradebooks" do
get "/courses/#{@course.id}/gradebook"
wait_for_ajaximations
ff('img.turnitin:visible').size.should eql 2
ffj('img.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
ff('img.turnitin:visible').size.should eql 2
ffj('img.turnitin:visible').size.should eql 2
end
end

View File

@ -106,7 +106,7 @@ shared_examples_for "quizzes selenium tests" do
end
def hover_first_question
question = f '.display_question'
question = f('.display_question')
driver.action.move_to(question).perform
end
@ -117,7 +117,7 @@ shared_examples_for "quizzes selenium tests" do
end
def save_question
f('.question_form:visible').submit
fj('.question_form:visible').submit
wait_for_ajax_requests
end
@ -131,7 +131,7 @@ shared_examples_for "quizzes selenium tests" do
end
def edit_first_multiple_choice_answer(text)
element = f 'input[name=answer_text]:visible'
element = fj('input[name=answer_text]:visible')
element.click
element.send_keys text
end
@ -144,7 +144,7 @@ shared_examples_for "quizzes selenium tests" do
def delete_first_multiple_choice_answer
driver.execute_script "$('.answer').addClass('hover');"
f('.delete_answer_link:visible').click
fj('.delete_answer_link:visible').click
end

View File

@ -507,6 +507,5 @@ describe "quizzes question creation" do
save_question
error_displayed?.should be_true
end
end