@troccoli You're not actively hiding the element, right? You just expect when it is scrolled past that element/is above the viewport that it is no longer visible because it is out of view? Unless you're actively hiding the element this doesn't feel like something that has value in testing tbh. It is implicit that if you scroll something out of view that you can't see it. E2E tests are built to test actions/responses. Though you could probably put some fancy javascript in there that tacks a data attribute to the logo when it is out of the view port. Doing that would allow you to use assertDataAttribute on the element when it is out of view. That said, seems like a lot of work for not much value. Maybe I am misunderstanding the goal of this.
Feb 19, 2022
5
Level 6
Asserting an element is, or is not, in the viewport with Laravel Dusk
I am pretty sure I have read somewhere that Dusk's methods assertVisible and assertMissing work on the viewport, but apparently they don't.
I have created a sample repo. I have added quite a few blocks of text on the homepage just to make sure the logo disappears when scrolling to the bottom of the page.
https://github.com/troccoli/dusk-assert-missing-issue
This is confirmed by the two screenshots I take during the test, but the test still fails.
Does anyone have an idea how I can test whether an element is visible in the viewport?
Please or to participate in this conversation.