Versions used while doing this blog post, (These are the prerequisites to automate chrome browser. Browser and driver versions should match)
selenium-python version – 3.141
chrome browser version – 86.0.4240
chrome driver version – 86
Chrome browser can be opened using selenium by following below steps:
1. Download and place the downloaded chromedriver file to usr local directory of the system (for Mac. Path setting should be done for Windows in environmental variables)
2. Instantiate (creation of object) driver object with ChromeDriver() class (This step opens the chrome browser)
driver = webdriver.Chrome()
3. 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("http://www.google.com")
4. 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()
driver.implicitly_wait(10)
driver.maximize_window()
driver.get("http://www.google.com")
driver.find_element_by_name("q").send_keys("Test")
driver.quit()