How to maximize and minimize browsers in Selenium with python?

Selenium Web DriverAutomation TestingSoftware Testing

We can maximize and minimize the browser while we are testing an application in Selenium.

For maximizing the browser, maximize() method is to be used.

For minimizing the browser, minimize() method is to be used.

Both these methods can be used simultaneously in the same program.

Example

Code Implementation

from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then #invoke actual browser
driver = webdriver.Firefox(executable_path="C:\\geckodriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/index.htm")
#to refresh the browser
driver.refresh()
# to minimize the browser window
driver.minimize_window()
#to close the browser
driver.close()
raja
Published on 29-Jul-2020 10:27:53
Advertisements