Search code examples
c#watin

Find Iframe inside div in WatIn


I have ajax based popup with below html

<div id="div1">
<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td>
            <iframe name="WindowManager">
                <select name="sel">
                    <option>1</option>
                    <option>2</option>
                </select>
                <input type="button" value="Submit" />
            </iframe>
        </td>
    </tr>        
</table>

I am trying to select the drop down and press the submit button using WatIn. I am able to do but without the popup and IFRAME. Does any one has any idea how to do this.


Solution

  • I understand you want to do it from C# desktop application?

    If yes you can press submit button in IFRAME using WebBrowser control and following code:

        WebBrowser wb = new WebBrowser();
        wb.Navigate("yourpage");
        //when document loaded
    
        wb.Document.Window.Frames[0].Document.GetElementsByTagName("input")[0].InvokeMember("Click");
    

    This example assumes there is only one control of type "input" on that page and it is our submit button. Otherwise you can use also GetElementById etc...