Kevin Marsh is a web developer from Toledo, OH with a focus on simplicity and usability, an eye for design, and insatiable curiosity.
The latest builds of iTerm2 support an API for displaying images in the terminal. It can display any Base64-encoded PNG or JPEG image inline or as a download. Guess what, Poltergeist can render the current page as a… Base64-encoded PNG or JPEG! Let’s combine the two with this little snippet of Ruby in our spec_helper.rb
file:
def show_screenshot(width = 640)
print "\033]1337;File=;inline=1;width=#{width}px:"
print page.driver.render_base64
print "\a\n"
end
Combine this with a call to Pry’s binding.pry
and now you can interact with your page and see the results of your capybara commands. Kind of like a web browser, but in your terminal!