Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Web fonts can cause the page to move and clicks to fall in the wrong place #787

Open
jonleighton opened this issue Jun 24, 2016 · 1 comment

Comments

@jonleighton
Copy link
Contributor

I've been debugging some sporadic spec failures today, where it seems that Poltergeist tries to click the wrong place in the page. Therefore it misses the button I'm trying to click, and my spec fails because the form is never submitted.

We use web fonts in our project. In this case, it seems that what is happening is that since I'm clicking a button very soon after the page has loaded, sometimes Poltergeist computes the click position before the web fonts have loaded but the click itself happens after the web fonts have loaded. And the web fonts cause the page to re-render, so everything moves around a bit. This can cause the click to fall in the wrong place.

More generally, it seems problematic that the page can change between when Poltergeist measures the click position and when it executes the click. Ideally there would be some way to freeze the page, but I don't know if that is at all possible.

For now, I have managed to work around the issue by checking for document.readyState == "complete" on each page load. This may be the next best thing for Poltergeist to implement if freezing the page is infeasible.

@twalpole
Copy link
Contributor

twalpole commented Jun 24, 2016

Unfortunately the way phantomjs works there is no way to freeze the page (it's the same issue that can happen with animated items on the page). Poltergeist calculates the position and then issues the click event at the right position at that moment in time. Unfortunately that event gets added to a queue, in which anything else can happen first, but poltergeist has no access to know what else is happening.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants