mercredi 16 août 2017

Ruby Capybara / Poltergeist screenshot of scrolled viewport

How can I take a screenshot of a scrolled viewport in Capybara / Poltergeist?

I see that there is support for a full screenshot, or a screenshot of a specific element as the pull request shows here:

http://ift.tt/2fMZV4a

And the code shows here:

http://ift.tt/2i7WRkd

However if I have a simple test such as:

visit 'page'
save_and_open_screenshot
page.execute_script "window.scrollBy(0, 100)"
expect(page.evaluate_script("$('body').scrollTop()")).to eql(100)
save_and_open_screenshot

How would I be able to get a screenshot of the current viewport? It seems the code would always take a screenshot of the viewport at position 0.

I would like to use this to test angular interactions which scroll a page through a flow.

Thanks!

Aucun commentaire:

Enregistrer un commentaire