I am trying to type into a RichText editor using CodeceptJs and Selenium but so far the only way I'm able to do this is by clicking the previous input field on the page and tabbing from it to the RichText editor and once there I then add my text simulating a keyboard interaction.However, I feel there may be a better way to do this and also to locate the editor to see if it's displayed on the screen.
I have tried grabbing both the textarea and the span tags that I see when inspecting the page, but none of them would work. I've also gone through the length of trying to use a javascript executor to remove the display none property on the hidden textarea that seems to accompany that field and I can type there but still not on the textarea inside the text editor. I've also checked to see if the editor would perhaps be inside a frame that I would need to switch to but it doesn't seem to be the case.
Any help much appreciated please.
async checkAllElementsAreDisplayed() {
await I.seeElement(this.titleInput)
await I.seeElement(this.summaryInput)
await I.executeScript(function() {
const doc = document.evaluate('//div[3]/div[1]/textarea', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
doc.style.display='inline';
doc.click()
});
await I.click(this.summaryInput)
await I.pressKey("Tab");
await I.pressKey("a");
I.fillField(this.textArea, "my text" )
await I.saveScreenshot('textarea.png', true)
await I.seeElement(this.textArea)
await I.seeElement(this.userInput)
await I.seeElement(this.secretInput)
await I.seeElement(this.saveButton)
}
PS: The RichText editor comes as a React component from import * as SimpleMDE from "easymde";
<div className="container container-narrow">
<SimpleMDE
className={""}
value={this.state.textValue}
onChange={this.handleChange}
/> </div>
Thank you very much.