Invoke Chrome browser using Selenium 4 and Python

Versions used while doing this blog post, (These are the prerequisites to automate chrome browser. Browser and driver versions should match)
selenium python version – 4.5.0
chrome browser version – 105
chrome driver version – 105 (Download link : https://chromedriver.chromium.org/downloads) [download this to a path in project directory]

1. Instantiate (creation of object) driver object with webdriver.Chrome() (This step opens the chrome browser)

driver = webdriver.Chrome("chromedriver path need to be passed")

2. Now, next steps of maximizing the browser, setting implicit timeout for driver object and launch of expected website can be carried out

driver.implicitly_wait(10)
driver.maximize_window()
driver.get("https://www.google.com")

3. Quit/close the driver object after automating the necessary flows within the website.

driver.quit()

Sample code for reference

from selenium import webdriver

driver = webdriver.Chrome("chromedriver path has to be passed")
driver.implicitly_wait(10)
driver.maximize_window()
driver.get("https://www.google.com")

driver.quit()

Leave a Reply

Your email address will not be published. Required fields are marked *