On Thu, Dec 8, 2011 at 3:36 AM, @90kts <tim.ko...@gmail.com> wrote: > Well it appears from the OP error that the return object > of Browser#execute_script is a WebDriver::Element.. hence my code is > failing as it expects a hash. > > I'm not sure why this is doing it on Win2K8 R2 with IE9, as I don't have > that development platform... but it was tested on Win2K3 with IE9 as Chuck > mentioned. > > I could just raise an error like Jari suggested, but that won't help the > outcome (getting navigation timings). > > We *could* just monkey patch the execute_script method, but before I do, > Jari, is there a more elegant solution? > > module Watir > class Browser > def execute_script(script, *args) > args.map! { |e| e.kind_of?(Watir::Element) ? e.wd : e } > obj = @driver.execute_script(script, *args) > obj.each { |k,v| obj[k] = wrap_elements_in(v) } > obj > end > end > end >
Well, execute_script should already wrap instances of Selenium::WebDriver::Element in Watir::Element, so I'm not sure how that is happening. https://github.com/jarib/watir-webdriver/blob/master/lib/watir-webdriver/browser.rb#L122 I don't really see how the monkey patch would help (e.g. it would break any script that doesn't return a Hash). Someone needs to get their hands on a Windows box in order to solve this I think :) > -- > Before posting, please read http://watir.com/support. In short: search > before you ask, be nice. > > watir-general@googlegroups.com > http://groups.google.com/group/watir-general > watir-general+unsubscr...@googlegroups.com > -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com