Monday, June 22, 2009

Selecting Popup window without Id

public bool SelectTopWindow()
{
    try
    {
        string[] arr = GetAllWindowNames();
        if (arr.Length != 0)
        {
            System.Threading.Thread.Sleep(1000);
            _selObj.SelectWindow(arr.GetValue(arr.Length - 1).ToString());
            return true;
        }
    }
    catch (Exception exc)
    {
        return false;
    }
}

3 comments:

  1. Hi amit,
    I have seen your posts and Thx for your posts...
    I used below code and not working....I am using VS2010 IDE with C# code.

    1) selenium.Click("css=input[id$='_LookupFooterImageButton']");
    2) String feedWinId = selenium.GetEval("{var windowId; for(var x in selenium.browserbot.openedWindows ) {windowId=x;} }");
    3) selenium.SelectWindow(feedWinId);
    4) selenium.WindowFocus();
    5) selenium.Type("//form[@id='form1']/table//*[@id='SearchTextBox']", "p");

    Here while executing, selenium RemoteRunner executes line 1 which is going to open popup window and after that no response for long time..
    So I closed that opened popup window manually while executing, Immediately lines 2,3 and 4 are executing....
    Line 5 is the command to give input on popup window...
    So whatever lines are there after the line which will open popup window are not executing. Also when i close popup manully, immediately excuting those lines.. so i can't get id or name of popup window to handle...

    Can u help me on this? How i can pass input to Popup window....


    Thx in advance,
    SCSVEL

    ReplyDelete
  2. hy your post realy save me thanks from argentina and keep that way ;)

    ReplyDelete
  3. Thank you! The code below works and it really really helped me.

    1) selenium.Click("css=input[id$='_LookupFooterImageButton']");
    2) String feedWinId = selenium.GetEval("{var windowId; for(var x in selenium.browserbot.openedWindows ) {windowId=x;} }");
    3) selenium.SelectWindow(feedWinId);
    4) selenium.WindowFocus();
    5) selenium.Type("//form[@id='form1']/table//*[@id='SearchTextBox']", "p");

    ReplyDelete