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
精彩评论