Selenium 環境安裝配置
一、關于Selenium

Selenium supports automation of all the major browsers in the market through the use of WebDriver. WebDriver is an API and protocol that defines a language-neutral interface for controlling the behaviour of web browsers. Each browser is backed by a specific WebDriver implementation, called a driver. The driver is the component responsible for delegating down to the browser, and handles communication to and from Selenium and the browser.
This separation is part of a conscious effort to have browser vendors take responsibility for the implementation for their browsers. Selenium makes use of these third party drivers where possible, but also provides its own drivers maintained by the project for the cases when this is not a reality.
The Selenium framework ties all of these pieces together through a user-facing interface that enables the different browser backends to be used transparently, enabling cross-browser and cross-platform automation.
Selenium setup is quite different from the setup of other commercial tools. Before you can start writing Selenium code, you have to install the language bindings libraries for your language of choice, the browser you want to use, and the driver for that browser.
二、安裝Selenium
2.1、Install a Selenium library
使用pip進行安裝即可
https://www.selenium.dev/documentation/webdriver/getting_started/install_library/

2.2、Install browser drivers
瀏覽器的驅動程序由瀏覽器的廠商提供。
https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/
Through WebDriver, Selenium supports all major browsers on the market such as Chrome/Chromium, Firefox, Internet Explorer, Edge, and Safari. Where possible, WebDriver drives the browser using the browser’s built-in support for automation.
Since all the driver implementations except for Internet Explorer are provided by the browser vendors themselves, they are not included in the standard Selenium distribution. This section explains the basic requirements for getting started with the different browsers.
Read about more advanced options for starting a driver in our driver configuration documentation.
三、測試代碼
from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get(r'http://www.baidu.com')
time.sleep(5)
driver.quit()
浙公網安備 33010602011771號