How to get and set the value of the text editor in selenium

advertisements

I have text Editor on a web page, i need to fill its value using selenium scripting in c#. I know how to do it for textbox. i have checked the process from Set value in textbox but when i have tried the same process for text editor, it is not working, i want to get and set the value of editor. please help me how can i do this.

code for getting text of textbox is :

IWebDriver firefoxDriver = new FirefoxDriver();
IWebElement passwordTextBox = Driver.FindElement(By.Id("passwordTextBox"));
passwordTextBox.Clear();
passwordTextBox.SendKeys("password");

I have tried the below code to set value of editor

IWebElement detailFrame = driver.FindElement(By.CssSelector("#cke_1_contents .cke_wysiwyg_frame"));
driver.SwitchTo().Frame(detailFrame);
Thread.Sleep(1000);
var body = driver.FindElement(By.TagName("body")); // then you find the body
Thread.Sleep(1000);
body.SendKeys("<span>hiiiiiiii<span>");


IWebDriver firefoxDriver = new FirefoxDriver();
IWebElement passwordTextBox = Driver.FindElement(By.Id("passwordTextBox"));
passwordTextBox.Clear();
passwordTextBox.SendKeys("password");

In above code change 2nd line to

IWebElement passwordTextBox = firefoxDriver.FindElement(By.Id("passwordTextBox"));

Also check id of element you are searching By.Id("passwordTextBox") is correct other wise use xpath/css