开发者

WatiN - Find Form By Element

开发者 https://www.devze.com 2023-01-07 14:19 出处:网络
I have a sample webpage: <form action=blabla.php methog=post>...</form> <form action=blabla.php methog=post>...</form>

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

精彩评论

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