refactor dependency cucumber feature to use css. This saves us the extra id on the todo element that I added in the previous commit.

This commit is contained in:
Reinier Balt 2010-03-25 16:34:01 +01:00
parent 4f66e463bd
commit 3146fa6bd1
2 changed files with 6 additions and 4 deletions

View file

@ -122,7 +122,7 @@ module TodosHelper
:title => 'Drag onto another action to make it depend on that action', :title => 'Drag onto another action to make it depend on that action',
:class => 'grip') + :class => 'grip') +
image_tag('blank.png', :width => 16, :height => 16, :border => 0, image_tag('blank.png', :width => 16, :height => 16, :border => 0,
:id => "successor_target_#{@todo.id}", :title => "Drop an action to make it depend on this action", :class => 'successor_target') :title => "Drop an action to make it depend on this action", :class => 'successor_target')
end end
end end

View file

@ -37,11 +37,13 @@ When /^I drag "(.*)" to "(.*)"$/ do |dragged, target|
drag_id = Todo.find_by_description(dragged).id drag_id = Todo.find_by_description(dragged).id
drop_id = Todo.find_by_description(target).id drop_id = Todo.find_by_description(target).id
drag_name = "xpath=//div[@id='line_todo_#{drag_id}']//img[@class='grip']" drag_name = "xpath=//div[@id='line_todo_#{drag_id}']//img[@class='grip']"
drop_name = "xpath=//div[@id='line_todo_#{drop_id}']//img[@id='successor_target_#{drop_id}']" # xpath does not seem to work here... reverting to css
# xpath=//div[@id='line_todo_#{drop_id}']//img[@class='successor_target']
drop_name = "css=div#line_todo_#{drop_id} img.successor_target"
# the target img is hidden until drag starts. We need to show the img or the # HACK: the target img is hidden until drag starts. We need to show the img or the
# xpath will not find it # xpath will not find it
js="$('img#successor_target_#{drop_id}').show();" js="$('div#line_todo_#{drop_id} img.successor_target').show();"
selenium.get_eval "(function() {with(this) {#{js}}}).call(selenium.browserbot.getCurrentWindow());" selenium.get_eval "(function() {with(this) {#{js}}}).call(selenium.browserbot.getCurrentWindow());"
selenium.drag_and_drop_to_object(drag_name, drop_name) selenium.drag_and_drop_to_object(drag_name, drop_name)