OnetapInc / chromy

Chromy is a library for operating headless chrome. 🍺🍺🍺
MIT License
605 stars 41 forks source link

Can not hover an element that is outside viewport #58

Open garris opened 6 years ago

garris commented 6 years ago

@dotneet I think this may be a somewhat challenging issue.

I have a document with a height of 1000px and a viewport (window) with a height of only 800px, if I attempt to hover an item which starts at 900px (using mouseMoved()) the hover fails. This makes sense since in normal chrome it is impossible for a user to move the cursor beyond the window bounds. However, it causes confusion when taking screenshots in the document (whole page) context. This is especially true when using backstop because this was not a limitation of phantom.

I am wondering, would it be possible to maintain the user's intended cursor position (probably by simply aggregating arguments to all mouseMoved() calls) prior to switching to document context. If so, would it also be possible to set the user's intended cursor position prior to taking screenshots?

This is a pretty big issue for backstop usecases. What do you think?

dotneet commented 6 years ago

@garris Always enabling viewport emulation that is used in .screenshotDocument() will possibly be solution. I'm not sure if it has possibility to cause another problem. At least result of both .screenshot() and .scrollTo() will be changed. (this is allowable in backstopjs?)

Anyway I'll confirm whether this idea is possible and or find out another approach.

garris commented 6 years ago

Thanks for the reply, just to be clear -- the issue is happening with the screenshotMultipleSelectors() use-case.

I like your first idea. Perhaps adding a method to force the necessary emulation (before making any mouseMoved() calls) would ensure there would be no regressions for established chromy cases? It may require some backstop refactoring for .screenshot() use-cases.

I still wonder if it is possible to simply add an extra mouseMoved() if called during chromy chain execution -- could be done just after you switch to alternate viewport (but before you take screenshot). I think this may impose the least amount of change -- but also I don't know if this is possible. ¯_(ツ)_/¯