1.查看自己chrome的版本
2.下载浏览器版本对应的chromeDrive
chrom驱动下载地址:http://npm.taobao.org/mirrors/chromedriver/
--------------------------------------------------------------------------------------------------------------------------
Firefox驱动geckodriver 下载地址:https://github.com/mozilla/geckodriver/releases/
IE的驱动IEdriver下载地址:http://www.nuget.org/packages/Selenium.WebDriver.IEDriver/
--------------------------------------------------------------------------------------------------------------------------
3.将下载好的chromeDriver解压好复制到谷歌浏览器安装目录,将谷歌浏览器安装路径添加环境变量中
3.安装pycharm,安装方法参考:
https://www.runoob.com/w3cnote/pycharm-windows-install.html
4.打开pycharm 使用pip下载selenium模块
pip install -U selenium
5.新建一个python文件,开始编写测试脚本
# -*- coding: utf-8 -*-from selenium import webdriverfrom selenium.webdriver.support.select import Selectimport time# 打开浏览器,且打开xxxx页面url = ‘http://xxxxx‘driver = webdriver.Chrome(executable_path="C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe")driver.get(url)#延时2秒time.sleep(2)# 通过id定位xx按钮,点击driver.find_element_by_class_name("xx按钮的类名").click()#延时2秒time.sleep(2)