tags:

views:

56

answers:

1

Hello, 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 name="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() ?

A: 

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

Shady M. Najib