How to capture the screenshot of a specific element rather than entire page using Selenium Webdriver?
问题 Currently I'm trying to capture a screenshot using the Selenium WebDriver. But I can only obtain the whole page screen shot. However, what I wanted is just to capture a part of the page or perhaps just on specific element based on ID or any specific element locator. (For example, I wish to capture the picture with image id = "Butterfly") Is there any way to capture a screenshot by selected item or element? 回答1: We can get the element screenshot by cropping entire page screenshot as below: