How to append text in textarea having existing text in it

29 Views Asked by At

This is my current code

WebElement textarea_click = driver.findElement(By.xpath("//*[@id=\"gvPods_txt_Comment_" + i + "\" ]"));
                        
             textarea_click.click();
             Thread.sleep(15000);
System.out.println("Text area is open");

                        
textarea_click.append = ("XWC status is NOGO");

Thread.sleep(2000);`

I intend to append the value of textarea_click.

1

There are 1 best solutions below

3
Lajos Arpad On

You can get the value of the textarea via

textarea_click.getAttribute("value")

And you can append the value via

setAttribute(textarea_click,"value",textarea.getAttribute("value") + "XWC status is NOGO");

Sources:

https://vaadin.com/forum/thread/3803119/get-value-from-textfield-textarea-using-selenium https://groups.google.com/g/selenium-users/c/3J27G1GxCa8?pli=1