[Wtr-general] Drag and drop
Max Russell
mrussell at inpses.co.uk
Thu Aug 17 09:39:53 EDT 2006
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 is.helpdesk at inps.co.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20060817/a3739227/attachment.html
More information about the Wtr-general
mailing list