Maximization of a web browser through the Web Driver (Python selenium) is very easy. In short, all you have you have to do is start the browser and call the maximize_window().

(Selenium is a Python module that uses a web driver to control a web browser for you)

Related course:

selenium

selenium maximize

Before you start, make sure you have the right Web Driver installed for your Web Browser. For Firefox that’s GeckoDriver, For Chrome that’s ChromeDriver and so on.

Besides installing the Web Driver, you need to install the Python selenium module. The selenium module can be installed using the operating systems package manager or pip.

The example below opens the web browser and maximizes it. This is done in a few steps.

1
2
3
4
5
6
7
8
from selenium import webdriver 
import time

driver = webdriver.Firefox()
driver.maximize_window()
time.sleep(5)

driver.get("https://www.python.org")

selenium maximize

First import webdriver and the time module. These are required for interacting with the Web Driver.

1
2
from selenium import webdriver 
import time

Then open your web browser, for instance, firefox with webdriver.Firefox() and maximize the window with the call maximize_window().

1
2
3
driver = webdriver.Firefox()
driver.maximize_window()
time.sleep(5)

If you are new to selenium, then I highly recommend this book.

Download examples