How to open a browser window, maximize it and open a website using selenium

How to open a browser window, maximize it and open a website using selenium?

We will be using Google Chrome for our example below.

First we need to import the webdriver from selenium using the code:

from selenium import webdriver

You can create an instance of your web browser and using the instance we will be performing the actions related to the browser window.

You can give any name to the browser instance. In the below example, myBrowser is the browser instance.

myBrowser = webdriver.Chrome()

Using the myBrowser instance, we will open a new chrome window and open a website.

myBrowser.get("https://www.fundaofwebit.com/")

The browser window will never open in a fully maximized state. To maximize the window, we use the maximize_window() function as shown below.

myBrowser.maximize_window()

Overall our code will look like : 

from selenium import webdriver

myBrowser = webdriver.Chrome()

myBrowser.get("https://www.fundaofwebit.com/")
myBrowser.maximize_window()


© Copyright - 2018 - 2022 | All rights reserved at Funda of Web IT