Reputation: 337
I am trying to add some value in a TextArea from Java to a WebPage, and I am using the following code :
JavascriptExecutor js = driver;
js.executeScript("CodeExpressionMirror.fromTextArea(document.getElementById('textToParse')).setValue(\"" + text + "\");");
The problem is that if the textArea already had some value in it, let's say "London", then in my case, the above code will override it with the value in setValue, and from the CodeMirror docs, I didn't see AddValue method. I have never worked with JavaScript or Web Development before, which makes things a bit more difficult for me.
Upvotes: 1
Views: 231
Reputation: 11
var string = js.executeScript("CodeExpressionMirror.fromTextArea(document.getElementById('textToParse')).getValue();
js.executeScript("CodeExpressionMirror.fromTextArea(document.getElementById('textToParse')).setValue(\"" + string + text + "\");");
Use code like this, in this you can get the current value and combine it with the new value.
Upvotes: 1