Foreword
Selenium is an open source framework for automated testing of UI Web page, the browser can drive to simulate user actions. Support multiple platforms (Windows, Mac OS, Linux) and various browsers (IE, Firefox, Chrome, Safari ), you can write tests in multiple languages (Java, Ruby, Python, Perl , PHP, C #).
selenium + python environment to build
python installation environment
install python environment on mac can refer to: Mac version -python environment configuration (a): Python download and install
Installation selenium
Open Terminal -> pip installation (command: pip3 install selenium)
Install the browser driver
Install Chrome browser driver ChromeDriver
1. Check the version of Chrome
Settings -> About Chrome
2. Find the correspondence between Chrome and ChromeDriver
Chrome and ChromeDriver correspondence relationship can reference: https://www.cnblogs.com/mini-monkey/p/12088721.html
3. Download the corresponding ChromeDriver
ChromeDriver Download: http://chromedriver.storage.googleapis.com/index.html
1 small series in view of chrome version 79, so download ChromeDriver 79 version
4. ChromeDriver environment configuration
Enter / usr / local / bin directory (the directory is hidden due to the Mac, it can be through the shortcut command + shift + g Open)
The decompression ChromeDriver drag to the bin folder
查看ChromeDriver版本:chromedriver --version
备注:输出ChromeDriver版本即安装成功
5. 编写脚本启动Chrome浏览器
1 # 启动Chrome 2 from selenium import webdriver 3 4 driver = webdriver.Chrome() 5 driver.get('http://www.baidu.com/') # 打开百度
运行脚本,打开百度页