How do I run Chrome with Selenium WebDriver in Python?

How do I run Chrome with Selenium WebDriver in Python?

QA 0

To launch Chrome with Selenium WebDriver, ensure that the path to your ChromeDriver binary download is listed in the Windows PATH environment variable. Alternatively, you can specify the path to ChromeDriver directly during runtime per the example below:

Python Code:

import win32com.client
x = win32com.client.Dispatch("AppRobotic.API")
import os
from selenium import webdriver

# assign ChromeDriver path to variable
chrome = "/Users/Administrator/Downloads/chromedriver"
os.environ["webdriver.chrome.driver"] = chrome
# navigate to Google
driver = webdriver.Chrome(chrome)
driver.get("http://www.google.com")
# wait 5 seconds
x.Wait(5000)
# close Chrome browser
driver.quit()