Last active
March 10, 2016 19:18
-
-
Save unixmonkey/60abcf1574387535fac5 to your computer and use it in GitHub Desktop.
Capybara helper to resize browser for an action, then put it back.
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
# Wrap some code with this block to change the browser window size | |
# When the block exits, it will resize to its original dimensions | |
# with_browser_size(1024, 768) { find('.hidden-sm').click } | |
def with_browser_size(width, height, &block) | |
window = Capybara.current_session.driver.browser.manage.window | |
before_size = window.size | |
window.resize_to(width, height) | |
yield | |
window.resize_to(before_size[:width], before_size[:height]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment