Javi
Javi

Reputation: 81

Working with textarea

How can I work with textareas using watin? There is no function like "browser.TextArea(...)".

Is there another name for textareas? I only need to find it and work with rows/cols.

Upvotes: 1

Views: 1165

Answers (2)

Ken Richards
Ken Richards

Reputation: 3013

Just came across this myself. I thought I would post a more complete answer for people that are still stumped by this. Just use the GetAttributeValue method on the TextField instance like so:

TextField field = Document.TextField(Find.ByName("comments"));
Assert.AreEqual("10", field.GetAttributeValue("rows"));
Assert.AreEqual("42", field.GetAttributeValue("cols"));

Upvotes: 0

dugas
dugas

Reputation: 12443

Use the TextField method to access a TextArea.

From the Watin Homepage (modified for this question)

[Test] 
public void SearchForWatiNOnGoogle()
{
  using (var browser = new IE("http://www.google.com"))
  {
    // If there was a TextArea with the name q - the next line would get the TextArea object and assign it to the textField variable.
    var textField = browser.TextField(Find.ByName("q")); 
   // Do what you need to do with the TextArea, for example, get the text from the textArea:
   string textAreaText = textField.Value;
  }
}

Upvotes: 3

Related Questions