Maximising the browser. I think this is the most basic step and one of the most included step in test automation using Selenium. This is one of the fundamental steps that I think each and every test automation script/framework out there would contain.
By default when you open a Selenium script, a simple one such as getting the webpage, it opens in a certain default resolution. In most cases it is 800x600
resolution. But I think so 99.9% of times, we do not want this resolution, since most systems – desktop or laptops, do not have this resolution. Today in the times of 4k
and 8k
videos, this resolution hardly seems to satisfy our needs.
So what do we do? Maximise the browser to certain resolution or to a maximum screen resolution. Almost all of us who are versed with Selenium know how to do it using the maximise()
method. But the beauty of Selenium is that it offers us multiple ways of doing something. So let’s see in how many different ways can we maximise the browser or change the resolution of the browser.
For the sake of simplicity, I’m considering Chrome browser for this and I’ve choosen Selenium Python bindings for this since I love to play around with Python.
- Using the default
maximise()
method
This is the first method that comes to mind – tried and tested. This is the de-facto standard method to open the browser in the maximum screen resolution using Selenium.
- Using a pre-defined screen co-ordinates
Second method is the one where we can use a specific co-ordinate combination of x and y coordinates to set the size of the browser using the set_window_size()
method. For eg, we can pass coordinates like 1400×900 in the method to open it to that resolution
- Using the Chrome options
--start-maximized
The ChromeOptions
class gives us a lot of useful flags that we can use to alter/change the behaviour of the Chrome browser in Selenium. You can find the complete list of Chrome Options here.
- Using the Chrome options
--kiosk
Similar to the --start-maximized
flag, there is another flag called the --kiosk
mode, that opens the browser in maximized mode in Chrome. However, unlike the former, the latter opens the browser in full screen mode, which you can see after running this code piece below

The above pic is the one with --start-maximized
, while the below is with --kiosk

- Using the javascript method to get the screen coordinates and then open browser to that resolution.
This is similar to the second approach that we discussed. But here instead of hard-coding the resolution, we use the js
method to return the available width and height of the screen and then use the set_window_size()
method to open the browser to that resolution.
- Using the
--start-fullscreen
flag in ChromeOptions
Similar to the --kisok
mode, we can also use the --start-fullscreen
flag in the ChromeOptions
class to open a browser in a complete full screen. Here the url bar would not be visible.. the screen almost appears same as the one in the --kiosk
mode.
So as you can see there are more than 1 approach to maximising the browser or changing the resolution of the browser to a desired resolution. However almost all of these are tried and tested on Chrome only. I’ve not included Firefox or Edge ( most would work on Edge since it already has a Chromium core).
If someone knows about the ways we can do these in Firefox, please feel free to message me, comment on the blog or post on my LinkedIn.
I maintain this github repo, where I have added Python code for some no-so-commonly asked Selenium questions. Feel free to go through them.