-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checkbox sometimes not checked after check …
#34
Comments
From the description it sounds like your page is dynamically modifying/adding behavior to the checkbox (possibly react/angular?). If the behavior hasn't fully been added before you tell Capybara to check the box then the box may get reset by the JS and/or the expected behavior may not trigger. It sounds like you need to have an expectation for whatever visible change on your page would indicate the page is actually ready for use before calling Additionally the fact the screenshot is white could imply you've set |
@twalpole Thank you again! The page is just server-rendered with very light JS to add/remove CSS classes. Those CSS classes don't style the checkbox other than changing the opacity of its container. And I still get the issue if I stop doing those styling changes. We do have Wonder if it could be a timing issue where content loads/shifts so the |
I tried setting Just in case it has any bearing on things, I noticed that even when the test passes, the screenshot has the top part of the page occluded by a box with the same colour as the body background. I made the background red just to make sure it was the body bg. This image shows the HTML page on left and the screenshot on right: |
Having |
Thank you again! I was thinking elements moving not so much from animations, as web fonts or images loading and shifting the page. We don't have an overlay that I'm aware of, and the weird thing is that this is the body background colour. Changing the body bg colour (e.g. to red above) changes the colour of the "overlay". So it doesn't seem to actually be an overlay but more that the top part of the page is somehow unrendered and the bg colour shows through. |
@henrik Or you do have an overlay that is dynamically using the background color (or are animating the form into place)?? It's really not possible that the browser is drawing the page from the bottom up and hasn't rendered the top yet, so for that image to exist you have an overlay /animation happening (99% sure). |
@twalpole Hm, that's an idea. If I find the time I'll grep around and/or try removing code to see if it is some kind of overlay/animation after all. Thank you! Really appreciate you taking the time. |
I've been running into a similar issue with an image-heavy page, where The I've eventually worked around this by adding a method to wait for the document to be complete. This is essentially a more sophisticated version of the
Calling this immediately before the first |
I realise this may be hard to do anything about without a repro, but I thought I'd mention it on the off-chance that the maintainer(s) can think of an explanation, or at least in case anyone else runs into it in the future.
This happens on a fairly complex page in our app, and I can't currrently take the time to try to make a minimal repro, but the nut of it is that if I do
Then sometimes the expectation fails.
When it fails, screenshots are completely white. When it passes, I can see the checked checkbox in the screenshot.
Adding a
sleep 0.1
before checking the box seems to consistently fix it. Adding asleep 0.01
fixes it some of the time. With no sleep, it fails almost every time. So clearly there's a timing thing going on.The preceding code in the test changes two other forms on the same page and submits them with Ajax. The page is not rewritten much by those submissions – it only toggles some classes on those other forms. If I remove either one (or both) of the two Ajax submissions, it starts passing without the
sleep
.Happy to screen share with a maintainer, but again, afraid I won't be able to take the time to make a distributable or minimal repro out of this :/
The text was updated successfully, but these errors were encountered: