Looks like you are trying send keys to CKEditor.
Please read through this article: Test WYSIWYG editors using Selenium WebDriver
This approach is the one you have tried and didn't work. It's known to have issues with Firefox. Your code should work for PhantomJS or Chrome. Note that <span>hiiiiiiii<span>
will result in actual text in the editor, not a span element.
IWebElement detailFrame = driver.FindElement(By.CssSelector("#cke_1_contents .cke_wysiwyg_frame"));
driver.SwitchTo().Frame(detailFrame);
var body = driver.FindElement(By.TagName("body")); // then you find the body
var executor = driver as IJavaScriptExecutor;
executor.ExecuteScript("arguments[0].innerHTML = '<span>hiiiiiiii<span>'", body);
- Use CKEditor's native API
var executor = driver as IJavaScriptExecutor;
executor.ExecuteScript("CKEDITOR.instances.ckeditor.setData('<span>hiiiiiiii<span>");