Launch Chrome Browser in Selenium Python

Profile picture for user arilio666

This bundle grants us access to a variety of classes. Using the web driver package, we can launch any browser. The Selenium.webdriver package must then be imported. Then we'll be exposed to all of the browsers in that package.

To invoke the Chrome browser, we must first select the Chrome class. Then build the class's driver object. This is the most critical and required stage in the browser invocation process.

Each Chrome browser includes an executable file. We must use Selenium to call this executable file, which is in charge of launching the Chrome browser.

The path to chromedriver.exe must be added to the executable file. Then we must obtain the Chrome driver version corresponding to our browser version. Then we must utilize the get () method to run our application in that browser.

from selenium import webdriver
driver = webdriver.Chrome(executable_path="D:drivers\chromedriver.exe")
  • After importing Webdriver, we can point out the path of the chromedriver.exe file we downloaded.
  • This will invoke the Chrome browser to open.
  • Note that this will always require us to check the up-to-date version of the browser we are using.

WebDriver Manager:

pip install webdriver-manager
  • Download the following library.
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.maximize_window()
driver.get('https://www.programsbuzz.com')
  • Hereafter importing web driver-manager, invoke Chrome with it and Chrome driver manager.
  • Then initialize the driver, assign the web driver with Chrome, and install it.
  • This will download the latest Chrome version according to our browser and then launch every time without manually doing this.