I still don't know why this is happening but the workaround I'm using its to programmatically copy the string to clipboard and past it with WebDriver SendKeys() which is normally as simple as:
Clipboard.SetText(myStringContainingHTML);
driver.FindElement(By.Id("myTxtBoxId")).SendKeys(OpenQA.Selenium.Keys.LeftControl + "v");
But actually I tried to do it while multithreading and got the error:
"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it."
So I had to do this workaround just to get it in clipboard:
class MyAsyncClass
{
static IWebDriver driver;
public static void MyAsyncMethod()
{
FirefoxProfile myProfile = new FirefoxProfile();
driver = new FirefoxDriver(myProfile);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
STAClipBoard(myStringWithHtmlCode);
driver.FindElement(By.Id("myTxtBoxId")).SendKeys(OpenQA.Selenium.Keys.LeftControl + "v");
}
private static void STAClipBoard(string myStringWithHtmlCode)
{
ClipClass clipClass = new ClipClass();
clipClass.myString = myString;
System.Threading.Thread t = new System.Threading.Thread(clipClass.CopyToClipBoard);
t.SetApartmentState(System.Threading.ApartmentState.STA);
t.Start();
t.Join();
}
}//class
public class ClipClass
{
public string myString;
public void CopyToClipBoard()
{
Clipboard.SetText(description);
}
}
}