
If you want to change these default settings, you can opt for JPEG file format and/or load the screenshot in a new tab. Extension Optionsīy default, this extension saves the taken screenshot and the file format is PNG. The Screenshot extension also offers a keyboard shortcut command Alt + P which makes it easier and quicker to take screenshots. Once installed, you can take screenshots of your current tab by using extension’s button on the toolbar.


It should also work with other Chromium-based browsers like Microsoft Edge, Brave, Opera etc. It works with Chrome on Windows, macOS, Linux, and Chrome OS (Chromebooks). It captures only the visible area of current tab. But, if you are still looking for a quicker and simpler solution for taking screenshots of visible area of any webpage, Install our Screenshot extension from this link. There are many popular and powerful Chrome extensions as well, which enable users to take full-page screenshots and edit or annotate right in the browser. Print timeit.Timer('browser.get_screenshot_as_file(file_name) pil_img = Image.open(file_name)', setup=setup).We already have tons of tools for taking screenshots across platforms. Print timeit.Timer('Image.open(StringIO(codestring(browser.get_screenshot_as_base64())))', setup=setup).repeat(2, 10) Print timeit.Timer('Image.open(StringIO(browser.get_screenshot_as_png()))', setup=setup).repeat(2, 10) Img 2 = Image.open(StringIO(browser.get_screenshot_as_png()))Īnd because I'm sure your next question is, "Well that's great but which one is fastest?", here's how to determine it (I find the first method to be the fastest by some distance): import timeit Img 1 = Image.open(StringIO(codestring(browser.get_screenshot_as_base64()))) Now of course this would be overkill for just grabbing a static image but if your want to grab something that requires Javascript to get to this could be a viable solution.Įxpanding on the comments in response to RandomPhobia's very nice answer, here are two solutions with correct import statements that will open a full-screen screenshot without first saving to a file: from selenium import webdriver Im.save('screenshot.png') # saves new cropped imageĪnd finally the output is.

Im = im.crop((left, top, right, bottom)) # defines crop points Im = Image.open(BytesIO(png)) # uses PIL library to open image in memory Png = fox.get_screenshot_as_png() # saves screenshot of entire page # now that we have the preliminary stuff out of the way time to get that image :DĮlement = fox.find_element_by_id('hlogo') # find part of the page you want image of Sometimes this is put in as one of the standard libraries and sometimes it's not, but if you don't have it you can install it with pip install Pillow from selenium import webdriver Other than Selenium, this example also requires the PIL Imaging library.
