I'd suggest looking at some of the other solutions listed here: http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups perhaps one of them will work better.
Otherwise specific answers to each step of the IRB process that Jarmo suggests, (are you getting the right hwnd, etc) might help to figure out where things are going wrong. (if you are not attaching to the right window for example, that would cause this problem) also be aware that unique_number is not a standard means of identifying an HTML Element for watir (at least I don't see it listed anywhere in our docs for the methods supported by various HTML Elements). I see it referenced only in places such as in step 6 of solution #5 on the page referenced above, where the code i creating a select_no_wait method. I don't think you will be able to use that as a way to select a button to click on (at least its not listed anywhere in the docs as a 'how' for identifying a button). Others more familiar with the guts of the Watir code might correct me on this, but I suspect you might need to find another way to identify the button you are trying to cick On Nov 28, 12:00 pm, Kushal <[email protected]> wrote: > Hi Jarmo, > > Thanks for your post. > > But, I still get the same error i.e. > "Watir::Exception::UnknownObjectException: Unable to locate element, > using :unique_number, 1" when I use: > > require "watir" > b = Watir::Browser.attach :title, /title/ > b.button(:unique_number, 1).click > > Thanks. > > Kushal > > On Nov 25, 11:03 am, Jarmo Pertman <[email protected]> wrote: > > > > > #click_no_wait returning nil is a correct behavior. Open up the page > > in your browser where that button is and then open up an irb session > > and try this: > > require "watir" > > b = Watir::Browser.attach :title, /title/ > > b.button(:unique_number, 1).click > > > Does that do anything or does it throw the same error message as with > > #click_no_wait? > > > If it stays blocking then open up yet another irb session (because the > > previous is unusable due to blocking) and try again to set $DEBUG=true > > and perform #click_no_wait to see the handle to the IE. > > > Now attach again to the window and see if that hwnd matches to your > > window's hwnd: > > b = Watir::Browser.attach :title, /title/ > > # verify that you have the correct window > > b.title > > b.url > > > # now verify that the hwnd matches to the hwnd used by #click_no_wait > > b.hwnd > > > # now try the attach command by #click_no_wait > > b = Watir::IE.attach(:hwnd, THE_HWND) > > # try to access the button > > b.button(:unique_number, 1).html > > > Jarmo Pertman > > ----- > > IT does really matter -http://www.itreallymatters.net > > > On Nov 24, 11:50 am, Arto Vuori <[email protected]> wrote: > > > > Hi Kushal, > > > > I'm having exactly the same problem and I have not found a working > > > solution. > > > I have a need to open and interact with a modal dialog. However, > > > click_no_wait simply returns nil. > > > > -- A. Vuori > > > > On 21 marras, 20:29, Kushal <[email protected]> wrote: > > > > > Hi all, > > > > > I am stuck in this problem for three days now. I need to open a modal > > > > dialog from a button on a webpage. When I use click or > > > > fire_event("onclick"), execution just hangs. This is understandable as > > > > it waits for work to be completed on the modal dialog. > > > > > Therefore, I am trying to useclick_no_wait, but it returns nil. I > > > > made some changes in theclick_no_waitfunction, to display the call > > > > by adding puts command on line 249 and replaced "start rubyw > > > > #{command}" with "rubyw #{command}" > > > > > I get the following error on the console: > > > > > c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/element.rb:58:in > > > > `assert_exists': Unable to locate element, using :unique_number, 1 > > > > (Watir::Exception::UnknownObjectException) > > > > from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/ > > > > element.rb:263 :in `click!' from -e:1 > > > > > The command that is executed in the above call is: > > > > > ruby -e "require 'rubygems';require 'c:/ruby/lib/ruby/gems/1.8/gems/ > > > > watir-1.6.7/lib/watir/core';Watir::Button.new(Watir::IE.attach(:hwnd, > > > > 656538), :unique_number, 1).click!" > > > > > Also, I read this article (http://jira.openqa.org/browse/WTR-144) > > > > which describes how fire_event_no_wait could be added to element.rb > > > > for fire_event("onmousedown") with no wait. However, > > > > eval_in_spawned_process method is not present in PageContainer module > > > > in Watir 1.6.7. > > > > > Thanks. > > > > > Kushal- Hide quoted text - > > - Show quoted text - -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected]
