How best to use `drag_to` when an element is not visible until the `dragstart` event?

12 views
Skip to first unread message

Drew

unread,
Dec 12, 2022, 9:01:49 AM12/12/22
to Capybara
I have a requirement that when dragging certain elements, a mask will appear over the top of a section of the screen, which is a valid drop target. However, it is not visible until you start dragging, so when I tried `page.find("#reset_drop_mask")` it failed since it could not find the element in question.

I have worked around this, temporarily, by forcing the mask visible even though the drag has not started, in order to test that once you drag it onto the mask, it does the job correctly. I've also tested correctly that the mask is *not* visible before I would have forced it.

So the only real requirement that I cannot test is that the mask *becomes* visible once the drag starts. What would be the best way to do this?

Drew

unread,
Dec 12, 2022, 9:10:20 AM12/12/22
to Capybara
Well, okay, I found I could do `page.find('#reset_drop_mask', visible: false)` to be able to find the element for the `drag_to` command. However, it works even if the element *does not* become visible, so I'm still not sure how to test that the mask *becomes* visible once the drag starts.
Reply all
Reply to author
Forward
0 new messages