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.

driver.manage().window().minimize();

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.
#ThanksForReading
#HappyLearning

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

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

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
0
%d bloggers like this: