Skip to content
Advertisement

How to take partial screenshot with Selenium WebDriver in python?

I have searched a lot for this but couldn’t find a solution. Here’s a similar question with a possible solution in java.

Is there a similar solution in Python?

Advertisement

Answer

Other than Selenium, this example also requires the PIL Imaging library. 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

JavaScript

and finally the output is… the Stackoverflow logo!!!

enter image description here

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.

Advertisement