How to select text area in Selenium which has a HTML code as follows

2.2k Views Asked by At
<textarea rows="7" cols="125" name="nomText1Line1" required="required"></textarea>

I tried using driver.findElement(By.name("nomText1Line1")); didn't work

1

There are 1 best solutions below

1
On

The way you mentioned is the easiest way to select your element. Are you sure there are no syntactical mistakes? This should work:

WebElement textArea = driver.findElement(By.name("nomText1Line1")); 

If you are trying to get the contents of the text area then something like this:

String textArea = driver.findElement(By.name("nomText1Line1")).getText();