cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.

Home Page:https://cypress.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error "TypeError: Cannot read property 'body' of null" when trying to use cy.type() in an iframe

codybarr opened this issue · comments

Current behavior:

I'm trying to type into a froala editor that uses an iframe to receive input and render rich text. The code below runs successfully in Cypress 3.4.1 but in 3.8.1 it throws an error:

cy.get('section.modal iframe.fr-iframe').then(function($iframe) {
    const $body = $iframe.contents().find('body')
    cy.wrap($body)
        .find('p')
        .type(MESSAGE)
})

image

Desired behavior:

After reverting Cypress to 3.4.1 the iframe .type() code runs successfully

Test code to reproduce

https://github.com/codybarr/cypress-bug-6142

Note: In creating this I discovered that if I first .clear() the editor I'm then able to .type() into it. So I have something of a workaround but still think this behavior is strange.

Also Note: In the test code repo above I'm using TinyMCE but the behavior is the same as Froala.

Versions

Cypress: 3.8.1
OS: MacOS 10.14.6 (Mojave)
Browser: Chrome 79 / Electron 78

Closing as duplicate of #5930