Set browser in fullscreen window in Selenium
Selenium Python - Set window in fullscreen
To set browser in a fullscreen window in Selenium Python, you can use fullscreen_window() function of the webdriver object.
Call full_screen_window()
function on the driver
object, and pass no arguments to the function.
driver.fullscreen_window()
In this tutorial, you will learn how to set the browser window in fullscreen in Selenium Python.
Example
In the following example, we initialize a Chrome webdriver, and set its window size to fullscreen.
Python Program
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service as ChromeService
import time
# Setup chrome driver
service = ChromeService(executable_path=ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)
# Set window to full screen
driver.fullscreen_window()
# Setting a delay so that we can see the browser window
time.sleep(5)
# Close the driver
driver.quit()
Browser window screenshot
Summary
In this Python Selenium tutorial, we learned how to set the browser to a fullscreen window, using fullscreen_window() function.