Donnerstag, 24. September 2020

Test TinyMCE Editor with Protractor

If you want to test TinyMCE editors with Protractor you have to work around the problem with iframes first. To do this you have to switch to the TinyMCE iframe using switch, send keys and then switch back to the parent. The following method shows an example of what is necessary:

static async sendKeysToTinyMce(tinyMCEiFrameLocator: Locator, value: string, clearField: boolean = true) {

  browser.waitForAngularEnabled(false);
browser.switchTo().frame(element(tinyMCEiFrameLocator).getWebElement());
const body = element(by.id('tinymce'));
if (clearField) {
await body.clear();
}
await body.click();
await body.sendKeys(value);
browser.switchTo().defaultContent();
browser.waitForAngularEnabled(true);
}