TinyMCE: Capybara::ElementNotFound: Unable to find visible frame "content_ifr"

516 Views Asked by At

In a Capybara feature spec, I am attempting to do the following:

  within_frame("element_content_content_ifr") do
    # do stuff
  end

Where element_content_content_ifr is the CSS ID of my tinymce iframe.

I get the error:

Capybara::ElementNotFound:
       Unable to find visible frame "element_content_content_ifr"

I've set a pause during the test and inspected element. The iframe with the specified ID is definitely there, but Capybara can't find it. I am not having issues with Capybara finding iframes in other parts of my application, only the TinyMCE iframe.

I have also attempted sleep 5 before executing the within_frame line, but I get the same error. Is there something I'm doing wrong? Is there a proper way to do Capybara tests when TinyMCE is on the page?

Attached is a screenshot of the iframe's visibility on the page, as well as its DOM ancestors: screenshot of DOM elements

1

There are 1 best solutions below

1
Thomas Walpole On BEST ANSWER

From the HTML/CSS shown it's confusing how the iframe is shown at all since its ancestor <div role="application" ...> has visibility: "hidden" as a style and there isn't a visible override of that anywhere below. First thing would be to make sure you're running a recent version of Capybara and whatever driver you're using (I assume selenium). If you already are, or that doesn't fix the issue you can try working around it with

within_frame("element_content_content_ifr", visible: false) do

and see if that works.

Beyond that if you can figure out what CSS is making the frame actually visible while inside the hidden element, I would appreciate it if you could file an issue on the Capybara project with enough info to replicate the issue.