Although this question has been asked before, I have searched for multiple answers and have not found a solution to my specific problem.
if (driver instanceof JavascriptExecutor) {
System.out.println("In try");
((JavascriptExecutor)driver).executeScript("document.getElementById('comment').value='"+line1+line2+"';");
} else {
throw new IllegalStateException("This driver does not support JavaScript!");
}
I am using the above code to set values in a text area. The variables line1 and line2 are both strings.
The content printed from these variables is as follows:
- Root Cause Analysis: We have analyzed and discovered duplicate transactions present in our database. It seems that there was a problem with the feed returning pending transactions as posted, resulting in filings for two different dates.
We have filed UDC 7735 to perform necessary cleanup. 2. Fixes implemented to resolve the issue:
Despite not containing any quotation marks, I am encountering an error message stating:
Exception thread "main" org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected token ILLEGAL
at Object.InjectedScript._evaluateOn (<anonymous>:878:140)
...
When I attempted to use the sendKeys
method of the driver, it worked but triggered automatic page submission or validation. This means I cannot use the sendKeys function to set the value.
If anyone can provide guidance on how to proceed, I would greatly appreciate it.