Take screenshot

Splinter can take current view screenshot easily:

browser = Browser()
screenshot_path = browser.screenshot('absolute_path/your_screenshot.png')

You should use the absolute path to save screenshot, if not screenshot will save in a temporary file.

Take a full view screenshot:

browser = Browser()
screenshot_path = browser.screenshot('absolute_path/your_screenshot.png', full=True)

Take element screenshot

First, if you want to use this function, you should install the Pillow dependency:

pip install Pillow

If the element in current view:

browser = Browser()
browser.visit('http://example.com')
screenshot_path = browser.find_by_xpath('xpath_rule').first.screenshot('absolute_path/your_screenshot.png')

If the element not in current view, you should do it like this:

browser = Browser()
browser.visit('http://example.com')
screenshot_path = browser.find_by_xpath('xpath_rule').first.screenshot('absolute_path/your_screenshot.png', full=True)