tinymce.ts 869 B

1234567891011121314151617181920212223242526272829
  1. import { Page, expect } from "@playwright/test";
  2. export class CommonPage {
  3. readonly page: Page;
  4. constructor(page: Page) {
  5. this.page = page;
  6. }
  7. /**
  8. * Fill TinyMCE editor inside an iframe
  9. * @param iframeSelector - iframe CSS or XPath selector
  10. * @param content - text content to insert into TinyMCE
  11. */
  12. async fillInTinymce(iframeSelector: string, content: string) {
  13. await this.page.waitForSelector(iframeSelector);
  14. const iframe = this.page.frameLocator(iframeSelector);
  15. const editorBody = iframe.locator("body");
  16. await expect(editorBody).toBeVisible();
  17. await editorBody.click();
  18. await editorBody.press("Control+A"); // Select all existing content
  19. await editorBody.press("Backspace"); // Clear existing content
  20. await editorBody.pressSequentially(content);
  21. await expect(editorBody).toHaveText(content);
  22. }
  23. }