import {BaseComponent} from '../baseComponent'; import Chainable = Cypress.Chainable; export class IFrame extends BaseComponent { static defaultSelector = 'iframe'; private body: JQuery; constructor(element: Chainable, assertion?: (s: JQuery) => void) { super(element, assertion); this.get() .should(f => { const fr: HTMLFrameElement = f[0] as HTMLFrameElement; expect(fr.contentWindow.location.href).not.equals('about:blank'); expect(fr.contentWindow.document.readyState).equals('complete'); // eslint-disable-next-line @typescript-eslint/no-unused-expressions expect(fr.contentDocument.body).not.be.empty; }) .its('0.contentDocument.body').as('framebody' + this.id); } getBody(): Chainable { return cy.get('@framebody' + this.id); } enter(): void { this.get().then(f => { const fr: HTMLFrameElement = f[0] as HTMLFrameElement; cy.visit(fr.contentWindow.location.href); }); } }