Make Selenium Easy

Now You Can Minimize Browser in Selenium WebDriver

Till Selenium 3, we were only able to maximize the window. We were not able to minimize directly. There were ways to do like setPosition() but it was of no use if you can not maximize whenever you want.

Selenium 4 gives you a brand new method named “minimize()” which can be used to minimize the browser just like a user normally do. “minimize” method is in inner interface “Window” of WebDriver interface.

Return type of minimize() method is void and official doc says it ” Minimizes the current window if it is not already minimized “.

Syntax :-

Same as maximize. Just use minimize in stead of miximize.


Remember to use this method you need to have Selenium 4.0.0-alpha-5 in build path as it is launched in that particular version onward.

It takes screenshot also without any problem.

Sample Program :-

You will see browser will be minimized and execution will be finished silently and you can do you other works. You can see taken screenshots in resource. Cool feature. Thanks developers of Selenium WebDriver.

You can find my Selenium WebDriver Java GIT repo here.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.

You can find all Selenium related post here.
You can find all API manual and automation related posts here.
You can find frequently asked Java Programs here.

Table of Contents

Author: Amod Mahajan

A software Tester who is paid to judge products developed by others. Currently getting paid in American Dollars. Writing technical posts and creating YouTube videos are my hobbies.

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.

Now You Can Minimize Browser in Selenium WebDriver

by Amod Mahajan time to read: 2 min
%d bloggers like this: