Issue:
In my JavaScript code, I have a CKEditor instance like this:
var editor = CKEDITOR.instances["id_corpo"];
I am looking to programmatically insert some text and then select a specific text range within the editor.
So far, I have successfully inserted text using:
editor.insertHtml('<h1 id="myheader">This is a foobar header</h1>');
However, my goal is to highlight the word "foobar" using JavaScript so that I can run functional tests with Selenium on my CKEditor plugins.
UPDATE 1:
I attempted the following approach:
var selection = editor.getSelection();
var childs = editor.document.getElementsByTag("p");
selection.selectElement(childs);
Unfortunately, this method did not work as expected!
Is there another way to achieve this?
I believe that utilizing
selection.selectRange()
could potentially solve the issue. However, the lack of examples has made it difficult for me to implement it correctly.