I'm trying to insert a HTML code (around 3000 letters) into a Textarea. There is .sendkeys
, however that's very slow. So I searched and found a way to use javascript with selenium and it worked fine till I reached the point where I had to add HTML code. My current code:
public void AttributeSet(string id, string value) {
IJavaScriptExecutor js = (IJavaScriptExecutor)browser;
js.ExecuteScript("document.getElementById(\"" + id + "\").value = ('" + value + "');");
}
I realized that it works just fine with a single line of string, however it has a hard time with multiline strings and strings which contain quotes ""
in them.
Since HTML code has a bunch of quotes it keeps preventing me to do so. What I tried so far is changing my string (newlines to \n
, " to \"
) and a bunch of other things which I forgot.
Is there an easy way to do this? If yes please help me out I'd appreciate it very much!