Quick and easy way to double-click in Watir use the fire_event command:
$ie.link(:id,”object_to_doubleclick”).fire_event(”ondblclick”)
Sometimes double clicking objects generate a new window. Make sure your Internet Explorer settings are set to allow popups: (IE 7)
- Tools/Internet Options/Security/Custom Level
- Allow websites to prompt for information using scripted windows
- Close/Save
If double clicking causes a popup window to show up, you may need to handle it with the no_click action.
$ie.link(:id,”object_to_doubleclick”).fire_event_no_wait(”ondblclick”)
Watir Tip: If you are using Watir 1.5.3 you should be ok, but if you have an older version like I did, a hack to use the fire_event_no_wait would be to update the element file:
C:\ruby\lib\ruby\gems\1.9\gems\watir-1.4.1\water\element.rb
Replace with:
#code from jira.openqa.org/browse/ WTR-144 to add a fire_event_no_wait
#****************************************************************
def fire_event(event)
fire_event!(event)
@container.wait
end
def fire_event!(event)
assert_enabled
highlight(:set)
ole_object.fireEvent(event)
highlight(:clear)
end
def fire_event_no_wait(event)
assert_enabled
highlight(:set)
object = “#{self.class}.new(self, :unique_number, #{self.unique_number})”
@page_container.eval_in_spawned_process(object + “.fire_event!(\”#{event}\”)”)
highlight(:clear)
end
#****************************************************************
Finally, to bypass popup windows don’t forget to user startClicker , Here’s an example of double clicking to open up a dialog box where the user enters information and submits it.
require ‘watir’
require ‘watir/winClicker’
require ‘watir\contrib\enabled_popup’
require ‘watir/dialog’
require ‘dl’
include Watir
$ie.link(:id,”object_to_doubleclick”).fire_event_no_wait(”ondblclick”)
startClicker(”OK”, 5, “\[Enter text here!\]“)

You must log in to post a comment.