1.安装JVM
环境变量配置:
%JAVA_HOME%\jre\bin
%MAVEN_HOME%\bin
2.安装Python
http://python.org/downloads/。
下载Python 3
设置环境变量
C:\Users\Administrator\AppData\Local\Programs\Python\Python38
C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts
2.执行命令pip install selenium
3.验证是否安装成功:pip show selenium
4.安装谷歌对应的驱动
http://chromedriver.storage.googleapis.com/index.html
5.设置环境变量
C:\Users\Administrator\AppData\Local\Google\Chrome\Application
6.模拟百度输入
from time import sleep
from selenium import webdriver
driver = webdriver.Chrome()
driver.get(r’https://www.baidu.com/’)
driver.find_element_by_xpath("//*[@id=‘kw’]").send_keys(‘selenium’)
sleep(5)
driver.quit()
7.安装遇到的问题
如果报错selenium.common.exceptions.WebDriverException: Message: unknown error: call function result missing 'value’的解决办法
下载对应驱动:http://chromedriver.storage.googleapis.com/index.html