开发者

WatiN - Find Form By Element

I have a sample webpage:

<form action=blabla.php methog=post>...</form>
<form action=blabla.php methog=post>...</form>
<form action=blabla.php methog=post>...</form>
<form action=blabla.php methog=post>...</form>
<form action=blabla.php methog=post><textarea na开发者_运维问答me="data"></textarea><input type="submit"></form>

I want to set textarea and submit last form. It's OK, I can find the text area with Find.ByName("data") syntax.

But how can I find the corresponding form for the "data" element?

I don't want to use

browser.Forms[index] 

Is there any way how I can find a corresponding form to be able to make Form.Submit() ?


After you get your text area (for eg in a var textArea) just use Ancestor()

Form myForm = textArea.Ancestor("form");

.Ancestor(...) resembles .Parent in ASP.NET

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜