Created
June 20, 2024 02:23
-
-
Save ryochin/f14dad6f413d5a16e59a10a9bd6904a2 to your computer and use it in GitHub Desktop.
Rails: Rspec: save full screenshot on feature tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def save_full_screenshot(page, path) | |
width = page.execute_script('return Math.max(document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth);') | |
height = page.execute_script('return Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);') | |
window = page.driver.browser.manage.window | |
window.resize_to width + 100, height + 100 | |
page.save_screenshot path | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment