Geckodriver – Selenium screenshots issue

Have you noticed a strange issue with Selenium when trying to get an element screenshot in Firefox? Once you try to take a screenshot of a particular element on the page, there is a viewport screenshot taken instead.

No matter what kind of element you try to use, on each call to the screenshot function there is a current viewport saved.

This issue is caused by the geckodriver version 0.23.0 and older.

The solution

The solution to this issue is really simple: upgrade your geckodriver. Please note that there can be multiple places on your computer where the geckodriver is stored. You should adjust all of them to make sure that the issue is gone. The driver version 0.24.0 is fixing this issue and also adds an endpoint to take a full-page screenshot.

As you may notice from my other posts, I prefer to use geckodriver and Firefox when working with Selenium – due to the fact that I don’t have to upgrade the driver all that often as it is with Chrome driver. On the other hand, in situations like this, it is a drawback.

Leave a Reply

Your email address will not be published. Required fields are marked *