1

I am working to write some Selenium WebDriver scripts that work with Telerik RadEditor controls. I can successfully enter content into the RadEditor in the following way with C#:

Driver.FindElement(By.Id("Id_Of_RadEditor_Iframe")).SendKeys("Hello World!");

But I have not been able to find a way to clear the existing content of the RadEditor. If I attempt the following:

Driver.FindElement(By.Id("Id_Of_RadEditor_Iframe")).Clear();

I will get this error:

OpenQA.Selenium.InvalidElementStateException: invalid element state:
Element must be user-editable in order to clear it.

Does anyone know a way to clear the existing content from the RadEditor?

P.S. Does anyone think this may be a bug in Selenium WebDriver? Since I know the IFrame is editable since I can successfully perform SendKeys(). This seems to make the error incorrect.

Kerry

1

2 Answers 2

1

I have the same issue and have yet to find an answer.

As a workaround you can use a loop and:

searchBox.sendKeys(Keys.BACK_SPACE);
1
  • Thanks for the response. Sad that we have to resort to these kind of hacks, but sometimes you have to do what you have to do.
    – Codegenic
    Feb 11, 2015 at 16:05
0

I finally got back around to looking at this issue again as I had more of a need to make this happen. Here is the "work around" I implemented and works for me:

var targetElement = Driver.FindElement(By.Id("Id_Of_RadEditor_Iframe"));
int length = targetElement.Text.Length;

for (var i = 0; i < length; i++)
{
    targetElement.SendKeys(Keys.Delete);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.