I change FindMethod behavior.

Apr 23, 2010 at 1:57 AM

I recompile WAX with WatiN 2.0 RC1.

I find that WAX can't find the element in frames.

So I change some code in FindMethod.cs.

Here is a example for FindById:

var docs = FindAllDocuments(context);
            WatiN.Core.Element elem = null;
            foreach (WatiN.Core.Document d in docs)
            {
                elem = d.Element(WatiN.Core.Find.ById(this.Value));
                if (elem != null && elem.Exists)
                    break;
            }            
            return elem;

 private List FindAllDocuments(IExecutionContext context)
{
var docs = new List<WatiN.Core.Document>();
// First find all frames FindAllFrames(context.Browser.Frames, docs); docs.Add(context.Browser); // Then add browser self return docs;
}

private void FindAllFrames(WatiN.Core.FrameCollection frames, List<WatiN.Core.Document> docs)
{
if (frames.Count == 0)
return;
foreach (WatiN.Core.Frame fm in frames)
{
docs.Add(fm);
FindAllFrames(fm.Frames, docs);
}
return;
}