[Wtr-general] Executing javascript in 1.5

Charley Baker charley.baker at gmail.com
Thu Dec 21 11:13:49 EST 2006


Agreed: http://jira.openqa.org/browse/WTR-121.

On 12/20/06, Charley Baker <charley.baker at gmail.com> wrote:
>
> Ah, you're adding it to the IE class, which in Watir 1.4.1 was a super of
> Frame. In 1.5.1, Frame doesn't inherit from IE, but does include Container
> and PageContainer as mixins. You'll want to change your run_script method to
> the Container namespace:
>
> module Watir::Container
>
>   def run_script
>    ....
>   end
>
> end
>
> -Charley
>
> On 12/20/06, Max Russell < mrussell at inpses.co.uk> wrote:
> >
> >  I'm running the code on the same machine as I'm developing it…
> >
> >
> >
> > The error I'm seeing is like this:
> >
> >
> >
> >
> >
> > test_drag_and_drop(TestWatir):
> >
> > NoMethodError: undefined method `run_script' for
> > #<Watir::Frame:0x2e58b14>
> >
> >     dragdrophacking.rbw:40:in `test_drag_and_drop'
> >
> >
> >
> >
> >
> > The code I'm trying to work is one I've posted before on this list,
> > based on the zbarzone.blogspot.com/ example.
> >
> > I don't expect it to complete the drag, but previously it would actually
> > select the div.
> >
> >
> >
> > 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://everestcf/CV_Tay_Test/home/Index.cfm'<http://everestcf/CV_Tay_Test/home/Index.cfm%27>
> > )
> >
> >     #ie.maximize
> >
> >             ie.frame("main").text_field(:name,
> > "username").set("ltanner")
> >
> >             ie.frame("main").text_field(:name,
> > "password").set("password9")
> >
> >             ie.frame("main").select_list(:name,
> > "ldapDir").select("SARAGON")
> >
> >             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("Batchelor")
> >
> >             #Click to search
> >
> >             ie.frame("main").button(:id, "btn_search").click
> >
> >
> >
> >             #insert a sleep
> >
> >             #sleep(5)
> >
> >
> >
> >             #Guessing at the path to the searched item...
> >
> >             ie.frame("main").div(:id, "10439,10439").flash #accessing
> > through the div id. Pretty Brittle for now, but can wrap this....
> >
> >
> >
> >             widget = ie.frame("main").div(:id, "10439,10439")
> >
> >             #sleep(10)
> >
> >             #ie.frame("main").run_script("alert(document.getElementById
> > ('10439,10439').id)")
> >
> >             #~ #THIS SECTION USES THE SCRIPTACULOUS DRAG/DROP
> >
> >             ie.frame("main").run_script("document.blah =
> > document.createEventObject(); document.blah.button = 1")
> >
> >             ie.frame("main").run_script("document.getElementById('#{widget}').fireEvent('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_toolbar')")#.offsetLeft .offsetTop
> > search_results
> >
> >             ie.frame("main").run_script("document.getElementById('#{widget}').fireEvent('onmousemove',
> > document.blah)")
> >
> >             ie.frame("main").run_script("document.getElementById('#{widget}').fireEvent('onmouseup',
> > document.blah)")
> >
> >             #~ sleep(20)
> >
> >       end
> >
> > end
> >
> >
> >
> >
> >
> > I know the dragdrop hacking stuff is slightly outwith the scope of
> > Watir, but for me it's about the one thing that could really improve testing
> > with Watir.
> >
> >
> >
> >
> >
> > *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*
> >
> >
> >
> > _______________________________________________
> > Wtr-general mailing list
> > Wtr-general at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20061221/49750cef/attachment-0001.html 


More information about the Wtr-general mailing list