How do I grab hold of a pop-up that is opened from a frame?

Posted by KLA on Stack Overflow See other posts from Stack Overflow or by KLA
Published on 2011-01-13T18:06:43Z Indexed on 2011/01/15 0:53 UTC
Read the original article Hit count: 133

Filed under:
|
|

I am testing a website using WatiN. On one of the pages I get a "report" in an Iframe, within this I frame there is a link to download and save the report. But since the only way to get to the link is to use frame.Link(...) the pop-up closes immediately after opening; Code snippet below //Click the create graph button ie.Button(Find.ById("ctl00_ctl00_ContentPlaceHolder1_TopBoxContentPlaceHolder_btnCreateGraph")).Click();

  //Lets export the data

  ie.Div(Find.ById("colorbox"));

  ie.Div(Find.ById("cboxContent"));

  ie.Div(Find.ById("cboxLoadedContent"));

  Thread.Sleep(1000);//Used to cover performance issues

  Frame frame = ie.Frame(Find.ByName(frameNameRegex));

  for (int Count = 0; Count < 10000000; Count++) {double nothing = (Count/12); }//Do nothing I just need a short pause


  //SelectList waits for a postback which does not occur.
  try
  {

        frame.SelectList(Find.ById("rvReport_ctl01_ctl05_ctl00")).SelectByValue("Excel");

  }

  catch (Exception)

  {

       //Do nothing

  }

  //Now click export

  frame.Link(Find.ById("rvReport_ctl01_ctl05_ctl01")).ClickNoWait();

  IE ieNewBrowserWindow = IE.AttachTo<IE>(Find.ByUrl(urlRegex));

  fileDownloadHandler.WaitUntilFileDownloadDialogIsHandled(150); 

  fileDownloadHandler.WaitUntilDownloadCompleted(200);

I have tried using ie instead of frame which is why all those ie.Div's are present. if I use frame the pop-up window opens and closes instantly. If I use ie I get a link not found error. If I click on the link manually, while the test is "trying to find the link" the file will download correctly.

© Stack Overflow or respective owner

Related posts about testing

Related posts about website