Hello Max,

I was the author of the code at that link.   It was more proof of concept 
than anything else and I haven't even checked recently to see if it still 
works against the live site.

One thing to keep in mind is that the code I wrote (the ruby/Watir side of 
things) isn't a general script for managing drag and drop.   It works with 
the specific example at script.aculo.us.   I built it by reverse engineering 
the script.aculo.us javascript and doing the appropriate ruby/watir things 
to simulate the drag/drop.  I would not expect it to work for any javascript 
code other than the script.aculo.us scripts.

There also isn't a whole lot that requires Watir in this code - it is mostly 
just plain DOM injection of events and such.

Not sure that helps but....

--andy





----Original Message Follows----
From: "Max Russell" <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: <[email protected]>
Subject: [Wtr-general] Drag and drop
Date: Thu, 17 Aug 2006 14:39:53 +0100

Hi there-



I have been looking at calling javascript and manipulating the DOM in
order to drag drop some images:



I am working of an example I found here:
zbarzone.blogspot.com/2006/05/drag-and-drop-with-watir.html





Code looks like this



require 'test/unit'

require 'watir'



class Watir::IE

   def run_script(js)

     ie.Document.parentWindow.execScript(js)

   end

end



class TestWatir < Test::Unit::TestCase

   def test_drag_and_drop

ie = Watir::IE.start('http://testaddress.com)

             ie.frame("main").text_field(:name,
"username").set("USERNAME")

             ie.frame("main").text_field(:name,
"password").set("PASSWORD")

             ie.frame("main").select_list(:name,
"ldapDir").select("DOMAIN")

             ie.frame("main").button(:name, "Login").click



             #expand the admin node

             ie.frame("left").link(:index, 35).click

             #click on the data management link

             ie.frame("left").link(:index, 54).click



             #Enter a search string into the search field.

             ie.frame("main").text_field(:id,
"Search_box").set("SEARCHSTRING")

             #Click to search

             ie.frame("main").button(:id, "btn_search").click



             ie.frame("main").run_script("document.blah =
document.createEventObject(); document.blah.button = 1")


ie.frame("main").run_script("document.getElementById('10439,10439').fire
Event('onmousedown', document.blah)")

             ie.frame("main").run_script("document.blah =
document.createEventObject(); document.blah.clientX =
document.getElementById('search_results'); document.blah.clientY =
document.getElementById('drop_p1')")#.offsetLeft .offsetTop


ie.frame("main").run_script("document.getElementById('10439,10439').fire
Event('onmousemove', document.blah)")


ie.frame("main").run_script("document.getElementById('10439,10439').fire
Event('onmouseup', document.blah)")

     #end



     end

   end





This is all fine, I can access the object I want - the div element
10439,10439' but it never moves it to the drop





Doing a divs.show of the frame I am accessing gives this:



index id                  className

1     background          merge_background

2     search

3     search_patients_wrappermerge_box

4     search_wrapper      merge_search_results_wrapper

5     wait_msg

6     search_results      merge_search_results

7     10439,10459         People_Widget

8     10439,10439         People_Widget

9     merge_next_10       merge_next_10

10    pat1                merge_box

11    drop_p1             drop_zone

12    drop_p1_toolbar     tool_bar

13    person_one          person_one

14    p1_body             merge_body

15    pat2                merge_box

16    drop_p2             drop_zone

17    drop_p2_toolbar     tool_bar

18    person_two          person_two

19    p2_body             merge_body

20    button_panel        merge_btn_panel

21    reports             dm_reports

22    invisible





So why won't the People_Widget I'm trying to move, move?



Max Russell

test Analyst.

InPS



Tel: 01382 223900

Fax: 01382 204488



Visit our Web site at www.inps.co.uk



The information in this internet email is confidential and is intended
solely for the addressee. Access, copying or re-use of information in it
by anyone else is not authorised. Any views or opinions presented are
solely those of the author and do not necessarily represent those of In
Practice Systems Limited or any of its affiliates. If you are not the
intended recipient please contact [EMAIL PROTECTED]





_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general


_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to