The timeout reported in the previous comment is explained: on stable-17.10.x and stable-18.4.x, ImagePopover#waitUntilReady() only waited for the popover to be visible. When the button went stale because the popover was hidden (lightbox.js hides it after a mouseleave), nothing showed it again, since only a mousemove over the image does and the pointer doesn't move. master already re-hovers the image in waitUntilReady() (XWIKI-24532), which was never backported.