This question is locked. New answers and comments are not allowed.
I have a number of Editors on a page. I have an automated test that clicks the image button on one of the editors. This is a custom dialog that is a page with two frames. I am trying to get a reference to both frames so I can manipulate the contents. The following code works if I single step through in debug mode but fails if I just run it. I commented the line that fails. This is my version of the example code found in the documentation.
var frameCount = 2;
switch (ActiveBrowser.BrowserType)
{
case BrowserType.FireFox:
case BrowserType.InternetExplorer:
frameCount = 6;
break;
case BrowserType.Safari:
break;
}
Wait.For(mybrowser => mybrowser.Frames.Count == frameCount, ActiveBrowser, 12000);
var result = new List<HtmlForm>(2);
FramesCollection frames = ActiveBrowser.Frames;
Browser topFrame = frames[1];
Wait.For(mybrowser => mybrowser.Find.SearchRootElement.Children.Count > 1, topFrame, 12000);
var kids = topFrame.Find.SearchRootElement.Children;
var firstKid = kids[1];
var kidsKids = firstKid.Children;
result.Add(kidsKids[0].As<HtmlForm>());
var bottomFrame = frames[2];
// ***** This line times out when I run this code but not if I single step in debug mode.
Wait.For(mybrowser => mybrowser.Find.SearchRootElement.Children.Count > 1, bottomFrame, 12000);
// ***** If I remove the above line the kids[1] fails with index out of range
kids = bottomFrame.Find.SearchRootElement.Children;
firstKid = kids[1];
kidsKids = firstKid.Children;
result.Add(kidsKids[0].As<HtmlForm>());
return result;
************ an update ********************
I put in some Thread.Sleep(4000); statements and the test now works. Not an ideal solution so still looking for the correct way to get this working.
var frameCount = 2;
switch (ActiveBrowser.BrowserType)
{
case BrowserType.FireFox:
case BrowserType.InternetExplorer:
frameCount = 6;
break;
case BrowserType.Safari:
break;
}
Wait.For(mybrowser => mybrowser.Frames.Count == frameCount, ActiveBrowser, 12000);
var result = new List<HtmlForm>(2);
FramesCollection frames = ActiveBrowser.Frames;
Browser topFrame = frames[1];
Wait.For(mybrowser => mybrowser.Find.SearchRootElement.Children.Count > 1, topFrame, 12000);
var kids = topFrame.Find.SearchRootElement.Children;
var firstKid = kids[1];
var kidsKids = firstKid.Children;
result.Add(kidsKids[0].As<HtmlForm>());
var bottomFrame = frames[2];
// ***** This line times out when I run this code but not if I single step in debug mode.
Wait.For(mybrowser => mybrowser.Find.SearchRootElement.Children.Count > 1, bottomFrame, 12000);
// ***** If I remove the above line the kids[1] fails with index out of range
kids = bottomFrame.Find.SearchRootElement.Children;
firstKid = kids[1];
kidsKids = firstKid.Children;
result.Add(kidsKids[0].As<HtmlForm>());
return result;
************ an update ********************
I put in some Thread.Sleep(4000); statements and the test now works. Not an ideal solution so still looking for the correct way to get this working.