Using Selenium WebDriver, we can type text in textarea using sendKeys like:
driver.findElement(By.xpath("//textarea")).sendKeys("text to type");
but in my case text to type is JSON something like:
{
"name": "Enter Name",
"id": "Enter ID",
"helpText": "Enter Help Text"
}
If I want to type above JSON in textarea, I can store it in string and type it but I need to resolve escape character issues.
In this case, what could be the best solution to type JSON in textarea using JAVA?
String var = text.replaceAll("\"","\\\"");and then send it.