Marco,

Looking at your HTML below I think that the problem is that your button 
is located inside a frame, which is loaded via another URL.  Because of 
that, the element would be in a different Watir "container" and wouldn't 
be found inside the top level container for that modal dialog.

Assuming that the frame "main" has the button you want, you should be 
able to click on it by using:

modal.frame('main').button(:text, 'Yes').click

Let me know if that works for you.

David Schmidt

Neri, Marco wrote:
>
> Hi
>
> I'm running v1.5.1.1017. I need some help re modal dialog.
>
> I'm using this code to access a modal dialog:
>
> @ie.link(:text, "Delete").click_no_wait
> modal = @ie.modal_dialog(:title, 'Confirmation')
> puts(modal.to_s)
> modal.button(:text, 'Yes').click
>
> In the console the puts shows #<Watir::ModalDialog:0x27c0970>. Based 
> on this I assume it has found the dialog using the title because no 
> error is thrown. I'm not 100% sure though. I had a look in the src for 
> ModalDialog.rb but cannot see a method that I could use to to get a 
> list of all elements in the dialog.
>
> The button click is not working the console shows the error:
>
>   1) Error:
> test802(TC_test802):
> Watir::Exception::UnknownObjectException: Unable to locate object, 
> using text an
> d Yes
>     c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1017/./watir.rb:2237:in 
> `assert_e
> xists'
>     c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1017/./watir.rb:2378:in 
> `click'
>     C:/visual studio 
> projects/VictoriaPolice/AttendanceTests/bug802.rb:61:in `te
> st802'
>
> I have the same issue if I use value and insert a value="Yes" into the 
> src for the dialog. I also tried using :index
>
>
> The src for the dialog:
>
> <html>
>         <head>
>                 <TITLE>Confirmation</TITLE>
>                 <meta name="GENERATOR" content="Microsoft Visual 
> Studio.NET 7.0">
>                 <meta 
> content="http://schemas.microsoft.com/intellisense/ie5"; 
> name="vs_targetSchema">
>         </head>
>         <frameset border="0" rows="0,100%" frameSpacing="0" 
> frameBorder="0">
>                 <frame name="header" src="" scrolling="no" noresize>
>                 <frame name="main" src="ConfirmDelete.aspx">
>         </frameset>
> </html>
>
> The src for confirmdelete.aspx:
>
> <div id="ConfirmDelete">
>         <img src="../Images/ICO_EXCLAMATION.gif">
>         <p><label id="MessageLabel" runat="server"></label></p>
>         <div id="confirmbuttons">
>                 <button type="submit" runat="server" 
> onclick="javascript:OnYesClick();">Yes</button>
>                 <button type="submit" runat="server" 
> onclick="javascript:OnNoClick();">No</button>
>         </div>
> </div>
>
> Is the issue that the buttons are defined using submit instead of 
> <input type=button value="Close" - does this means that the modal 
> dialog support in 1.5 is restricted only to dialogs implemented 
> similar to the example in unit test. ?
>
> Any suggestions? thanks
>
> Marco
>

_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to