Thinking within()
Portals
#9288
Unanswered
eastside
asked this question in
Questions and Help
Replies: 1 comment
-
Okay, I think I've discovered one workaround to let you "break" out of a within statement. I can alias body outside of the within statement, and then inside a within statement, select my portal as within the aliased body selector.
It seems to work okay! Things I tried that did not work: using cy.window(). cy.root(), and the "withinSubject" option on cy.get(). I probably should have been able to figure out quickly that none of these were going to work, but still, it took time to cross them out, and they were red herrings for me. Maybe it's worth nothing the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have a lot of popovers in our app, mostly from Blueprints.js. There are tons of nested menus, popovers, tooltips, fancy select elements, things like that.
Everything is properly nested in React components, children within parents, as it should be. But the library makes heavy use of React Portals, meaning many of these elements are rendered in HTML outside the DOM tree, as children of
<body>
.This makes coding tests in Cypress a real pain. It seems like the
within
statement is just entirely off limits. It would be totally natural for us to use it, but because it can't select "child" Portal elements, it means we have to code without it. Which just, sucks. Unless there's something I'm missing? Is there some strategy for making use of within statements and "breaking out" of the DOM to look at nodes in Portals?Beta Was this translation helpful? Give feedback.
All reactions