2

I'm getting an issue when try to automated user type on Redactor text editor.

Here's the details:

  • Used command click or clickAt on Redactor text editor
  • Used Locator with ID, Name, or Class.
  • Used command type and input the text
  • Used command click on Save button

All of the test case was PASSED, but no text typed/appear on Redactor text editor after click on Save button, why is that?

1
  • It seems somehow the text was sent to the wrong element and/or some internal Javascript event was not triggered. I had no problem automating/testing Redactor with Kantu, but this one uses images as locator.
    – Bobby231
    Jan 27, 2017 at 7:14

1 Answer 1

1

Definitely solvable

Problem: redactor editors usually work different way. You can use type or sendKeys IDE commands just for inputbox, which will inject the value of the inputbox.

Often text editors have generated id, which differs each time you reload the page

Solution: text editors usually define an element with an unique id, which contains subsequent/child HTML tags as content of the edited text. What you can do is to inject the value to this element by javaScript in storeEval.

IDE code example: you will have to localise and replace the Xpath of the idOfTextArea stored variable

<tr>
    <td>store</td>
    <td><p>Some text<br></p></td>
    <td>inputText</td>
</tr>
<tr>
    <td>storeAttribute</td>
    <td>//div[contains(@id,'taTextElement')]@id</td>
    <td>idOfTextArea</td>
</tr>
<tr>
    <td>storeEval</td>
    <td>this.browserbot.getCurrentWindow().document.getElementById(storedVars['idOfTextArea']).innerHTML = storedVars['inputText']; </td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>this.browserbot.getCurrentWindow().document.getElementById(storedVars['idOfTextArea']).innerHTML</td>
    <td>resulttext</td>
</tr>

Explanation:

  • By the storeAttribute | //div[contains(@id,'taTextElement')]@id you get the id of the editor window if it changes each time when you reload the page. If id of editor window is a constant, you can skip this point or replace it by store | some ConstantId
  • By the this.browserbot.getCurrentWindow() you get current HTML document
  • By the getElementById(storedVars['idOfTextArea']) you get the object of the editor Window. If the id of editor window element is a constant you can replace it instead storedVars[...] as well
  • By the .innerHTML you get or change all HTML content in the editor window
  • stored variable resulttext will contain the text if everything is ok, so you can validate the results if something went wrong by comparing both inputtext and resulttext

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.