开发者

Is there a way to select a child element inside another child element in Watin

I am trying to select a link/button inside of a form, that is in a div. the way it was made is that there are two links/buttons of the same id, name etc. however they are in different forms, so the code i wanted to use is:

_myTest.For开发者_运维百科m(Find.ById("PermissionsForm")).Child(Find.ByClass("saveBtn")).Child(Find.ByText("SAVE"));

any help would be appreciated


I think this is what you need:

var button = _myTest.Form("PermissionsForm").Button(Find.ByClass("saveBtn"));

This will lookup the button having the class 'saveBtn' inside the form 'permissionsform' in your browser instance _myTest.

Have a look at this page to decide if you need to have .Button(..) or .Link(...) based on the html tag that is used in your html.


How about building a regex for the element?

Regex could something like this Regex elementRe = new Regex("id=LnkOk href="http://stackoverflow.com");

Then you can use your code to Click this link. The Click method can be extended to accept Regex if it is not already doing that.

Let me know how this goes or if you need more info. Cheers, DM

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜