Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set text into TextArea with Selenium Webdriver?

I am trying to set some Text into the TextArea which has some kind of text to it by default which when clicked clears out and then you can set text to it, but I'm enable to perform it with webdriver using java.


Here's the code snippet of the TextArea:

<textarea id="gwt-uid-13" class="v-textarea v-widget v-textarea-required v-required v-has-width v-textarea-prompt" aria-labelledby="gwt-uid-12" aria-required="true" rows="5" tabindex="0" style="width: 600px;" maxlength="4000"/>


Here's what I have tried so far: element is the TextArea control itself:

element= driver.findElement(By.id("gwt-uid-13"))
element.clear();
element.sendKeys("Modification Comment TextArea");

Also, I tried first clicking the element too:

element.click(); element.clear(); element.sendKeys("Modification Comment TextArea");

Please check out the images attached for more info:

like image 796
AmeetV27 Avatar asked Sep 17 '25 18:09

AmeetV27


1 Answers

This is something that works for me (got to know this with trial and error) - instead of performing click() first, I tried sending TAB and clear and the value.

element.sendKeys(Keys.TAB);
element.clear();
element.sendKeys("Some Sample Text Here");

Thanks

like image 168
AmeetV27 Avatar answered Sep 19 '25 09:09

AmeetV27