How to create ElementFinder in WatiN?
In Wat开发者_StackOverflowiN RC1 how can I create ElementFinder which will find any element on page?
Here is what I found out.
I can create ElementFinder using two ways
First. When creating custom control (extending Div, Table and so on) there is a protected method CreateElementFinder<T>
. Here is an example:
var elementFinder = CreateElementFinder<Element>(
nativeEl => nativeEl.AllDescendants,
Find.ById("id"));
Second. If you are not extending any control you can use NativeElementFinder constructor. Here is an example:
var finder = new NativeElementFinder(
() => browser.Body.NativeElement.AllDescendants,
browser.DomContainer,
new[] { ElementTag.Any },
Find.ById("id"));
精彩评论