Denis Koreyba
Denis Koreyba

Reputation: 3718

Take a screenshot of a full browser window with Selenium WebDriver

There is a possibility to take a screenshot using Selenium Webdriver.

It takes screenshot of the whole area of a web page but the browser window (boarder) is not included in this screenshot.

Is there a way to take screenshot with Selenium Webdriver so the whole browser window is captured?

I want to see all the status bars, tabs and buttons.

It's possible to do with .NET but then there is a chance that it will screen something else (if for example browser was minimized) so I'd like to do it with selenium.

Upvotes: 1

Views: 4516

Answers (2)

Sarabjit Singh
Sarabjit Singh

Reputation: 790

It is not possible with Selenium Webdriver, to get the screenshot of whole web browser window. However you can still make it work by using Ashot

The article how can we do that can be checked here

Hope this helps :).

Upvotes: 1

Andrew Regan
Andrew Regan

Reputation: 5113

No, this isn't possible using WebDriver:

WebDriver provides the Take Screenshot command to capture the top-level browsing context’s initial viewport, and a command Take Element Screenshot for doing the same with the visible region of an element’s bounding rectangle after it has been scrolled into view.

I don't know how vital this is to you, but you could potentially configure your browser to open at a fixed location, with a fixed size (via WebDriver), take a full-screen screenshot (Java code; alternatively automate the "Print Screen" button), and use what you know about the window bounds to crop the full-screen image down to include just the window.

It might not be perfect if you have to support multiple operating systems and browsers, but you could tweak it to be quite accurate.

Upvotes: 2

Related Questions